How can I convert arc image to flat rectangle image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ahmed
Posts: 3
Joined: 2016-05-05T04:48:43-07:00
Authentication code: 1151

How can I convert arc image to flat rectangle image

Post by ahmed »

This is my sample image:

Image

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

Please help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply