I have written the following GIMP script-fu
function to remove lens distortion from an image using the lens-distortion-plugin
. I execute this script through a command line function from my main python script. Just wondering if there is an equivalent ImageMagic function (or any other library) to achieve the same so that i don't have to leave the python script.
lens-distortion.scm
(define (lens-distortion filename destination)
(let* (
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) ; load the image
(drawable (car (gimp-image-flatten image)))
(offset-x -3.51)
(offset-y -9.36)
(main-adjust 28.07)
(edge-adjust 0)
(rescale -100)
(brighten 0.58)
)
(gimp-message (string-append "processing-" filename))
(plug-in-lens-distortion RUN-NONINTERACTIVE image drawable offset-x offset-y main-adjust edge-adjust rescale brighten)
(gimp-file-save RUN-NONINTERACTIVE image drawable destination destination)
(gimp-image-delete image)
)
)
Example input image:
As you can see the distortion does not start from the middle which makes it a lot challenging to get rid of it.