Marking pixels above a certain value

Hello. I have a problem.Let's say we have an image called img1 and I want to do the following two things (without loops):
"1. Create logical image where every pixel is marked that has a green channel which is greater or equal 0.5. The result should be stored in mark_green."
"2. Set all pixels in the original image (the double image from step 2) to black where _mark_green is true. Store the result in image_masked. Use repmat to complete this task."
Any ideas?

 Respuesta aceptada

James Tursa
James Tursa el 8 de Abr. de 2016
Hint for the 1st part,
G = (insert code here to pick off the green plane)
mark_green = G >= 0.5; % the marked pixels
For the 2nd part, repmat ~mark_green so that it can be used for all of the color planes. You might want to .* the result with your image.
Give it a try, and then post your code if you have problems and need specific advice.

4 comentarios

Trn
Trn el 9 de Abr. de 2016
Editada: James Tursa el 11 de Abr. de 2016
G = image(:,:, 2);
mark_green = G >= 0.5;
Should work right? I'm not sure how to use repmat for the second part.
idxmat = repmat(image_mark_green,[1,1,3]);
image_masked = image;
image_masked(idxmat) = 0;
Trn
Trn el 10 de Abr. de 2016
This works. Thanks! Could you shortly explain what it does exactly?
rashi
rashi el 1 de Mzo. de 2018
1,1,3 means three dimensional right. But from where do three dimensions come here..? Thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 8 de Abr. de 2016

Comentada:

el 1 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by