Barrel distortion and crop don't chain as expected with conv
Posted: 2008-10-08T11:12:05-07:00
ImageMagick 6.4.4 2008-10-07 Q16 OpenMP (compiled from SRPM)
Linux 2.6.25.14-108.fc9.x86_64 #1 SMP x86_64
(same results with convert on Microsoft Windows XP SP2, official binary of ImageMagick 6.4.4 2008-10-05 Q16)
I have a series of images I am applying a barrel distortion to as a correction. To speed things up, I found the coefficients for a crop of the image--the only part I need--using PanoCoef, then tried to use:
...but that didn't work correctly, giving a non-rectilinear output with a lot of stretching in the upper left corner. The same was true of the following Magick++ code which gives the same output:
However, adding a certain indirection suddenly makes the distort have the desired effect:
works as expected, as does:
Thanks,
Patrick
Linux 2.6.25.14-108.fc9.x86_64 #1 SMP x86_64
(same results with convert on Microsoft Windows XP SP2, official binary of ImageMagick 6.4.4 2008-10-05 Q16)
I have a series of images I am applying a barrel distortion to as a correction. To speed things up, I found the coefficients for a crop of the image--the only part I need--using PanoCoef, then tried to use:
Code: Select all
convert image.jpg -gravity Center -crop "800x600+0+0" -distort Barrel "-0.004817967 -0.010172833 -0.028159933 1.043146167" corrected-image.jpg
Code: Select all
const double distortParams[] = {-0.004817967, -0.010172833, -0.028159933, 1.043146167};
image.read("image.jpg");
image.crop(Magick::Geometry(800,600,239,211));
image.distort(Magick::BarrelDistortion,4,distortParams);
image.display();
Code: Select all
convert image.jpg -gravity Center -crop "800x600+0+0" - | convert - -distort Barrel "-0.004817967 -0.010172833 -0.028159933 1.043146167" corrected-image.jpg
Code: Select all
const double distortParams[] = {-0.004817967, -0.010172833, -0.028159933, 1.043146167};
image.read("image.jpg");
image.chop(Magick::Geometry(239,211));
image.crop(Magick::Geometry(800,600));
image.distort(Magick::BarrelDistortion,4,distortParams);
image.display();
Patrick