bug in depolar
Posted: 2013-09-10T20:43:22-07:00
Following the discussion in viewtopic.php?f=1&t=23664 there appears to be a bug in the depolar code affecting the angular scale, in the current version 6.8.6-9. This is revealed in the verbose output, eg
coefficient c4 is the first angle in radians. In the fx equivalent code aa should run from the first angle (c4) to the second (c5) as i runs from 0 to the image width. But at i=0, aa=-c4, and at i=<image width> aa does not reach c5 (second angle), but rather some other odd value (c5-2*c4).
So the part of the image expected by computing the angles is not properly mapped. Changing the sign in the first expression to creates the expected output.
This fix can be applied to magick/distort.c at lines 2186 and 2581
Code: Select all
convert fc.png -verbose -distort DePolar "820 780, 893 269, 90, 180" show:
DePolar Distort, Internal Coefficents
c0 = +820.000000
c1 = +780.000000
c2 = +893.000000
c3 = +269.000000
c4 = +1.570796
c5 = +3.141593
c6 = +0.002485
c7 = +0.085470
DePolar Distort, FX Equivelent:
-fx 'aa=(i+.5)*0.002485 -1.570796;
rr=(j+.5)*0.085470 +780.000000;
xx=rr*sin(aa) +893.000000;
yy=rr*cos(aa) +269.000000;
v.p{xx-.5,yy-.5}' \
So the part of the image expected by computing the angles is not properly mapped. Changing the sign in the first expression to
Code: Select all
aa=(i+.5)*0.002485 +1.570796;
This fix can be applied to magick/distort.c at lines 2186 and 2581