Class AlgorithmBarrelDistortion

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmBarrelDistortion
    extends AlgorithmBase
    Corrects barrel and/or pin cushion distortion for 2D images. rsrc = a * rdest**4 + b * rdest**3 + c * rdest**2 + d * rdest rsrc and rdest are specified in units of the min((xDim-1)/2, (yDim-1)/2) Reference 1.) Correcting Barrel Distortion by Helmut Dersch at http://www.all-in-one.ee/~dersch/barrel/barrel.html Quoting from this reference: How to determine suitable Parameters: The correcting function is a third order polynomial. It relates the distance of a pixel from the center of the source image (rsrc) to the corresponding distance in the corrected image (rdest) : rsrc = ( a * rdest3 + b * rdest2 + c * rdest + d ) * rdest The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center. This counteracts barrel distortion, and is the basis for the above corrections. Using positive values shifts distant points towards the center. This counteracts pincussion distortions. Correcting using 'a' affects only the outermost pixels of the image, while 'b' correction is more uniform. Finally, you may correct pincussion and barrel distortions in the same image: If the outer regions exhibit barrel distortions, and the inner parts pincussion, you should use negative 'a' and positive 'b' values. If you do not want to scale the image, you should set d so that a +b + c + d = 1. In most cases, you will get quite satisfactory results by using just one parameter, like the 'b'-parameter in the above examples. These examples may also serve as a guide to how large these values should be, ie around 0.1 if the distortion is quite visible, or around 0.01 if it is very small. Simply optimize this starting value until you like your image. Reference 2.) Lens correction model by From PanoTools.org Wiki at http://wiki.panotools.org/Lens_correction_model Quoting from this reference: Usual values for a, b, and c are below 1.0, in most cases below 0.01. The a and c parameters control more complex forms of distortion. In most cases it will be enough to optimize for the b parameter only, which is good at correcting normal barrel distortion and pincushion distortion.
    • Field Detail

      • a

        private float a
        DOCUMENT ME!
      • b

        private float b
        DOCUMENT ME!
      • c

        private float c
      • d

        private float d
    • Constructor Detail

      • AlgorithmBarrelDistortion

        public AlgorithmBarrelDistortion()
        AlgorithmBarrelDistortion - default constructor.
      • AlgorithmBarrelDistortion

        public AlgorithmBarrelDistortion​(ModelImage destImg,
                                         ModelImage srcImg,
                                         float a,
                                         float b,
                                         float c,
                                         float d)
        AlgorithmBarrelDistortion.
        Parameters:
        destImg - DOCUMENT ME!
        srcImg - DOCUMENT ME!
        a -
        b -
        c -
        d -