color all pixels in an image black except white pixels

1 回表示 (過去 30 日間)
Alberto Acri
Alberto Acri 2023 年 2 月 1 日
編集済み: DGM 2023 年 2 月 1 日
Hi! From the attached .png figure [rxcx3] I would like to keep only the white pixels and turn all other pixels to black. How can I do?

採用された回答

DGM
DGM 2023 年 2 月 1 日
編集済み: DGM 2023 年 2 月 1 日
Presuming that "white" is [255 255 255] within the context of a uint8 RGB image:
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1280620/example_1.png');
inpict = im2gray(inpict);
mk = inpict == 255;
imshow(mk)

その他の回答 (0 件)

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by