Move a region to a given point
7 views (last 30 days)
Show older comments
J.L. Jones
on 26 Dec 2013
Commented: Image Analyst
on 26 Dec 2013
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 ?
0 Comments
Accepted Answer
Image Analyst
on 26 Dec 2013
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 Comments
Image Analyst
on 26 Dec 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?
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!