MATLAB Answers

0

Is it possible to morph a polygonal ROI into the shape of a second polygon?

Asked by Right Grievous on 7 Nov 2014
Latest activity Answered by Image Analyst
on 7 Nov 2014
Hi everybody,
I was wondering (because it would be extremely helpful to a piece of code I am writing) whether it is possible to specify a region of interest in an image, using impoly for instance, and then morph/reshape this ROI into a different shape? I imagine this working by using some form of image interpolation.
What I want to do is morph an angled rectangle into a vertical rectangle of the same size, I dont want to rotate the image (I have done this already) I want to morph the data in the image (i.e. stretch/squeeze it to fit the new polygon).
Any help with this problem would be appreciated. I know Matlab can do image interpolation and can resize images etc, I just can't find a way to reshape an image...
Thanks,
Rod.

  0 Comments

Sign in to comment.

2 Answers

Answer by Guillaume
on 7 Nov 2014

What you're looking for is a shear transformation. You can perform that using imwarp on the portion of the image you want to transform.

  0 Comments

Sign in to comment.


Answer by Image Analyst
on 7 Nov 2014

Another way is to use activecontour(). Just pass in one as the starting region, one as the ending region, and pass in different number of iterations to get different "in between" regions. See my demo, attached, which creates images like this:
You can see the initial polygon in the lower left, the target polygon in the upper right, and an "in between" polygon in the lower middle. How closely the boundary "Hugs" the final polygon is determined by how many iterations you tell it to do.

  0 Comments

Sign in to comment.