color all pixels in an image black except white pixels

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

DGM
DGM il 1 Feb 2023
Modificato: DGM il 1 Feb 2023
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)

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by