Page 1 of 1
3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-22T10:41:10-07:00
by wms
Hello,
I've been happily using Fred Weinhaus' 3Dbox script in the past. Now I've updated my system (openSUSE 11.4) which comes with this version of ImageMagick:
Code: Select all
Version: ImageMagick 6.6.5-8 2011-02-14 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP
and I find that convert hangs with full CPU load (on both cores of my Core 2 Duo) on the call that does the perspective distortion:
Code: Select all
3DBox.sh roll=0 pan=-90.00000000000000000000 tilt=0 format=center zoom=0.865 pef=0.5 bgcolor=black filter=lanczos images/im_menu1-0.jpg images/im_menu1-2.jpg images/moon.jpg images/galaxy.jpg images/im_menu1-1.jpg images/Iceberg.jpg frames_0_to_1/cube0000.png
hangs at
Code: Select all
convert -virtual-pixel transparent -mattecolor none '(' /tmp/3DBox.sh.7335/tmp1.mpc -matte -filter lanczos +distort Perspective '0,0 1056.73,92.6186 767,0 -1720.19,182.814 767,767 -1720.19,-182.814 0,767 1056.73,-92.6186' ')' '(' ')' '(' /tmp/3DBox.sh.7335/tmp3.mpc -matte -filter lanczos +distort Perspective '0,0 -1223.55,-130.033 767,0 1660.6,-145.546 767,767 -1720.19,182.814 0,767 1056.73,92.6186' ')' '(' ')' '(' /tmp/3DBox.sh.7335/tmp5.mpc -matte -filter lanczos +distort Perspective '0,0 -1720.19,182.814 767,0 1660.6,-145.546 767,767 1660.6,145.546 0,767 -1720.19,-182.814' ')' '(' /tmp/3DBox.sh.7335/tmp6.mpc -matte -filter lanczos +distort Perspective '0,0 1660.6,145.546 767,0 -1223.55,130.033 767,767 1056.73,-92.6186 0,767 -1720.19,-182.814' ')' -crop '1150x1150-574.5-574.5!' -background black -flatten frames_0_to_1/cube0000.png
I killed the convert process after a few minutes. On my previous installation with ImageMagick 6.5.4.8 this call to convert would have taken a few seconds to complete.
I also tested this:
which left convert running on one core only but it still wouldn't finish.
For completeness, all images are 768x768. As mentioned, this worked fine on the older ImageMagick installation.
Any suggestions are appreciated!
Martin
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-22T12:12:16-07:00
by fmw42
try disabling OpenMP. I have heard of problems on some Linux machines, but don't know if that is the case with your system. Also you may have a version of IM with a bug in it. You might try installing a different version.
If you post links to your input images, I could test those out with your command line.
I did some tests with the examples on my web page for 3Dbox using IM 6.6.9.10 Q16 Mac OSX Tiger.
I fixed one argument trapping issue and uploaded the script again. I think the script has trouble with too many digits after the decimal place. Try cutting your precision down to 6 significant figures or less.
However, it appears that the script has trouble with pan or tilt angles that are too close to 90 multiples. This means that some images are rendered edge-on and that causes problems. In my tests, if those angles are within 2 degrees, either one gets an error message or it takes a very long if not indefinite time to render or a very distorted picture. So I would suggest making sure you use pan or tilt angles that are no closer to 90 than 3 degrees (i.e. 87) degrees. (3 degrees from 90, i.e. 87 degrees, looks pretty much like 90 in terms of the resulting image). My suspicion, though not tested, is that the script may be trying to render back-facing images. Your case seems to be trying to render 4 images and the script should not render more than 3 for any one output image.
I cannot say whether this has been a problem all along or is due to some change in IM. I will try to look into it further when I have time, but cannot guarantee when that might be. It is definitely in my 3Dbox script as I can use 3Drotate on a single image and do a 90 tilt or pan without the system hanging, though the image is blank because the input is being viewed edge-on. However, 89 degrees looks fine and does show some image texture. Thus I believe that distort perspective is not the root cause of the problem.
I believe that in my example animations, I use 10 degree increments from 45 degrees, so that no frame had either tilt or pan of exactly 90 degree multiples but was for example at 85 and then 95.
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-22T17:45:34-07:00
by anthony
Perspective image distortions will become slower for extreme perspective when image tiling is involved.
This only makes sense as more pixels become compressed into a single pixel as you "look into the distance". IM does have some limits and will shortcircuit at extreme ranges. Turning off tiling will also make this faster.
If you want speed over accuracy you can turn of EWA by setting -filter point
However this will cause extreme alising effects in areas where compression exceeds 50%
For information as to what is happening see IM examples, distortions, Pixel Interpolated lookup, susper Sampling and Area re-sampling
http://www.imagemagick.org/Usage/distorts/#lookup
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-22T18:47:32-07:00
by fmw42
Anthony,
I don't think this is an issue of -distort perspective. I can do a pan=90 in 3Drotate and it returns very quickly. So I suspect it has to do with one too many faces (at least one backfacing face) being rendered when it should not in 3Dbox. That may be the issue, but I have not had time to look into it further.
Fred
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-23T08:23:33-07:00
by wms
Fred and Anthony, thanks for your replies! I've diffed the commands that 3DBox runs. The trouble starts here:
Code: Select all
# convert xc: -format '%[fx: (6.12323e-17 * 1) + (0 * 0) + (-1 * 0)]' info:
My previous ImageMagick installation returned
6.12323e-17 which seems about right. The current installation returns
10.4095 which seems to be a bit off
Some more testing suggests that there's a trend:
Code: Select all
# convert xc: -format '%[fx: 1e-9 ]' info:
0.9
# convert xc: -format '%[fx: 1E-9 ]' info:
-8
That is, 1E-x is interpreted as 1-x, 1E+x is interpreted as 1+x, and 1e-x is interpreted as x/10. Funnily, 1e+x is interpreted correctly as 10^x.
Any ideas?
Martin
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-23T08:45:18-07:00
by magick
We have a patch for the bug your reported in ImageMagick 6.7.0 beta available by sometime tomorrow.
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-23T09:33:28-07:00
by fmw42
Yes, that makes sense. At one time IM did not allow scientific notation in fx expressions. But then it was fixed in
Code: Select all
2008-08-04 6.4.2-7 Cristy <quetzlzacatenango@image...>
Support -fx scientific-notation (e.g. '2.0*3.81469e-06').
It appears that it got lost or broken at some point. Thanks for locating that issue. It was one of the other things that I was concerned about, but had not tested yet.
convert xc: -format '%[fx:2.0*1.0e-9]' info:
1.8
I can verify that this is indeed wrong in IM 6.6.9.10 Q16 Mac OSX Tiger.
Thanks Magick for fixing it in the next IM release.
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-23T20:24:39-07:00
by fmw42
This appears to still be broken in IM 6.7.0.0 Q16 Mac OSX Tiger
convert -version
Version: ImageMagick 6.7.0-0 2011-05-23 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features:
convert xc: -format '%[fx:2.0*1.0e-9]' info:
1.8
convert xc: -format '%[fx:2.0*1.0e-09]' info:
1.8
var="1.0e-6"
convert xc: -format "%[fx:2*$var]" info:
1.2
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-24T05:43:37-07:00
by magick
Look for a patch for the problem you reported in ImageMagick 6.7.0-1 Beta by sometime tomorrow. Thanks.
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-26T10:04:22-07:00
by fmw42
magick wrote:Look for a patch for the problem you reported in ImageMagick 6.7.0-1 Beta by sometime tomorrow. Thanks.
This works again now in IM 6.7.0.1 Thanks
Fred
Re: 3Dbox (convert) hangs with 100% CPU load in 6.6.5-8 Q16
Posted: 2011-05-26T10:07:44-07:00
by fmw42
These two test cases work again now in IM 6.7.0.1 Q16 now that the fx scientific notation has been fixed.
3DBox roll=0 pan=-90 tilt=0 format=center zoom=0.865 pef=0.5 \
bgcolor=black filter=lanczos zelda3.jpg lena2.jpg logo3.jpg tmp5.png
3DBox roll=0 pan=-88 tilt=0 format=center zoom=0.865 pef=0.5 \
bgcolor=black filter=lanczos zelda3.jpg lena2.jpg logo3.jpg tmp6.png