color all pixels in an image black except white pixels

1 vue (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 1 Fév 2023
Modifié(e) : DGM le 1 Fév 2023
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?

Réponse acceptée

DGM
DGM le 1 Fév 2023
Modifié(e) : DGM le 1 Fév 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)

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by