Suppose I've selected a region of interests out of an image and that now I've a mask and an image where everything's black but the ROI that contains the originals intensity values.
How can I now move this region to a given point obtained with ginput ?
As for now what I've tried was to get the differences in X,Y coordinate of the centroid of my region and the point I want to move it to and then circshifting the matrix with these distances. The result however is not the desired one.
EDIT: Also, is it possible to have one ROI obtained from one image to fit another ROI from another image ?

 Réponse acceptée

Image Analyst
Image Analyst le 26 Déc 2013

0 votes

Simple. Use circshift(). Just figure out how much you need to move it
deltaY = yDesired - yNow; % Rows
deltaX = xDesired - xNow; % Columns.
Then move it
shiftedImage = circshift(originalImage, [deltaY, deltaX]);

2 commentaires

J.L. Jones
J.L. Jones le 26 Déc 2013
Modifié(e) : J.L. Jones le 26 Déc 2013
That's what I was doing, but then I found out that I was misinterpreting the data from ginput (I confused x with y).
Thanks for the answer though.
Do you have an answer for my EDIT part ? The only thing I thought was to to get the centroid of the new ROI and do the same as before, but there's a way to resize accordingly the image as best as possible ?
Image Analyst
Image Analyst le 26 Déc 2013
Confusing x and y with rows and columns is a very common mistake because the order is reversed: (x,y) = (column, row), not (row,column). So it sounds like it's working now.
I don't know what your second question means. What if the ROI in one image is a big rectangle and in the other it is a small circle? What do you want to do in a case like that where they are different shapes and sizes? And why?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by