Class AlgorithmLocalNormalization

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

    public class AlgorithmLocalNormalization
    extends AlgorithmBase
    Local Normalisation equalises colour levels among pixels by removing variations due to lighting; this brings out contrasts in detail.

    This is done by normalizing a surface-detail version of an image with its slowly varying local average image. That is to say, each pixel of the output image is the value at that location of the pixel of the high-frequency image divided by the pixel at that same location of the low-frequency image.

    The surface-detail image is generated by using an unsharp masking algorithm, and the local average image is a low-pass image generated using a general-purpose (but fast) frequency filter.

    References:

    1. Local Normalization. http://bigwww.epfl.ch/demo/normalize/desc.html
    2. Halyo, Nesim; Rahman, Zia-ur; Park, Stephen. "Information Content in Nonlinear Local Normalization Processing of Digital Images". College of William and Mary. Williamsburg, Virgiana.
    See Also:
    AlgorithmUnsharpMask, AlgorithmFrequencyFilter
    • Field Detail

      • frequency

        private float frequency
        FrequencyFilter's low-pass cut-off frequency.
      • is2d

        private boolean is2d
        Images that are solely 2D images set this to true; images with other dimensionality are false.
      • isColourImage

        private boolean isColourImage
        Colour images set this to true; monochromatic should be false;.
      • kernelDiameter

        private int kernelDiameter
        Required by the low pass filter, but is unused with these options.
      • norm

        private float[] norm
        temporary image-data buffer to store (hi-pass)/(lo-pass) data.
      • rChannel

        private boolean rChannel
        when true, indicates whether to process the colour channel.
      • gChannel

        private boolean gChannel
        when true, indicates whether to process the colour channel.
      • bChannel

        private boolean bChannel
        when true, indicates whether to process the colour channel.
      • sigmas

        private float[] sigmas
        UnsharpMask sigmas, for blurring.
      • tempImage

        private ModelImage[] tempImage
        a temporary image array.
      • unsharper

        private AlgorithmUnsharpMask unsharper
        the UnsharpMask algorithm, to hi-pass filter the image.
      • weightingFactor

        private double weightingFactor
        UnsharpMask weighting factor.
    • Constructor Detail

      • AlgorithmLocalNormalization

        public AlgorithmLocalNormalization​(ModelImage dest,
                                           ModelImage src,
                                           float[] sigmas,
                                           double weight,
                                           int kernSize,
                                           float freq)
        This constructor initialises a Local normalisation algorithm for a source and destination image, and ensures that the destination image is ModelStorageBase.FLOAT.

        Currently (8 May 2003), this algorithm does not support replacing the original data set with that of the locally-normalized image.

        Parameters:
        dest - DOCUMENT ME!
        src - DOCUMENT ME!
        sigmas - DOCUMENT ME!
        weight - DOCUMENT ME!
        kernSize - DOCUMENT ME!
        freq - DOCUMENT ME!
    • Method Detail

      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • runAlgorithm

        public void runAlgorithm()
        Standard algorithm run method. It will not run if the source Image is null. The calculation is done and placed in a separate destination image if it is to be stored there.
        Specified by:
        runAlgorithm in class AlgorithmBase
      • setRGBChannelFilter

        public void setRGBChannelFilter​(boolean r,
                                        boolean g,
                                        boolean b)
        RGB images are local-normalized by 'channel.' That is, each colour, red, blue and green, is filtered independantly of the other two colours. This filter permits selectively filtering any combination of the three channels instead of simply filtering all three. True for any of the arguments enforces filtering that channel.
        Parameters:
        r - Filter red channel.
        g - Filter green channel.
        b - Filter blue channel.
      • calcInPlace

        private void calcInPlace()
        Filters the source image. Replaces the original image with the filtered image.

        Does not currently work.

      • calcStoreInDest

        private void calcStoreInDest()
        This function produces a local-normalized image into a ModelImage that does not replace the original image-data.
      • doImageDivision

        private float[] doImageDivision​(float[] top,
                                        float[] bot)
        takes the data of the two images, one unsharp'd and the other gaussian blur'd, and divides the two pixel-by-pixel to find the locally normalized value for each pixel.
        Parameters:
        top - DOCUMENT ME!
        bot - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • normalize

        private void normalize()
        works depending on the extent of the image and the colourisation of the source image in question.

        calls to doImageDivision(...) for as many slices (and selected colour channels) as necessary to finish off the image.

        See Also:
        doImageDivision(float[], float[])