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

3 views (last 30 days)
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.

Answers (2)

Guillaume
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.

Image Analyst
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.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!