Class AlgorithmHistogramMatch

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmHistogramMatch
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmHistogramMatch extends AlgorithmBase
Algorithm that matches the transforms a match or source image so as to make its histogram equal to the histogram of a base image. 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 source 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 source 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 Details

    • baseImage

      private ModelImage baseImage
      DOCUMENT ME!
    • bChannel

      private boolean bChannel
      DOCUMENT ME!
    • bufMax

      private float bufMax
      DOCUMENT ME!
    • bufMin

      private float bufMin
      DOCUMENT ME!
    • gChannel

      private boolean gChannel
      DOCUMENT ME!
    • isColorImage

      private boolean isColorImage
      DOCUMENT ME!
    • rChannel

      private boolean rChannel
      DOCUMENT ME!
    • valuesPerPixel

      private int valuesPerPixel
      DOCUMENT ME!
  • Constructor Details

    • AlgorithmHistogramMatch

      public AlgorithmHistogramMatch(ModelImage srcImg, ModelImage baseImage)
      Constructor for 3D images in which changes are returned to the source image.
      Parameters:
      srcImg - source image model
      baseImage - image whose histogram serves as a model
    • AlgorithmHistogramMatch

      public AlgorithmHistogramMatch(ModelImage destImg, ModelImage srcImg, ModelImage baseImage)
      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
      baseImage - image whose histogram serves as a model
  • Method Details

    • finalize

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

      public void runAlgorithm()
      starts the algorithm.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • calcInPlace

      private void calcInPlace()
      Histogram matching of the source image to the base image. Replaces the original image with the filtered image.
    • calcStoreInDest

      private void calcStoreInDest()
      This function produces a new image that has had itself histogram matched to the base image. 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)
      Calculate idealWidth for bins.
    • 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