Page 1 of 1
Barrel distortion vs. LUT map distortion
Posted: 2008-10-25T18:56:56-07:00
by Ryland
I have a script that uses a lot of CPU time. One thing it does is a distortion with a LUT map. I just realized I could do the same effect with a barrel distortion. Is a barrel distortion less CPU intensive than a LUT map distortion? The script runs on a shared hosting web server, so I really need to make it leaner.
Also, is barrel distortion implemented in the PerlMagick API? I can't find it anywhere.
Re: Barrel distortion vs. LUT map distortion
Posted: 2008-10-25T22:18:47-07:00
by fmw42
Ryland wrote:I have a script that uses a lot of CPU time. One thing it does is a distortion with a LUT map. I just realized I could do the same effect with a barrel distortion. Is a barrel distortion less CPU intensive than a LUT map distortion? The script runs on a shared hosting web server, so I really need to make it leaner.
Also, is barrel distortion implemented in the PerlMagick API? I can't find it anywhere.
Depends upon what you mean by LUT map. If you mean using -fx, then -distort barrel will be faster. If you mean -clut, then -clut will be faster. If you mean -displace, then probably (?) -displace is faster, but Anthony is the last word in all of this.
Don't know about implementation in PerlMagick?
Re: Barrel distortion vs. LUT map distortion
Posted: 2008-10-25T22:34:11-07:00
by Ryland
Depends upon what you mean by LUT map. If you mean using -fx, then -distort barrel will be faster. If you mean -clut, then -clut will be faster.
I'm using distortion maps similar to the ones described
here, but I hardly ever use ImageMagick from the command line, I always use it via PerlMagick. I'm guessing it uses -fx, but I don't know for sure. Here's the syntax I use, if it helps:
Code: Select all
$img->Composite(image=>$disp1,compose=>'Displace',blend=>"0x10",gravity=>"NorthWest");
$disp1 is the distortion map, it's a GIF that looks somewhat similar to
this one in the Usage examples for distortion maps.
Don't know about implementation in PerlMagick?
I wouldn't be surprised if it isn't implemented in PerlMagick, many things aren't, and the things that are often use different names or parameters.
Re: Barrel distortion vs. LUT map distortion
Posted: 2008-10-26T11:36:36-07:00
by fmw42
Depends upon what you mean by LUT map. If you mean using -fx, then -distort barrel will be faster. If you mean -clut, then -clut will be faster.
I'm using distortion maps similar to the ones described here, but I hardly ever use ImageMagick from the command line, I always use it via PerlMagick. I'm guessing it uses -fx, but I don't know for sure. Here's the syntax I use, if it helps:
Code:
$img->Composite(image=>$disp1,compose=>'Displace',blend=>"0x10",gravity=>"NorthWest");
You are using a displacement map via -displace and that should be as fast or faster than -distort barrel, except for the time that it takes you to create the displacement maps themselves. So possibly -distort barrel overall may be faster. You will just have to try it and see which is faster. -displace does not use -fx, as far as I know.
Anthony should be able to set this all straight. But the bottom line is try both to see which is faster.
Re: Barrel distortion vs. LUT map distortion
Posted: 2008-10-26T12:23:45-07:00
by Ryland
fmw42 wrote:You are using a displacement map via -displace and that should be as fast or faster than -distort barrel, except for the time that it takes you to create the displacement maps themselves. So possibly -distort barrel overall may be faster.
The displacement map is a static GIF file, so that isn't a factor.
fmw42 wrote: You will just have to try it and see which is faster. -displace does not use -fx, as far as I know.
Anthony should be able to set this all straight. But the bottom line is try both to see which is faster.
I'm not necessarily concerned with speed so much as how much CPU it uses. If one way is faster but eats a lot of CPU and the other is slower but uses much less CPU, I'll go with the slower one. I don't know how to go about finding that out, though.
Re: Barrel distortion vs. LUT map distortion
Posted: 2008-10-26T23:04:03-07:00
by anthony
The Perl API method you are using is the same as described in
http://www.imagemagick.org/Usage/compose/#displace
It is currently a 'composition' -displace method even though really it does not fit in that classification of image operation. The -fx LUT methods are working for a eventual replacement.
The -displace method is a simple direct lookup (one lookup of the source image for each output image.
The -distort Barrel however I believe we have fixed to use Area Resampling, allowing better results for areas of image compression, producing better images, though that would make it slower. You can turn of EWA using -filter point before -distort.
Other than that the two should be about the same speed.
I am planning at some point to properly implement displacement mapping, with Area Sampling for better results, but time line for that is known at this point. It will probably be a special "convert" form of -distort-lut method that will not only allow relative displacements, but also absolute displacement mappings.