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:
ActionListener,WindowListener,Runnable,EventListener
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate floatDOCUMENT ME!private floatDOCUMENT ME!private booleanDOCUMENT ME!private intFields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmHistogramSliceMatch(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
Modifier and TypeMethodDescriptionprivate voidHistogram equalizing of slices to reference slice.private voidThis function produces a new image that has had all slices histogram equalized to reference slice. places filtered image in the destination image.private voidfilter(float[] srcBuffer, float[] baseBuffer) just break up each RGB image into these separate monochrome images sliceFilter and then reassemble int aRGB.voidfinalize()Prepares this class for destruction.private voidfindBufferMinMax(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 floatgetIdealWidth(float[] srcBuffer) find the ideal bin widthvoidstarts 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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
bufMax
private float bufMaxDOCUMENT ME! -
bufMin
private float bufMinDOCUMENT ME! -
isColorImage
private boolean isColorImageDOCUMENT ME! -
referenceSlice
private int referenceSlice
-
-
Constructor Details
-
AlgorithmHistogramSliceMatch
Constructor for 3D images in which changes are returned to the source image.- Parameters:
srcImg- source image modelreferenceSlice-
-
AlgorithmHistogramSliceMatch
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 Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()starts the algorithm.- Specified by:
runAlgorithmin 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
-