[magick-users] RE: Barrel / pincushion distortion

Fred Weinhaus fmw at alink.net
Mon Feb 25 19:52:02 PST 2008


By the way, GIMP has an interactive lens distortion tool (under 
Filters->Distorts) that can correct this kind of distortion. I took 
the first example from Dersch's page and was able to correct it using 
GIMP.

Any chance GIMP code is open source and some of its code can be used, 
such as this one?


Fred





>Wolfgang Hugemann on  wrote...
>| Playing arount with the "new" -distortion option, I was surprised that
>| it doesn't support barrel / pincushion distortion. Wouldn't that be easy
>| to involve?
>|
>Actually there are a huge number of distortions that have yet to be
>added. Including those.
>
>I have been concentrating on 'quality' improvements, before adding more
>distortions.  Though that is on hold due to the pressure of other
>commitments in my life, a trip to China for the whole of April being
>and the Weifang International Kite Festival, being the main one.
>
>
>That however should not stop you or others contributing new distortions.
>
>Though I recommend you read up on   General Distortion Techniques
>    http://imagemagick.org/Usage/distorts/#summary
>So as to get an understanding of what is going on.
>
>
>What is needed for a distortion function...
>
>  1/ The function to convert a i,j (destination) -> x,y (source) coordinate.
>     See the reasons in  Reverse Pixel Mapping
>        http://imagemagick.org/Usage/distorts/#mapping
>
>     This basically defines the distorting in programmable terms.
>
>  2/ The scale changes needed for an image at that point..
>     that is how much the original image is compressed (and optionally rotated)
>     This can be expressed as 'none' (point interpolation - not good)
>     or as a direct scale,  or as a vector scaling
>          di -> dx,dy  vector  and    dj -> dx,dy
>     to form the 'resampling' ellipse.  See the diagram in
>       http://imagemagick.org/Usage/distorts/#area-resampling
>     Though mathematically the arrows are reversed, as we need to
>     determine the ellipse size, so we can then map the colors in the
>     direction indicated.
>
>     Without this you will see the pixel mapping problems at extreme
>     distortions, such as IM has with the old -implode operator
>        http://imagemagick.org/Usage/distorts/#implode
>
>  3/ And finally if you like the +distort to handle automatic resizing of
>     the resulting image, you need a method of determining how big to
>     make the final image from a give source image, that as a x,y offset
>     and a specific w,h size.
>
>     Without this, macro scale resizing of the resulting image, such as
>     what -rotate does, does not happen.
>     See the SRT distortion  http://imagemagick.org/Usage/distorts/#srt
>
>
>The first is required, but can be difficult.  For example the 'Bilinear'
>distort is currently mapped in a reverse direction as it is a difficult
>operation to 'reverse' mathematically.
>
>The other two 'needs' are optional.
>
>However for heavy distorts, such as 'perspective' the second option is
>very much a MUST.  Again see
>    http://imagemagick.org/Usage/distorts/#area-resampling
>
>And sometimes for a distortion that completely remaps the coordinate
>system, the third need is not optional at all.  For example the 'Arc'
>distortion always performs the third (macro image resize) regardless of
>the '+' or '-' sign of the -distort operation, otherwise it is not as
>simple to use as I have designed it.
>
>
>| There are astonishingly few programs on the market that perform this
>| sort of transformation / correction. Recently, I have been experimenting
>| with PTlens and found its results in short focal length correction
>| surprising. (Or, to put it the other way round: I was surprised by the
>| extend of distortion that normal digital cameras produce at short focal
>| lenghts.)
>|
>Yes I know. I have planned it, just not implemented it.
>
>
>| The good thing about PTlens is that the correction factors for most
>| digital cameras are already in its database and that it readily extracts
>| the focal length from the EXIF data and corrects the photo accordingly.
>| (And that it allows batch processing.)
>|
>A database of lens distortions is not something IM would probably get
>into.
>
>| I instantly thought that this could also be done with IM (without having
>| to use the -fx operator). But it can't at the moment -- right?
>|
>Right.  But if you have a bit of programming skill, you could give it a
>try, or just workout the details of the above 'needs'.
>
>   Anthony Thyssen ( System Programmer )    <A.Thyssen at griffith.edu.au>


More information about the Magick-users mailing list