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,java.awt.event.ActionListener,java.awt.event.WindowListener,java.lang.Runnable,java.util.EventListener
public class AlgorithmEntropyMinimization extends AlgorithmBase implements de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
DOCUMENT ME!
-
-
Field Summary
Fields Modifier and Type Field Description private doubleac1DOCUMENT ME!private doubleac2DOCUMENT ME!private doubleac3DOCUMENT ME!private doubleac4DOCUMENT ME!private doubleac5DOCUMENT ME!private doubleac6DOCUMENT ME!private doubleac7DOCUMENT ME!private doubleac8DOCUMENT ME!private doubleac9DOCUMENT ME!private doublead1DOCUMENT ME!private doublead2DOCUMENT ME!private doublead3DOCUMENT ME!private doublead4DOCUMENT ME!private doublead5DOCUMENT ME!private doublead6DOCUMENT ME!private doublead7DOCUMENT ME!private doublead8DOCUMENT ME!private doublead9DOCUMENT ME!private intareaDOCUMENT ME!private booleanbackgroundPresentDOCUMENT ME!private float[]bufferDOCUMENT ME!private doublegrayCountDOCUMENT ME!private inthistogramAvailableNumber of pixels available for histogram formation.private double[]idealBufferBuffer holding calculation for noiseless U(x,y).private intiterDOCUMENT ME!private doublemaximumoriginal image maximum.private doublemaximumBDOCUMENT ME!private doublemaximumGDOCUMENT ME!private doublemaximumRDOCUMENT ME!private doublemc1DOCUMENT ME!private doublemc10DOCUMENT ME!private doublemc11DOCUMENT ME!private doublemc12DOCUMENT ME!private doublemc13DOCUMENT ME!private doublemc14DOCUMENT ME!private doublemc15DOCUMENT ME!private doublemc16DOCUMENT ME!private doublemc17DOCUMENT ME!private doublemc18DOCUMENT ME!private doublemc19DOCUMENT ME!private doublemc2DOCUMENT ME!private doublemc3DOCUMENT ME!private doublemc4DOCUMENT ME!private doublemc5DOCUMENT ME!private doublemc6DOCUMENT ME!private doublemc7DOCUMENT ME!private doublemc8DOCUMENT ME!private doublemc9DOCUMENT ME!private doublemd1DOCUMENT ME!private doublemd10DOCUMENT ME!private doublemd11DOCUMENT ME!private doublemd12DOCUMENT ME!private doublemd13DOCUMENT ME!private doublemd14DOCUMENT ME!private doublemd15DOCUMENT ME!private doublemd16DOCUMENT ME!private doublemd17DOCUMENT ME!private doublemd18DOCUMENT ME!private doublemd19DOCUMENT ME!private doublemd2DOCUMENT ME!private doublemd3DOCUMENT ME!private doublemd4DOCUMENT ME!private doublemd5DOCUMENT ME!private doublemd6DOCUMENT ME!private doublemd7DOCUMENT ME!private doublemd8DOCUMENT ME!private doublemd9DOCUMENT ME!private doubleminimumoriginal image minimum.private doubleminimumBDOCUMENT ME!private doubleminimumGDOCUMENT ME!private doubleminimumRDOCUMENT ME!static intNOISE_M2Quadratic multiplicative noise.static intNOISE_M3Cubic multiplicative noise.static intNOISE_MA2The user can choose to use thresholding to exclude the background from any processing.private intnoiseTypeNOISE_MA2 or NOISE_M2.private intnParamsNumbering of shading correction parameters.private boolean[]objectBufferDOCUMENT ME!private intpixelIncrementpixelIncrement is increased above 1 if subsampling.private doublepowellToleranceTolerance passed to Powell's algorithm.private intsliceSizexDim * yDim.private booleansubsampleIf true, subsample image for histogram formation.private floatthresholdLevelDOCUMENT ME!private booleanthresholdSelectedIf true don't use pixels below thresholdLevel that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel.private boolean[]validBufferTrue for source input locations not having image min or image max values.private intvolSizeDOCUMENT ME!private intvolumeDOCUMENT ME!private intxDimDOCUMENT ME!private intyDimDOCUMENT ME!private intzDimDOCUMENT ME!private intzPixelIncrementHandle case where zDim is far less than xDim and yDim-
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 AlgorithmEntropyMinimization(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private doubleentropyFunction(double[] p)DOCUMENT ME!doubleeval(double[] x)voidfinalize()Prepares this class for destruction.intgetNumberOfVariables()private voidpowell(double[] p, double[][] xi, double ftol)Minimization of entropy function of nParams variables.private voidrun2Da2m2()DOCUMENT ME!private voidrun2Dm2()DOCUMENT ME!private voidrun2Dm3()DOCUMENT ME!private voidrun3Da2m2()DOCUMENT ME!private voidrun3Dm2()DOCUMENT ME!private voidrun3Dm3()DOCUMENT ME!voidrunAlgorithm()DOCUMENT 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, 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
-
-
-
-
Field Detail
-
NOISE_MA2
public static final int NOISE_MA2
The 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:
- Constant Field Values
-
NOISE_M2
public static final int NOISE_M2
Quadratic multiplicative noise.- See Also:
- Constant Field Values
-
NOISE_M3
public static final int NOISE_M3
Cubic multiplicative noise.- See Also:
- Constant Field Values
-
ac1
private double ac1
DOCUMENT ME!
-
ac2
private double ac2
DOCUMENT ME!
-
ac3
private double ac3
DOCUMENT ME!
-
ac4
private double ac4
DOCUMENT ME!
-
ac5
private double ac5
DOCUMENT ME!
-
ac6
private double ac6
DOCUMENT ME!
-
ac7
private double ac7
DOCUMENT ME!
-
ac8
private double ac8
DOCUMENT ME!
-
ac9
private double ac9
DOCUMENT ME!
-
ad1
private double ad1
DOCUMENT ME!
-
ad2
private double ad2
DOCUMENT ME!
-
ad3
private double ad3
DOCUMENT ME!
-
ad4
private double ad4
DOCUMENT ME!
-
ad5
private double ad5
DOCUMENT ME!
-
ad6
private double ad6
DOCUMENT ME!
-
ad7
private double ad7
DOCUMENT ME!
-
ad8
private double ad8
DOCUMENT ME!
-
ad9
private double ad9
DOCUMENT ME!
-
area
private int area
DOCUMENT ME!
-
backgroundPresent
private boolean backgroundPresent
DOCUMENT ME!
-
buffer
private float[] buffer
DOCUMENT ME!
-
grayCount
private double grayCount
DOCUMENT ME!
-
histogramAvailable
private int histogramAvailable
Number of pixels available for histogram formation.
-
idealBuffer
private double[] idealBuffer
Buffer holding calculation for noiseless U(x,y).
-
iter
private int iter
DOCUMENT ME!
-
maximum
private double maximum
original image maximum.
-
maximumR
private double maximumR
DOCUMENT ME!
-
maximumG
private double maximumG
DOCUMENT ME!
-
maximumB
private double maximumB
DOCUMENT ME!
-
mc1
private double mc1
DOCUMENT ME!
-
mc2
private double mc2
DOCUMENT ME!
-
mc3
private double mc3
DOCUMENT ME!
-
mc4
private double mc4
DOCUMENT ME!
-
mc5
private double mc5
DOCUMENT ME!
-
mc6
private double mc6
DOCUMENT ME!
-
mc7
private double mc7
DOCUMENT ME!
-
mc8
private double mc8
DOCUMENT ME!
-
mc9
private double mc9
DOCUMENT ME!
-
mc10
private double mc10
DOCUMENT ME!
-
mc11
private double mc11
DOCUMENT ME!
-
mc12
private double mc12
DOCUMENT ME!
-
mc13
private double mc13
DOCUMENT ME!
-
mc14
private double mc14
DOCUMENT ME!
-
mc15
private double mc15
DOCUMENT ME!
-
mc16
private double mc16
DOCUMENT ME!
-
mc17
private double mc17
DOCUMENT ME!
-
mc18
private double mc18
DOCUMENT ME!
-
mc19
private double mc19
DOCUMENT ME!
-
md1
private double md1
DOCUMENT ME!
-
md2
private double md2
DOCUMENT ME!
-
md3
private double md3
DOCUMENT ME!
-
md4
private double md4
DOCUMENT ME!
-
md5
private double md5
DOCUMENT ME!
-
md6
private double md6
DOCUMENT ME!
-
md7
private double md7
DOCUMENT ME!
-
md8
private double md8
DOCUMENT ME!
-
md9
private double md9
DOCUMENT ME!
-
md10
private double md10
DOCUMENT ME!
-
md11
private double md11
DOCUMENT ME!
-
md12
private double md12
DOCUMENT ME!
-
md13
private double md13
DOCUMENT ME!
-
md14
private double md14
DOCUMENT ME!
-
md15
private double md15
DOCUMENT ME!
-
md16
private double md16
DOCUMENT ME!
-
md17
private double md17
DOCUMENT ME!
-
md18
private double md18
DOCUMENT ME!
-
md19
private double md19
DOCUMENT ME!
-
minimum
private double minimum
original image minimum.
-
minimumR
private double minimumR
DOCUMENT ME!
-
minimumG
private double minimumG
DOCUMENT ME!
-
minimumB
private double minimumB
DOCUMENT ME!
-
noiseType
private int noiseType
NOISE_MA2 or NOISE_M2.
-
nParams
private int nParams
Numbering of shading correction parameters.
-
objectBuffer
private boolean[] objectBuffer
DOCUMENT ME!
-
pixelIncrement
private int pixelIncrement
pixelIncrement is increased above 1 if subsampling.
-
zPixelIncrement
private int zPixelIncrement
Handle case where zDim is far less than xDim and yDim
-
powellTolerance
private double powellTolerance
Tolerance passed to Powell's algorithm.
-
sliceSize
private int sliceSize
xDim * yDim.
-
subsample
private boolean subsample
If true, subsample image for histogram formation.
-
thresholdLevel
private float thresholdLevel
DOCUMENT ME!
-
thresholdSelected
private boolean thresholdSelected
If true don't use pixels below thresholdLevel that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel.
-
validBuffer
private boolean[] validBuffer
True for source input locations not having image min or image max values.
-
volSize
private int volSize
DOCUMENT ME!
-
volume
private int volume
DOCUMENT ME!
-
xDim
private int xDim
DOCUMENT ME!
-
yDim
private int yDim
DOCUMENT ME!
-
zDim
private int zDim
DOCUMENT ME!
-
-
Constructor Detail
-
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 Detail
-
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
-
-