MATLAB: How to find pixel having a specific value and copy those regions to a new matrix

image processing

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

Best Answer

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