Class AlgorithmHistogramSliceMatch

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

    public class AlgorithmHistogramSliceMatch
    extends AlgorithmBase
    Algorithm that matches or transforms a match or source slice so as to make its histogram equal to the histogram of a base slice. In order to easily note the great similarity of the histograms, the histogram displays must both be in linear mode rather than log mode so that small differences are not exaggerated. The algorithm is as follows: 1.) Make the histogram for the match image. 2.) Make the histogram cumulative. 3.) Create the scaled cumulative histogram mapping scaled so that the last bin of mapping has the range of the base image. 4.) For the base image create a histogram with the same number of bins as the match image. 5.) Make the histogram cumulative. 6.) Create the scaled cumulative histogram cumHist scaled so that the last bin of cumHist has the range of the base image. 7.) For each value of mapping[i] find the cumHist[j] that is closest in value. 8.) In remap[i] put the value of srcImage corresponding to the jth bin. 9.) For each srcBuffer[i] find the bin number brightnessLevel and replace the srcBuffer[i] with the remap[brightnessLevel]. References: 1.) Digital Image Processing by Rafael C. Gonzalez and Richard E. Woods, Addison-Wesley Publishing Company, 1992, pp. 173-182. 2.) Two-Dimensional Signal and Image Processing by Jae S. Lim, Prentice-Hall, Inc., 1990, pp. 453-459.

    According to Freedman and Diaconis as summarized in "Recent Developments in NonParametric Density Estimation" by Alan Julian Izenman, Journal of the American Statistical Association, March, 1991, Vol. 86, No. 413, pp. 205 - 224: The ideal histogram bin width W is given by W = 2(IQR)pow(N,-1/3) where IQR is the inrterquartile range(the 75 percentile minus the 25th percentile) and N is the number of available samples.

    • Field Detail

      • bufMax

        private float bufMax
        DOCUMENT ME!
      • bufMin

        private float bufMin
        DOCUMENT ME!
      • isColorImage

        private boolean isColorImage
        DOCUMENT ME!
      • referenceSlice

        private int referenceSlice
    • Constructor Detail

      • AlgorithmHistogramSliceMatch

        public AlgorithmHistogramSliceMatch​(ModelImage srcImg,
                                            int referenceSlice)
        Constructor for 3D images in which changes are returned to the source image.
        Parameters:
        srcImg - source image model
        referenceSlice -
      • AlgorithmHistogramSliceMatch

        public AlgorithmHistogramSliceMatch​(ModelImage destImg,
                                            ModelImage srcImg,
                                            int referenceSlice)
        Constructor for 3D images in which changes are placed in a predetermined destination image.
        Parameters:
        destImg - image model where result image is to stored
        srcImg - source image model
        referenceSlice -
    • Method Detail

      • finalize

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

        private void calcInPlace()
        Histogram equalizing of slices to reference slice. Replaces the original image with the filtered image.
      • calcStoreInDest

        private void calcStoreInDest()
        This function produces a new image that has had all slices histogram equalized to reference slice. places filtered image in the destination image.
      • filter

        private void filter​(float[] srcBuffer,
                            float[] baseBuffer)
        just break up each RGB image into these separate monochrome images sliceFilter and then reassemble int aRGB.
        Parameters:
        srcBuffer - source buffer
        baseBuffer - base Buffer
      • getIdealWidth

        private float getIdealWidth​(float[] srcBuffer)
        find the ideal bin width
      • findBufferMinMax

        private void findBufferMinMax​(float[] buf,
                                      int bufStart,
                                      int bufEnd)
        Finds the local maximum and minimum values in the given range in order, as given by the starting and stoping values.
        Parameters:
        buf - float array of values
        bufStart - where to begin looking
        bufEnd - where to stop