possible bug in distort perspective IM 6.6.9.10 Q16

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug in distort perspective IM 6.6.9.10 Q16

Post by fmw42 »

IM 6.6.9.10 Q16 Mac OSX Tiger.

Anthony,

Testing on my 3Dbox script led me to test 90 degree rotations in my 3Drotate script, which shows some minor asymmetry between 90 and -90 rotations with respect to the skycolor i.e. -mattecolor as follows:

Image

Pan=90 leads to coloration issue in skycolor, i.e. mattecolor?

Defaults:
virtual-pixel is background
background is black
mattecolor is black

3Drotate1 pan=90 auto=zc mandril.jpg mandril_pan90zc.jpg
Perspective Projection:
-distort PerspectiveProjection \
'-1.390749, 0.513765, 63.686275, -4.027032,
-2.506420, 285.817193, -0.021837, 0.008067'
Perspective Distort, FX Equivelent:
-fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;
rr=-0.015702*ii +0.000000*jj + 1;
xx=(-0.882649*ii +0.000000*jj +56.212644)/rr;
yy=(-0.442894*ii +0.000000*jj +28.206260)/rr;
rr<0 ? p{ xx-page.x-.5, yy-page.x-.5 } : blue'
./3Drotate_16481.mpc=>mandril_pan90zc.jpg MPC 128x128 128x128+0+0 8-bit DirectClass 0.060u 0:00.080

Which should be equivalent to the control points generated by the script:

convert mandril.jpg -virtual-pixel background -background black \
-mattecolor black -verbose -distort Perspective \
"0,0 63.6862745098,0 127,0 63.6862745098,34 127,127 63.6862745098,92 0,127 63.6862745098,127" \
mandril_pan90zc.jpg

Image


Whereas pan=-90, does not show this effect as the whole image is black.

Defaults:
virtual-pixel is background
background is black
mattecolor is black

3Drotate1 pan=-90 auto=zc mandril.jpg mandril_panm90zc.jpg
Perspective Projection:
-distort PerspectiveProjection \
'12.595127, -9.842898, 63.686275, -1.647869,
0.473557, -10.962272, 0.197768, -0.154553'
Perspective Distort, FX Equivelent:
-fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;
rr=-0.015702*ii -0.000000*jj + 1;
xx=(+0.621573*ii -0.000000*jj -39.585670)/rr;
yy=(+0.693779*ii -0.000000*jj -44.184170)/rr;
rr<0 ? p{ xx-page.x-.5, yy-page.x-.5 } : blue'
./3Drotate_16836.mpc=>mandril_panm90zc.jpg MPC 128x128 128x128+0+0 8-bit Bilevel DirectClass 0.040u 0:00.060

Which should be equivalent to the control points generated by the script:

convert mandril.jpg -virtual-pixel background -background black \
-mattecolor black -verbose -distort Perspective \
"0,0 63.6862745098,34 127,0 63.6862745098,0 127,127 63.6862745098,127 0,127 63.6862745098,92" \
mandril_panm90zc.jpg

Image

Fred
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug in distort perspective IM 6.6.9.10 Q16

Post by anthony »

What do you expect to happen when you take mathematical formulas to extreme limits like this!

My suggestion is to distort by 89.9 degrees rather than 90.0

Also why is your image center line 63.686275? Seems like a rather odd value! actually center line of image in image coordinates is 64, and for the right edge 128
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug in distort perspective IM 6.6.9.10 Q16

Post by fmw42 »

What do you expect to happen when you take mathematical formulas to extreme limits like this!
I understand. But why does it happen for pan=90 but not pan=-90 nor for tilt=90 nor for tilt=-90.
My suggestion is to distort by 89.9 degrees rather than 90.0
Yes, I would agree. I only used that value because another user complained about my 3Dbox script failing and used 90 degrees. So I was checking out the problem by using 3Drotate and thus -distort perspective directly from the control points generated.
Also why is your image center line 63.686275? Seems like a rather odd value! actually center line of image in image coordinates is 64, and for the right edge 128
It is a factor of the perspective and the auto zoom mode that I was using and the generation of the 3D coords for the situation. Not an intentional offset.

It is not a big deal (as I said a minor issue). I just thought you might want to look into it as it is an odd asymmetry, though as you point out, not a very likely case, except when rotating using 3Dbox.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug in distort perspective IM 6.6.9.10 Q16

Post by anthony »

Seems to be more of an exceptional situation, that should be "if'ed" out.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug in distort perspective IM 6.6.9.10 Q16

Post by fmw42 »

anthony wrote:Seems to be more of an exceptional situation, that should be "if'ed" out.

It is a rare case for a simple one-image perspective transformation. Probably not worrying too much about. It was just odd and curious that it only happened for pan=90 and not pan=-90 nor tilt=+-90. Perhaps just a precision difference. However, I just wanted you to be aware of it. Again not really something to worry much about and very low priority due to the exceptional situation.
Post Reply