Package gov.nih.mipav.model.algorithms
Class AlgorithmHistogram
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmHistogram
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
Calculates the histogram for an image. The number of bins is determined by the extents of the histogram model. The
calling algorithm can specify if the histogram is to be calculated for whole image or only over VOI regions. The Otsu
and Maximum Entrophy thresholds are also automatically calculated and stored in the ModelHistogram structure. The
Otsu and Max entropy can take time (minutes) to calculate for histgrams with bins larger than (10,000).
- Version:
- 0.1 September 18, 1997
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classUsed specifally by the Otsu threshold algorithm to define a gray level object for calculating probabilities.Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag indicating whether or not histogram data is output to the data window.private booleanprivate booleanIf true the histogram should be calculated for the entire image.private double[]DOCUMENT ME!private int[]DOCUMENT ME!private ModelHistogramReference to the histogram storage object.private ModelImageReference to the image.private double[]DOCUMENT ME!private intprivate intIndicates which channel of the RGB image the histogram should be calculated. 1 = Red channel 2 = Green channel 3 = Blue channelprivate static final intprivate intUsed to indicate the number of histogram bins when using the constructors that do NOT pass in the histogram object.private static final intprivate booleanprivate doubleprivate doubleprivate static final 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
ConstructorsConstructorDescriptionAlgorithmHistogram(ModelHistogram histogram, int RGBOffset, ModelImage image, boolean maskFlag) Constructs the histogram calculation object for an RGB image.AlgorithmHistogram(ModelHistogram histogram, ModelImage image, boolean maskFlag) Constructs the histogram calculation object.AlgorithmHistogram(ModelImage image, int summaryBins) Constructs the histogram calculation object for an image.AlgorithmHistogram(ModelImage image, int summaryBins, boolean maskFlag) Constructs the histogram calculation object for an image.AlgorithmHistogram(ModelImage image, int summaryBins, boolean maskFlag, boolean displayGraph, boolean userLimits, double userMin, double userMax) Constructs the histogram calculation object for an image.AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset) Constructs the histogram calculation object for an RGB image.AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset, boolean maskFlag) Constructs the histogram calculation object for an RGB image.AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset, boolean maskFlag, boolean displayGraph, boolean userLimits, double userMin, double userMax) Constructs the histogram calculation object for an RGB image.AlgorithmHistogram(ModelImage image, int summaryBins, int processMode, boolean displayGraph, boolean userLimits, float userMin, float userMax) Constructs the histogram calculation object for an image.AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset, int processMode, boolean displayGraph, boolean userLimits, float userMin, float userMax) Constructs the histogram calculation object for an RGB image. -
Method Summary
Modifier and TypeMethodDescriptionvoidDispose of local variables.voidentireImage(boolean flag) Sets a flag to indicate if the histogram is to be calculated for the entire image or just the VOI.private intentropySplit(int[] hist) Calculate maximum entropy split of a histogram.voidfinalize()Prepares this class for destruction.double[]DOCUMENT ME!int[]The buffer of all histogram values.double[]DOCUMENT ME!Accessor to the histogram.private intotsuThreshold(ModelImage image, int[] histoBuffer) This algorithm is an implementation of Otsu thresholding technique based on the minimization of inter-class variance [otsu79].voidCalculates the histogram.voidrunData(int bins, int VOINum) Calculates the histogram and outputs the number of counts per bin and area/volume information.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
-
WHOLE_IMAGE
private static final int WHOLE_IMAGE- See Also:
-
TOTAL_VOIS
private static final int TOTAL_VOIS- See Also:
-
SEPARATE_VOIS
private static final int SEPARATE_VOIS- See Also:
-
dataOutput
private boolean dataOutputFlag indicating whether or not histogram data is output to the data window. -
entireImage
private boolean entireImageIf true the histogram should be calculated for the entire image. -
highValue
private double[] highValueDOCUMENT ME! -
histoBuffer
private int[] histoBufferDOCUMENT ME! -
histogram
Reference to the histogram storage object. -
image
Reference to the image. -
lowValue
private double[] lowValueDOCUMENT ME! -
RGBOffset
private int RGBOffsetIndicates which channel of the RGB image the histogram should be calculated. 1 = Red channel 2 = Green channel 3 = Blue channel -
summaryBins
private int summaryBinsUsed to indicate the number of histogram bins when using the constructors that do NOT pass in the histogram object. -
displayGraph
private boolean displayGraph -
userLimits
private boolean userLimits -
userMin
private double userMin -
userMax
private double userMax -
processMode
private int processMode
-
-
Constructor Details
-
AlgorithmHistogram
Constructs the histogram calculation object for an image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogram
-
AlgorithmHistogram
Constructs the histogram calculation object.- Parameters:
histogram- model of a histogramimage- model of the source imagemaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to true
-
AlgorithmHistogram
Constructs the histogram calculation object for an image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogrammaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to true
-
AlgorithmHistogram
public AlgorithmHistogram(ModelImage image, int summaryBins, int processMode, boolean displayGraph, boolean userLimits, float userMin, float userMax) Constructs the histogram calculation object for an image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogramprocessMode- WHOLE_IMAGE, TOTAL_VOIS, or SEPARATE_VOISdisplayGraph- If true, produces a graph for displayuserLimits- If true, histogram goes from userMin to userMax instead of image.getMin() to image.getMax()userMin-usermax-
-
AlgorithmHistogram
public AlgorithmHistogram(ModelImage image, int summaryBins, boolean maskFlag, boolean displayGraph, boolean userLimits, double userMin, double userMax) Constructs the histogram calculation object for an image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogrammaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to truedisplayGraph- If true, produces a graph for displayuserLimits- If true, histogram goes from userMin to userMax instead of image.getMin() to image.getMax()userMin-usermax-
-
AlgorithmHistogram
Constructs the histogram calculation object for an RGB image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogramRGBOffset- correct offset for RED = 1 , GREEN = 2, or BLUE = 3 component to be exported
-
AlgorithmHistogram
public AlgorithmHistogram(ModelHistogram histogram, int RGBOffset, ModelImage image, boolean maskFlag) Constructs the histogram calculation object for an RGB image.- Parameters:
histogram- model of a histogram for a RGB componentRGBOffset- correct offset for RED = 1 , GREEN = 2, or BLUE = 3 component to be exportedimage- model of the source imagemaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to true
-
AlgorithmHistogram
Constructs the histogram calculation object for an RGB image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogramRGBOffset- correct offset for RED = 1 , GREEN = 2, or BLUE = 3 component to be exportedmaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to true
-
AlgorithmHistogram
public AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset, int processMode, boolean displayGraph, boolean userLimits, float userMin, float userMax) Constructs the histogram calculation object for an RGB image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogramRGBOffset- correct offset for RED = 1 , GREEN = 2, or BLUE = 3 component to be exportedprocessMode- WHOLE_IMAGE, TOTAL_VOIS, or SEPARATE_VOISdisplayGraph- If true, produces a graph for display * @param userLimits If true, histogram goes from userMin to userMax instead of image.getMin() to image.getMax()userMin-usermax-
-
AlgorithmHistogram
public AlgorithmHistogram(ModelImage image, int summaryBins, int RGBOffset, boolean maskFlag, boolean displayGraph, boolean userLimits, double userMin, double userMax) Constructs the histogram calculation object for an RGB image.- Parameters:
image- ModelImage the imagesummaryBins- number of bins in the histogramRGBOffset- correct offset for RED = 1 , GREEN = 2, or BLUE = 3 component to be exportedmaskFlag- Flag that indicates that the histogram will be calculated for the whole image if equal to truedisplayGraph- If true, produces a graph for display * @param userLimits If true, histogram goes from userMin to userMax instead of image.getMin() to image.getMax()userMin-usermax-
-
-
Method Details
-
disposeLocal
public void disposeLocal()Dispose of local variables. -
entireImage
public void entireImage(boolean flag) Sets a flag to indicate if the histogram is to be calculated for the entire image or just the VOI.- Parameters:
flag- true = histogram of entire image, false = histogram of VOI
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
getHighValue
public double[] getHighValue()DOCUMENT ME!- Returns:
- double[]
-
getHistoBuffer
public int[] getHistoBuffer()The buffer of all histogram values.- Returns:
- int[]
-
getLowValue
public double[] getLowValue()DOCUMENT ME!- Returns:
- double[]
-
getModelHistogram
Accessor to the histogram.- Returns:
- returns the model of the histogram
-
runAlgorithm
public void runAlgorithm()Calculates the histogram.- Specified by:
runAlgorithmin classAlgorithmBase
-
runData
public void runData(int bins, int VOINum) Calculates the histogram and outputs the number of counts per bin and area/volume information.- Parameters:
bins- number of bins in the histogram
-
entropySplit
private int entropySplit(int[] hist) Calculate maximum entropy split of a histogram. This method is very similar to Otsu's method. Rather than maximising the inter-class variance, it maximizes the inter-class entropy. Entropy is a measure of the uncertainity of an event taking place. You can calculate it as: S = -(sum)p*log2(p) so it is very straightforward to do using the histogram data. (p is the probability of a pixel greyscale value in the image, and (sum) is the greek capital sigma. It is customary to use log in base 2. P.K. Sahoo, S. Soltani, K.C. Wong and, Y.C. Chen "A Survey of Thresholding Techniques", Computer Vision, Graphics, and Image Processing, Vol. 41, pp.233-260, 1988.- Parameters:
hist- histogram to be thresholded.- Returns:
- index of the maximum entropy split.`
- Throws:
IllegalArgumentException- DOCUMENT ME!
-
otsuThreshold
This algorithm is an implementation of Otsu thresholding technique based on the minimization of inter-class variance [otsu79].- Parameters:
image- DOCUMENT ME!histoBuffer- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-