Package gov.nih.mipav.model.algorithms
Class AlgorithmEntropyMinimization
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmEntropyMinimization
- All Implemented Interfaces:
de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables,ActionListener,WindowListener,Runnable,EventListener
public class AlgorithmEntropyMinimization
extends AlgorithmBase
implements de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
DOCUMENT ME!
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private intDOCUMENT ME!private booleanDOCUMENT ME!private float[]DOCUMENT ME!private doubleDOCUMENT ME!private intNumber of pixels available for histogram formation.private double[]Buffer holding calculation for noiseless U(x,y).private intDOCUMENT ME!private doubleoriginal image maximum.private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleoriginal image minimum.private doubleDOCUMENT ME!private doubleDOCUMENT ME!private doubleDOCUMENT ME!static final intQuadratic multiplicative noise.static final intCubic multiplicative noise.static final intThe user can choose to use thresholding to exclude the background from any processing.private intNOISE_MA2 or NOISE_M2.private intNumbering of shading correction parameters.private boolean[]DOCUMENT ME!private intpixelIncrement is increased above 1 if subsampling.private doubleTolerance passed to Powell's algorithm.private intxDim * yDim.private booleanIf true, subsample image for histogram formation.private floatDOCUMENT ME!private booleanIf true don't use pixels below thresholdLevel that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel.private boolean[]True for source input locations not having image min or image max values.private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intHandle case where zDim is far less than xDim and yDimFields 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
ConstructorsConstructorDescriptionAlgorithmEntropyMinimization(ModelImage srcImage, boolean thresholdSelected, float thresholdLevel, boolean subsample, int noiseType) Creates a new AlgorithmEntropyMinimization object.AlgorithmEntropyMinimization(ModelImage resultImage, ModelImage srcImage, boolean thresholdSelected, float thresholdLevel, boolean subsample, int noiseType) Creates a new AlgorithmEntropyMinimization object. -
Method Summary
Modifier and TypeMethodDescriptionprivate doubleentropyFunction(double[] p) DOCUMENT ME!doubleeval(double[] x) voidfinalize()Prepares this class for destruction.intprivate voidpowell(double[] p, double[][] xi, double ftol) Minimization of entropy function of nParams variables.private voidDOCUMENT ME!private voidrun2Dm2()DOCUMENT ME!private voidrun2Dm3()DOCUMENT ME!private voidDOCUMENT ME!private voidrun3Dm2()DOCUMENT ME!private voidrun3Dm3()DOCUMENT ME!voidDOCUMENT ME!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
-
NOISE_MA2
public static final int NOISE_MA2The user can choose to use thresholding to exclude the background from any processing. Excluded pixels will have the same values as the original source image. All pixels with values below threshold that are 4 or 6 neighbor connected thru below threshold pixels to a boundary pixel which is below threshold will be excluded from processing. By default image subsampling is used in histogram formation since using 5000 images samples is sufficient to form the histogram. If subsampling is selected, pixelIncrement for both x and y is set equal to: Math.max(1,(int)Math.sqrt(histogramAvailable/5000)) If subsampling is not selected, pixelIncrement equals 1 Powell's algorithm is used to search for the values of the 10 shading parameters that minimize the entropy of the blurred histogram of the U(x,y) image. A histogram is formed to represent integers from the floor(image U minimum) to the ceiling(image U maximum). For each floating point gray value gp in U(x,y) a count of 1 is split between the 2 integer bins encompassing it. Let the bins be k and k+1. k+1-gp is added to bin k and gp - k is added to bin k+1. Gray values in locations corresponding to the image minimum or image maximum in the original input image are not used in creating this histogram, since they may represent regions where saturation effects are occurring. Then, a blurred histogram is created from the original histogram. The original histogram is blurred with a triangular window of size 5: blurredHistogram[i] = originalHistogram[i-2] + 2* originalHistogram[i-1] + 3*originalHistogram[i] + 2*originalHistogram[i+1] + originalHistogram[i+2] The blurred histogram is normalized to give probabilities by dividing the count in each bin by the total number of counts in the blurred histogram. The entropy is formed by summing the -probability(n)*log(probability(n)) over all bins n with nonzero counts. References: This software implements the algorithm discussed in: 1.) Retrospective shading correction based on entropy minimization by B. Likar, J. B. A. Maintz, M. A. Viergever, and F. Pernus, Journal of Microscopy, Vol. 197, Pt 3., March, 2000, pp. 285-295. 2.) Retrospective Correction of MR Intensity Inhomogeneity by Information Minimization by Bostjan Likar, Max Viergever, and Franjo Pernus, IEEE Transactions on Medical Imaging, Vol. 20, No. 12, December, 2001, pp. 1398-1410. 3.) Real-time automated visual inspection of color tablets in pharmaceutical blisters by Joze Derganc, Bostjan Likar, Rok Bernard, Dejan Tomazevic, and Franjo Pernus, Real-Time Imaging, Vol. 9, 2003, pp. 113-124.- See Also:
-
NOISE_M2
public static final int NOISE_M2Quadratic multiplicative noise.- See Also:
-
NOISE_M3
public static final int NOISE_M3Cubic multiplicative noise.- See Also:
-
ac1
private double ac1DOCUMENT ME! -
ac2
private double ac2DOCUMENT ME! -
ac3
private double ac3DOCUMENT ME! -
ac4
private double ac4DOCUMENT ME! -
ac5
private double ac5DOCUMENT ME! -
ac6
private double ac6DOCUMENT ME! -
ac7
private double ac7DOCUMENT ME! -
ac8
private double ac8DOCUMENT ME! -
ac9
private double ac9DOCUMENT ME! -
ad1
private double ad1DOCUMENT ME! -
ad2
private double ad2DOCUMENT ME! -
ad3
private double ad3DOCUMENT ME! -
ad4
private double ad4DOCUMENT ME! -
ad5
private double ad5DOCUMENT ME! -
ad6
private double ad6DOCUMENT ME! -
ad7
private double ad7DOCUMENT ME! -
ad8
private double ad8DOCUMENT ME! -
ad9
private double ad9DOCUMENT ME! -
area
private int areaDOCUMENT ME! -
backgroundPresent
private boolean backgroundPresentDOCUMENT ME! -
buffer
private float[] bufferDOCUMENT ME! -
grayCount
private double grayCountDOCUMENT ME! -
histogramAvailable
private int histogramAvailableNumber of pixels available for histogram formation. -
idealBuffer
private double[] idealBufferBuffer holding calculation for noiseless U(x,y). -
iter
private int iterDOCUMENT ME! -
maximum
private double maximumoriginal image maximum. -
maximumR
private double maximumRDOCUMENT ME! -
maximumG
private double maximumGDOCUMENT ME! -
maximumB
private double maximumBDOCUMENT ME! -
mc1
private double mc1DOCUMENT ME! -
mc2
private double mc2DOCUMENT ME! -
mc3
private double mc3DOCUMENT ME! -
mc4
private double mc4DOCUMENT ME! -
mc5
private double mc5DOCUMENT ME! -
mc6
private double mc6DOCUMENT ME! -
mc7
private double mc7DOCUMENT ME! -
mc8
private double mc8DOCUMENT ME! -
mc9
private double mc9DOCUMENT ME! -
mc10
private double mc10DOCUMENT ME! -
mc11
private double mc11DOCUMENT ME! -
mc12
private double mc12DOCUMENT ME! -
mc13
private double mc13DOCUMENT ME! -
mc14
private double mc14DOCUMENT ME! -
mc15
private double mc15DOCUMENT ME! -
mc16
private double mc16DOCUMENT ME! -
mc17
private double mc17DOCUMENT ME! -
mc18
private double mc18DOCUMENT ME! -
mc19
private double mc19DOCUMENT ME! -
md1
private double md1DOCUMENT ME! -
md2
private double md2DOCUMENT ME! -
md3
private double md3DOCUMENT ME! -
md4
private double md4DOCUMENT ME! -
md5
private double md5DOCUMENT ME! -
md6
private double md6DOCUMENT ME! -
md7
private double md7DOCUMENT ME! -
md8
private double md8DOCUMENT ME! -
md9
private double md9DOCUMENT ME! -
md10
private double md10DOCUMENT ME! -
md11
private double md11DOCUMENT ME! -
md12
private double md12DOCUMENT ME! -
md13
private double md13DOCUMENT ME! -
md14
private double md14DOCUMENT ME! -
md15
private double md15DOCUMENT ME! -
md16
private double md16DOCUMENT ME! -
md17
private double md17DOCUMENT ME! -
md18
private double md18DOCUMENT ME! -
md19
private double md19DOCUMENT ME! -
minimum
private double minimumoriginal image minimum. -
minimumR
private double minimumRDOCUMENT ME! -
minimumG
private double minimumGDOCUMENT ME! -
minimumB
private double minimumBDOCUMENT ME! -
noiseType
private int noiseTypeNOISE_MA2 or NOISE_M2. -
nParams
private int nParamsNumbering of shading correction parameters. -
objectBuffer
private boolean[] objectBufferDOCUMENT ME! -
pixelIncrement
private int pixelIncrementpixelIncrement is increased above 1 if subsampling. -
zPixelIncrement
private int zPixelIncrementHandle case where zDim is far less than xDim and yDim -
powellTolerance
private double powellToleranceTolerance passed to Powell's algorithm. -
sliceSize
private int sliceSizexDim * yDim. -
subsample
private boolean subsampleIf true, subsample image for histogram formation. -
thresholdLevel
private float thresholdLevelDOCUMENT ME! -
thresholdSelected
private boolean thresholdSelectedIf true don't use pixels below thresholdLevel that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel. -
validBuffer
private boolean[] validBufferTrue for source input locations not having image min or image max values. -
volSize
private int volSizeDOCUMENT ME! -
volume
private int volumeDOCUMENT ME! -
xDim
private int xDimDOCUMENT ME! -
yDim
private int yDimDOCUMENT ME! -
zDim
private int zDimDOCUMENT ME!
-
-
Constructor Details
-
AlgorithmEntropyMinimization
public AlgorithmEntropyMinimization(ModelImage srcImage, boolean thresholdSelected, float thresholdLevel, boolean subsample, int noiseType) Creates a new AlgorithmEntropyMinimization object.- Parameters:
srcImage- original imagethresholdSelected- If true, don't use pixels that are 4 or 6 neighbor connected to boundary pixels below thresholdLevelthresholdLevel- DOCUMENT ME!subsample- DOCUMENT ME!noiseType- DOCUMENT ME!
-
AlgorithmEntropyMinimization
public AlgorithmEntropyMinimization(ModelImage resultImage, ModelImage srcImage, boolean thresholdSelected, float thresholdLevel, boolean subsample, int noiseType) Creates a new AlgorithmEntropyMinimization object.- Parameters:
resultImage- entropy minimized imagesrcImage- original imagethresholdSelected- If true, don't use pixels that are 4 or 6 neighbor connected to boundary pixels below thresholdLevelthresholdLevel- DOCUMENT ME!subsample- DOCUMENT ME!noiseType- DOCUMENT ME!
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()DOCUMENT ME!- Specified by:
runAlgorithmin classAlgorithmBase
-
entropyFunction
private double entropyFunction(double[] p) DOCUMENT ME!- Parameters:
p- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
powell
private void powell(double[] p, double[][] xi, double ftol) Minimization of entropy function of nParams variables. Input consists of an initial starting point p[0...nParams-1]; an initial matrix xi[0...nParams-1][0...nParams-1], whose columns contain the initial set of directions (usually the nParams unit vectors); and ftol, the fractional tolerance in the function value such that failure to decrease by more than this amount on one iteration signals doneness. On output, p is set to the best point found, xi is the then-current direction set, fret is the returned function value at p, and iter is the number of iterations taken.- Parameters:
p- DOCUMENT ME!xi- DOCUMENT ME!ftol- DOCUMENT ME!
-
run2Da2m2
private void run2Da2m2()DOCUMENT ME! -
run2Dm2
private void run2Dm2()DOCUMENT ME! -
run2Dm3
private void run2Dm3()DOCUMENT ME! -
run3Da2m2
private void run3Da2m2()DOCUMENT ME! -
run3Dm2
private void run3Dm2()DOCUMENT ME! -
run3Dm3
private void run3Dm3()DOCUMENT ME! -
eval
public double eval(double[] x) - Specified by:
evalin interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-
getNumberOfVariables
public int getNumberOfVariables()- Specified by:
getNumberOfVariablesin interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-