Class 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 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
      • 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 image
        thresholdSelected - If true, don't use pixels that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel
        thresholdLevel - 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 image
        srcImage - original image
        thresholdSelected - If true, don't use pixels that are 4 or 6 neighbor connected to boundary pixels below thresholdLevel
        thresholdLevel - DOCUMENT ME!
        subsample - DOCUMENT ME!
        noiseType - DOCUMENT ME!
    • Method Detail

      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • 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:
        eval in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
      • getNumberOfVariables

        public int getNumberOfVariables()
        Specified by:
        getNumberOfVariables in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables