MATLAB Save pixel location for later use

38 Views Asked by At

I am trying to use a threshold to highlight certain pixels in the image and save their coordination in a matrix so that I can highlight the pixels of the same coordination in a different image. How could I do that?

1

There are 1 best solutions below

0
FangQ On

the pixels in a selected image can be uniquely identified as a set of indices stored as a 1D vector. as long as your 2nd image has the same dimension, you can manipulate the pixels using the same index vector.

see example below

im1=peaks;
threshold=0;
im2=-im1;

idx=find(im1>threshold);
mask=zeros(size(im2));
mask(idx)=1;
imagesc(im2.*mask);
figure;
imagesc(im2);
hold on;
contour(mask);