Arc 360 radius as function of input image w x h

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
gubach
Posts: 45
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

Arc 360 radius as function of input image w x h

Post by gubach » 2016-02-22T04:55:18-07:00

The general case "-distort Arc 360" generates from an image with $w_i x $h_i a circle structure
with radius $r by bending the right and left edge together; the resulting square image has the
width 2*$r. In the specific case "-distort Arc '360, 0, $r, 0'" the radius can be predefined but
is there a formula (or heuristic) that links the values $r = f($w_i , $h_i) in the
general case (it is not $r = $h one might expect if the bending is considered)?

snibgo
Posts: 12139
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Arc 360 radius as function of input image w x h

Post by snibgo » 2016-02-22T05:11:55-07:00

The answer comes from a quick read of distort.c.

new_radius = cols/(2.pi) + (rows-1)/2.0

The new width and height are 2*new_radius, with a conversion to integer.
snibgo's IM pages: im.snibgo.com

gubach
Posts: 45
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

Re: Arc 360 radius as function of input image w x h

Post by gubach » 2016-02-22T09:37:57-07:00

thank you for answering; I am puzzling what 2.pi might be? 2*pi?
In an example I just made with Arc 360 (in: w=3740 x h=1872 out: r=1452) the term 2.pi becomes 7.241... so a bit more than 2*pi

snibgo
Posts: 12139
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Arc 360 radius as function of input image w x h

Post by snibgo » 2016-02-22T10:27:17-07:00

Yes, 2 times pi where pi = 3.141...

What version IM are you using? With 6.9.2-5 I get:

Code: Select all

f:\web\im>%IM%convert -size 3740x1872 xc: -distort Arc 360 +repage info:

xc: XC 3064x3064 16-bit sRGB 11.391u 0:01.468
So r=1532.

The formula gives:

Code: Select all

f:\web\im>ccalc = 3740/(2*pi) + (1872-1)/2.0= exit

1530.739487163689
I haven't traced the code to find where 1530.739 becomes 1532.
snibgo's IM pages: im.snibgo.com

gubach
Posts: 45
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

Re: Arc 360 radius as function of input image w x h

Post by gubach » 2016-02-22T16:08:59-07:00

thank you for clarifying the 2*pi.

> What version IM are you using?
For some reasons I am using an old development environment with ImageMagick 6.6.2-5 2010-08-12 Q8


> I haven't traced the code to find where 1530.739 becomes 1532.
On http://www.imagemagick.org/Usage/distorts there is a hint about anti-aliasing effects:
"This creates a ring that is 100 pixels wide, though the accomidating image is 102 pixels wide to allow for anti-aliasing effects. "
so int(1530.739)+2 = 1532


Morerover I am not able to reproduce the result of Arc 360 with Arc '360 0 $r 0' were $r is derived from the first result. The appearence of the images are viewable different so I am suspecting that there are hidden variables and/or parameter settings in the code.

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

Re: Arc 360 radius as function of input image w x h

Post by fmw42 » 2016-02-22T19:15:39-07:00

Just a note: your version of Imagemagick is over 300 versions old. You might consider upgrading IM.

Post Reply