Reusing ROI for another image

Hey,
I have two images that I want to mask. My desired region is the same size on both images, so I want two masks of the same size. However, since the region is shifted in X and Y coordinates, I want to align it by hand. My idea is to create a mask on the first image and export the ROI to the second, so I just have to move it to the right position and create the mask. I tried using roipoly() on the first picture and importing the coordinates to the roipoly() of the second image, but nothing happens. I can't even draw anything on the second roipoly(). I also tried to use drawpolygon(), this one shows me my ROI of my first image, but I still can't save any new ROI or export any coordinates. Do you have any tips?
[Mask,xi,yi] = roipoly(Image1);
imwrite[...]
Mask2 = roipoly(Image2,xi,yi); %or Mask2 = drawpolygon('Position',[xi yi],);

Risposte (1)

Image Analyst
Image Analyst il 22 Mag 2020

0 voti

You could plot xi, yi over your image and have two scrollbars on your GUI to let them nudge the outline up, down, left, or right.

2 Commenti

Chris
Chris il 26 Mag 2020
I will try this solution. But is there also the possibility to get the coordinates?
Sure. You could pass the xi and yi from one function to another, or save to disk with save() and recall with load() if you have to. See the FAQ.

Accedi per commentare.

Prodotti

Release

R2020a

Richiesto:

il 22 Mag 2020

Commentato:

il 26 Mag 2020

Community Treasure Hunt

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

Start Hunting!

Translated by