Hi,
I'm writing some bash scripts to do some video compositing with imagemagick. One of the commands involves the "-distort arc" command. I'm using it to alter a gradient mask that then is used to composite two images. The complete bash scripts can be seen under http://kaputte-moderne.sweat-lodge.de/aurora.html and there's also a video there to help you get an idea of where I'm going with this. The script with this particular command is called sunset.
Anyway processing times get ridiculously long when the top radius and bottom radius parameters get very small or close to each other (not sure which one is causing this). My question is whether there is any way around this? If not, is there a correlation between image size, top radius and bottom radius limits, and reasonable processing times? What I mean is, given the image size can I write a formula that will give a minimum top and bottom radius value that will not take too long to process?
Anyway, here's the command I'm using:
convert -size 720x576 gradient: -rotate 180 -sigmoidal-contrast 50,100% -distort arc 150 -gravity north -crop 720x576+0+0 -resize 720x576! +repage maskC.mpc
convert input2.png \( input1.png \( \( -size 576x720 gradient: -rotate 90 \) maskC.mpc -channel RGB -combine \) -fx 'p{v.r*w,v.g*h}' \) \( -size 720x576 gradient: -set option:distort:viewport 720x576-360-576 -distort arc 180,0,15,0 -negate \) -compose src-over -composite output.png
Would be grateful for any clue you could give me, Rob
Distort arc: small top and bottom radii
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Distort arc: small top and bottom radii
The processing time will get long when IM needs to compress a LOT of the source image into a small area, This happens at extreme limits such as perspective horizon, or the center of an arc.rob wrote:Anyway processing times get ridiculously long when the top radius and bottom radius parameters get very small or close to each other (not sure which one is causing this). My question is whether there is any way around this?
The solution is to either avoid such limits, OR turn of the image compression by using -filter point. But you may not like the result!
See notes of EWA re-sampling and Super Sampling techniques used to produce nicer images on image compression during distorts.
http://www.imagemagick.org/Usage/distor ... ts/#lookup
and onward. Or read that whole introduction to understand how distortions work!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Distort arc: small top and bottom radii
Looking more closely at the command, I finally figured out that only the gradient is being distorted. Since -filter point doesn't have any visible negative effect on gradients, I see no problem in using it. I was at first afraid that I'd loose quality, but I guess I should have looked more closely. Anyway, here's the command I'm using (I forgot a +repage in my original post):
convert -size 720x576 gradient: -rotate 180 -sigmoidal-contrast 50,100% -distort arc 150 +repage -gravity north -crop 720x576+0+0 -resize 720x576! +repage maskC.mpc
convert input2.png \( input1.png \( \( -size 576x720 gradient: -rotate 90 \) maskC.mpc -channel RGB -combine \) -fx 'p{v.r*w,v.g*h}' \) \( -filter point -size 720x576 gradient: -set option:distort:viewport 720x576-360-576 -distort arc 180,0,15,0 -negate \) -compose src-over -composite output.png
I have a few more questions, but I'll look at them more closely and put them in separate posts if necessary.
Thanks
convert -size 720x576 gradient: -rotate 180 -sigmoidal-contrast 50,100% -distort arc 150 +repage -gravity north -crop 720x576+0+0 -resize 720x576! +repage maskC.mpc
convert input2.png \( input1.png \( \( -size 576x720 gradient: -rotate 90 \) maskC.mpc -channel RGB -combine \) -fx 'p{v.r*w,v.g*h}' \) \( -filter point -size 720x576 gradient: -set option:distort:viewport 720x576-360-576 -distort arc 180,0,15,0 -negate \) -compose src-over -composite output.png
I have a few more questions, but I'll look at them more closely and put them in separate posts if necessary.
Thanks