MRaster examples 21.0.0.0
Image Processing Library
|
Read an image, correct it for radial lens discortion, and write out the corrected image. More...
Go to the source code of this file.
Read an image, correct it for radial lens discortion, and write out the corrected image.
Copyright (c) 1988-2015, Mitchell Jay Richling https://www.mitchr.me All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The geomTfrmRevRPoly() method uses a radial polynomial transform. This method may be used to reproduce the behavior of Imagemagick's barrel distortion transformation. In Imagemagick the following terminology and constraints are used:
This is all put together on the command line something like this:
-distort Barrel "A B C D X Y"
We can demonstrate the similar behavior between Imagemagick & this example program like this:
make test_images ./test_images.exe
rm test_images_mcgrid_fimg.tiff magick test_images_mcgrid.tiff -background Green -virtual-pixel Background -interpolate Bilinear -filter point -distort barrel "0.0 -0.0160 0.0" test_images_mcgrid_fimg.tiff start test_images_mcgrid_fimg.tiff
make geomTfrm_LensDistortion ./geomTfrm_LensDistortion.exe test_images_mcgrid.tiff mv geomTfrm_LensDistortion.tiff test_images_mcgrid_fmr.tiff start test_images_mcgrid_fmr.tiff
magick compare -metric mae test_images_mcgrid_fmr.tiff test_images_mcgrid_fimg.tiff out.tiff start out.tiff
magick test_images_mcgrid_fmr.tiff test_images_mcgrid_fimg.tiff -compose Mathematics -define compose:args='0,1,-1,0' -composite out.tiff start out.tiff
Note the images are not identical, but they are very close.
Definition in file geomTfrm_LensDistortion.cpp.