How to flatten an image and find dimensions?
Show older comments
I have a source image shown below (full size)

I want to flatten it and fit it within a circle of known diameter (say 20cm).
Below is an example that i have tried to produce in image editing software where I drew a yellow circle and skewed and resized the image to match with the circle.

Is it possible to do in matlab. I want to measure dimensions of the inner circle based on the known dimension of the outer circle.
Thanks
2 Comments
So basically you have some part of the image which you know (i.e. prior knowledge) is a circle in the real-world, and you want to skew/warp the image in such a way that it is also displayed as a circle?
How do you want to identify that circle: 1) automagically (if so, based on what properties?) or 2) by hand (e.g. a lasso) ?
Answers (1)
Find the 4 vertices of the outer ellipse (i.e., the end points of the major and minor axes). This can be done manually with drawellipse. SInce you already know the corresponding 4 points on the outer circle, you can then use fitgeotform2d to find the projective mapping between the two sets of 4 points.
You can then use the mapping obtained this way to "flatten" the entire image with imwarp. Or you could just extract boundary coordinates on the inner ellipse and transform those with transformPointsForward.
1 Comment
Muha
on 4 May 2026 at 14:47
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!