Class AlgorithmLocalNormalization
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmLocalNormalization
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmLocalNormalization extends AlgorithmBase
Local Normalisation equalises colour levels among pixels by removing variations due to lighting; this brings out contrasts in detail.This is done by normalizing a surface-detail version of an image with its slowly varying local average image. That is to say, each pixel of the output image is the value at that location of the pixel of the high-frequency image divided by the pixel at that same location of the low-frequency image.
The surface-detail image is generated by using an unsharp masking algorithm, and the local average image is a low-pass image generated using a general-purpose (but fast) frequency filter.
References:
- Local Normalization. http://bigwww.epfl.ch/demo/normalize/desc.html
- Halyo, Nesim; Rahman, Zia-ur; Park, Stephen. "Information Content in Nonlinear Local Normalization Processing of Digital Images". College of William and Mary. Williamsburg, Virgiana.
- See Also:
AlgorithmUnsharpMask
,AlgorithmFrequencyFilter
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
bChannel
when true, indicates whether to process the colour channel.private AlgorithmFrequencyFilter
FFTer
the AlgorithmFrequencyFilter, to lo-pass filter the image.private float
frequency
FrequencyFilter's low-pass cut-off frequency.private boolean
gChannel
when true, indicates whether to process the colour channel.private boolean
is2d
Images that are solely 2D images set this to true; images with other dimensionality are false.private boolean
isColourImage
Colour images set this to true; monochromatic should be false;.private int
kernelDiameter
Required by the low pass filter, but is unused with these options.private float[]
norm
temporary image-data buffer to store (hi-pass)/(lo-pass) data.private boolean
rChannel
when true, indicates whether to process the colour channel.private float[]
sigmas
UnsharpMask sigmas, for blurring.private ModelImage[]
tempImage
a temporary image array.private AlgorithmUnsharpMask
unsharper
the UnsharpMask algorithm, to hi-pass filter the image.private double
weightingFactor
UnsharpMask weighting factor.-
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 AlgorithmLocalNormalization(ModelImage dest, ModelImage src, float[] sigmas, double weight, int kernSize, float freq)
This constructor initialises a Local normalisation algorithm for a source and destination image, and ensures that the destination image isModelStorageBase.FLOAT
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcInPlace()
Filters the source image.private void
calcStoreInDest()
This function produces a local-normalized image into a ModelImage that does not replace the original image-data.private float[]
doImageDivision(float[] top, float[] bot)
takes the data of the two images, one unsharp'd and the other gaussian blur'd, and divides the two pixel-by-pixel to find the locally normalized value for each pixel.void
finalize()
Prepares this class for destruction.private void
normalize()
works depending on the extent of the image and the colourisation of the source image in question.void
runAlgorithm()
Standard algorithm run method.void
setRGBChannelFilter(boolean r, boolean g, boolean b)
RGB images are local-normalized by 'channel.'-
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
-
FFTer
private AlgorithmFrequencyFilter FFTer
the AlgorithmFrequencyFilter, to lo-pass filter the image.
-
frequency
private float frequency
FrequencyFilter's low-pass cut-off frequency.
-
is2d
private boolean is2d
Images that are solely 2D images set this to true; images with other dimensionality are false.
-
isColourImage
private boolean isColourImage
Colour images set this to true; monochromatic should be false;.
-
kernelDiameter
private int kernelDiameter
Required by the low pass filter, but is unused with these options.
-
norm
private float[] norm
temporary image-data buffer to store (hi-pass)/(lo-pass) data.
-
rChannel
private boolean rChannel
when true, indicates whether to process the colour channel.
-
gChannel
private boolean gChannel
when true, indicates whether to process the colour channel.
-
bChannel
private boolean bChannel
when true, indicates whether to process the colour channel.
-
sigmas
private float[] sigmas
UnsharpMask sigmas, for blurring.
-
tempImage
private ModelImage[] tempImage
a temporary image array.
-
unsharper
private AlgorithmUnsharpMask unsharper
the UnsharpMask algorithm, to hi-pass filter the image.
-
weightingFactor
private double weightingFactor
UnsharpMask weighting factor.
-
-
Constructor Detail
-
AlgorithmLocalNormalization
public AlgorithmLocalNormalization(ModelImage dest, ModelImage src, float[] sigmas, double weight, int kernSize, float freq)
This constructor initialises a Local normalisation algorithm for a source and destination image, and ensures that the destination image isModelStorageBase.FLOAT
.Currently (8 May 2003), this algorithm does not support replacing the original data set with that of the locally-normalized image.
- Parameters:
dest
- DOCUMENT ME!src
- DOCUMENT ME!sigmas
- DOCUMENT ME!weight
- DOCUMENT ME!kernSize
- DOCUMENT ME!freq
- DOCUMENT ME!
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Standard algorithm run method. It will not run if the source Image isnull
. The calculation is done and placed in a separate destination image if it is to be stored there.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setRGBChannelFilter
public void setRGBChannelFilter(boolean r, boolean g, boolean b)
RGB images are local-normalized by 'channel.' That is, each colour, red, blue and green, is filtered independantly of the other two colours. This filter permits selectively filtering any combination of the three channels instead of simply filtering all three. True for any of the arguments enforces filtering that channel.- Parameters:
r
- Filter red channel.g
- Filter green channel.b
- Filter blue channel.
-
calcInPlace
private void calcInPlace()
Filters the source image. Replaces the original image with the filtered image.Does not currently work.
-
calcStoreInDest
private void calcStoreInDest()
This function produces a local-normalized image into a ModelImage that does not replace the original image-data.
-
doImageDivision
private float[] doImageDivision(float[] top, float[] bot)
takes the data of the two images, one unsharp'd and the other gaussian blur'd, and divides the two pixel-by-pixel to find the locally normalized value for each pixel.- Parameters:
top
- DOCUMENT ME!bot
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
normalize
private void normalize()
works depending on the extent of the image and the colourisation of the source image in question.calls to doImageDivision(...) for as many slices (and selected colour channels) as necessary to finish off the image.
- See Also:
doImageDivision(float[], float[])
-
-