Page 1 of 1

How can I convert arc image to flat rectangle image

Posted: 2016-05-05T05:01:24-07:00
by ahmed
This is my sample image:

Image

I want to convert it to rectangle (flat) image.

Please help.

Re: How can I convert arc image to flat rectangle image

Posted: 2016-05-05T09:22:13-07:00
by fmw42
You would need to know the inverse transform used by -distort arc and the angle that was used to create it, which could be measured from the angle of the sides. You might be able to use -distort depolar with the angle and the other radii arguments. Otherwise, locate the four corners in your image and use the -distort perspective or -distort BilinearReverse.

Re: How can I convert arc image to flat rectangle image

Posted: 2016-05-06T10:15:05-07:00
by fmw42
I can get kind of close using +distort depolar.

input:
Image

First I pad the image with white to a height of 10,000 and invert it and draw lines.
http://www.fmwconcepts.com/misc_tests/a ... s_flip.png

I measure the angle between vertical and the lines at the edges. I also measure the inner and outer radii and the ratio of the difference in radii to 10,000. Then I use +distort depolar.

Code: Select all

convert i3nc0kf.png -flip -virtual-pixel white +distort depolar \
"7140 5076 2436,2884 -19.4 +19.4" -flip -fuzz 10% -trim +repage -scale 100x20.6% tmp1c.png
Image

Then to check, I do an arc distort, which is similar but has different widths

Code: Select all

convert tmp1c.png -virtual-pixel white +distort arc 38.8 tmp1c_arc.png
Image