How to convert the green pixels to white?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
charuleelaa vanilavarasu
el 20 de Mzo. de 2016
Comentada: Image Analyst
el 21 de Mzo. de 2016
I have this image labelled dark green(In the image attached). I want to turn all of the pixels that are not black to white. How do i do that?
1 comentario
Respuesta aceptada
Walter Roberson
el 20 de Mzo. de 2016
%black pixels have 0 for all 3 components, R, G, B. So a non-black pixel has at least one non-0 component
mask = any(YourRGBImage,3); %true if any component is non-zero
%now that we know which ones are non-black, make those pixels white
%ah, short-cut: since logical true is 1 and white is 1, and logical false is 0 and black is 0
%we can just use the mask itself as the black / white image
maskedImage = double(repmat(mask, 1, 1, 3));
3 comentarios
charuleelaa vanilavarasu
el 21 de Mzo. de 2016
Editada: charuleelaa vanilavarasu
el 21 de Mzo. de 2016
Más respuestas (1)
Image Analyst
el 21 de Mzo. de 2016
I hve several color segmentation demos in my File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Adapt one of them to find pixels that you consider to be of a roughly or exactly "green" color. This will give you a mask of what pixels are green.
If you really want to "I want to turn all of the pixels that are not black to white." then it really doesn't matter if they're green or purple or yellow or any other color to start with, does it? In that case, use Walter's code to turn non-pure-black pixels to white.
4 comentarios
charuleelaa vanilavarasu
el 21 de Mzo. de 2016
Editada: Walter Roberson
el 21 de Mzo. de 2016
Image Analyst
el 21 de Mzo. de 2016
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!