how to find pixel having a specific value and copy those regions to a new matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Elysi Cochin
el 20 de Sept. de 2017
Comentada: Walter Roberson
el 20 de Sept. de 2017
find pixel having a specific value and copy those regions to a new matrix...
[rows, columns] = find(L == 0);
how to copy to a new matrix
0 comentarios
Respuesta aceptada
Bjorn Gustavsson
el 20 de Sept. de 2017
Something like this should get what you ask for:
Img = peaks;
clf
subplot(2,1,1)
imagesc(Img),colorbar
I2 = 0*Img;
Irange = [2 4];
I2(Irange(1)<=Img(:)&Img(:)<=Irange(2)) = Img(Irange(1)<=Img(:)&Img(:)<=Irange(2));
subplot(2,1,2)
imagesc(I2)
HTH
1 comentario
Walter Roberson
el 20 de Sept. de 2017
I usually put the condition into a variable to avoid recomputing it.
I2 = zeros(size(IMG), class(IMG)); %but 0*Img works too
mask = Irange(1) <= Img & Img <= Irange(2);
I2(mask) = Img(mask);
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!