Package gov.nih.mipav.model.algorithms
Class AlgorithmHistogramSliceMatch
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.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 Summary
Fields Modifier and Type Field Description private float
bufMax
DOCUMENT ME!private float
bufMin
DOCUMENT ME!private boolean
isColorImage
DOCUMENT ME!private int
referenceSlice
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmHistogramSliceMatch(ModelImage srcImg, int referenceSlice)
Constructor for 3D images in which changes are returned to the source image.AlgorithmHistogramSliceMatch(ModelImage destImg, ModelImage srcImg, int referenceSlice)
Constructor for 3D images in which changes are placed in a predetermined destination image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcInPlace()
Histogram equalizing of slices to reference slice.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.private void
filter(float[] srcBuffer, float[] baseBuffer)
just break up each RGB image into these separate monochrome images sliceFilter and then reassemble int aRGB.void
finalize()
Prepares this class for destruction.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.private float
getIdealWidth(float[] srcBuffer)
find the ideal bin widthvoid
runAlgorithm()
starts the algorithm.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
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 modelreferenceSlice
-
-
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 storedsrcImg
- source image modelreferenceSlice
-
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
starts the algorithm.- Specified by:
runAlgorithm
in classAlgorithmBase
-
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 bufferbaseBuffer
- 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 valuesbufStart
- where to begin lookingbufEnd
- where to stop
-
-