color all pixels in an image black except white pixels

1 次查看(过去 30 天)
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