WEIRD: convert -distort Affine producing black images

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.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

Cristy's patch looks like a good one: In exact arithmetic, we are never taking a square root of something negative. But we're not in exact arithmetic.
From svn diff:

Code: Select all

-  const double sqrt_discriminant = sqrt(discriminant);
+  const double sqrt_discriminant =
+    sqrt(discriminant < -0.0 ? 0.0 : discriminant);
If more problems crop up, I should carefully put some MagickEpsilons in there.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

This bug is an immediate illustration of "direct" SVD decompositions being ill-conditioned. Fast, but better be extra careful. And I was not.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

Forgot to use changelist again with IM6 (Makefile.PL, magick-baseconfig.h and version.h changed when I did not intend to).
-----
In any case, I made the test this one to minimize the impact of "various computation branches on floating point computation":

Code: Select all

 /*
   * In exact arithmetic, discriminant can't be negative. In floating
   * point, it can, because of the bad conditioning of SVD
   * decompositions done through the associated normal matrix.
   */
  const double sqrt_discriminant =
    sqrt(discriminant > 0.0 ? discriminant : 0.0);
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: WEIRD: convert -distort Affine producing black images

Post by anthony »

The patch seems to have solved the problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

I'm really impressed at how fast Cristy, Anthony and Fred got the issue figured out and solved.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: WEIRD: convert -distort Affine producing black images

Post by fmw42 »

NicolasRobidoux wrote:I'm really impressed at how fast Cristy, Anthony and Fred got the issue figured out and solved.
Thanks goes to Anthony and Cristy and you. I really had nothing to contribute on this one.
tsanders
Posts: 13
Joined: 2012-12-06T04:14:34-07:00
Authentication code: 6789

Re: WEIRD: convert -distort Affine producing black images

Post by tsanders »

Is there any progress on the new beta release? Thanks.
tsanders
Posts: 13
Joined: 2012-12-06T04:14:34-07:00
Authentication code: 6789

Re: WEIRD: convert -distort Affine producing black images

Post by tsanders »

Found it! Checked it out and it works 100% OK! Thanks everyone, GREAT JOB!
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

tsanders wrote:GREAT JOB!
... to you too. Thank you for your very informative bug report.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: WEIRD: convert -distort Affine producing black images

Post by anthony »

I have mapped it into IMv7 too.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: WEIRD: convert -distort Affine producing black images

Post by NicolasRobidoux »

anthony wrote:I have mapped it into IMv7 too.
Apologies if I forgot. Juggling -> dropping balls.
Post Reply