'-distort Perspective' doesnt seem to work properly
Posted: 2014-04-10T14:35:44-07:00
In the example I did (using IM 6.8.6-Q16), i intentionally kept the lower-left and lower-right 'corners' of my image IDENTICAL (eg; specified to NOT shift), and i intentionally shifted the upper-left and upper-right 'corners' of my image.
ImageMagick did do the distort, but in my opinion - it did so incorrectly. Notice how the lower-right corner remained in its' original location? (i believe this is proper). But, notice how the lower-left corner has SHIFTED (i believe this is a mistake as i told ImageMagick NOT to change that corners location). it was originally at pixel location (250,2449) and in the output image, it became shifted to a new location of (280,2213)
here is the input graphic file: [having 'corners of interest' at pixel locations (250,250) (2449,250) (250,2449) (2449,2449)]
gregaiken.com/files/in.png
here is the output graphic file:
gregaiken.com/files/out.png
here is the command i used to do the perspective distort:
"C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" in.png -verbose -distort Perspective
"250.5,250.5,500.5,500.5 2249.5,250.5,2000.5,700.5 250.5,2449.5,250.5,2449.5 2449.5,2449.5,2449.5,2449.5" out.png
(upper-left)DISTORT (upper-right)DISTORT (lower-left)DONT-MOVE (lower-right)DONT-MOVE
Perspective Projection:
-distort PerspectiveProjection \
'0.850329, -0.142621, 314.837195, 0.137775,
0.569933, 314.837195, 0.000056, -0.000123'
Perspective Distort, FX Equivelent:
-fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;
rr=-0.000097*ii +0.000192*jj + 1;
xx=(+1.207047*ii +0.205965*jj -444.868729)/rr;
yy=(-0.238095*ii +1.651107*jj -444.868729)/rr;
rr>0 ? p{ xx-page.x-.5, yy-page.y-.5 } : blue' \
in.png=>out.png PNG 2500x2500 2500x2500+0+0 8-bit sRGB 300KB 12.371u 0:03.626
ImageMagick did do the distort, but in my opinion - it did so incorrectly. Notice how the lower-right corner remained in its' original location? (i believe this is proper). But, notice how the lower-left corner has SHIFTED (i believe this is a mistake as i told ImageMagick NOT to change that corners location). it was originally at pixel location (250,2449) and in the output image, it became shifted to a new location of (280,2213)
here is the input graphic file: [having 'corners of interest' at pixel locations (250,250) (2449,250) (250,2449) (2449,2449)]
gregaiken.com/files/in.png
here is the output graphic file:
gregaiken.com/files/out.png
here is the command i used to do the perspective distort:
"C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" in.png -verbose -distort Perspective
"250.5,250.5,500.5,500.5 2249.5,250.5,2000.5,700.5 250.5,2449.5,250.5,2449.5 2449.5,2449.5,2449.5,2449.5" out.png
(upper-left)DISTORT (upper-right)DISTORT (lower-left)DONT-MOVE (lower-right)DONT-MOVE
Perspective Projection:
-distort PerspectiveProjection \
'0.850329, -0.142621, 314.837195, 0.137775,
0.569933, 314.837195, 0.000056, -0.000123'
Perspective Distort, FX Equivelent:
-fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;
rr=-0.000097*ii +0.000192*jj + 1;
xx=(+1.207047*ii +0.205965*jj -444.868729)/rr;
yy=(-0.238095*ii +1.651107*jj -444.868729)/rr;
rr>0 ? p{ xx-page.x-.5, yy-page.y-.5 } : blue' \
in.png=>out.png PNG 2500x2500 2500x2500+0+0 8-bit sRGB 300KB 12.371u 0:03.626