Class AlgorithmMedian
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
If any element in the kernel which does not have a corresponding element in the image, then the pixel is unfiltered. This results in a border of unfiltered pixels in the image 1/2 of the kernel-size large.
When adaptiveSize is true, the Adaptive median filter discussed in Digital Image Processing Second Edition by Rafael C. Gonzalez and Richard E. Woods in Chapter 5.3 pages 241-243 is implemented. It has 3 main purposes: 1. remove salt and pepper (impulse) noise 2. provide smoothening of other noise that may not be impulsive 3. reduce distortion such as excessive thinning or thickening of object bounderies. Depending on certain conditions, the kernel size can incresase during the filtering operation. For Adaptive Truncated Vector Median Filter for color images see "Adaptive Truncated Vector Median Filter" by Bogdan Smolka, 2011 IEEE International Conference on Computer Science and Automation Engineering, June, 2011, pp. 261-266. The truncated median filter estimates the mode. See Feature Extraction and Image Processing for Computer Vision Third Edition by Mark S. Nixon and Alberto S. Aguado, Section 3.5.2 Model filter, pp. 112 - 114. The symmetrical triangular fuzzy filter with a truncated median is used to suppress the type of noise found in historical photographs. This is characterized by fine fractures or threads in the image and by dirt that leads to a grainy appearance. See "Suppression of Noise in Historical Photographs Using a Fuzzy Truncated-Median Filter" by Michael Wirth and Bruce Bobier, Image Analysis and Recognition, Lecture Notes in Computer Science, Volume 4633, 2007, pp. 1206-1216.- Version:
- 1.0; 17 February 2000
- Author:
- David Parsons (parsonsd), Matthew J. McAuliffe, Ph.D., Paul F. Hemler, Ph.D.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int(3D only).private booleanthe blue channel.(package private) intBorder buffer number of slices.(package private) intBorder buffer number of rows.(package private) intBorder buffer number of columns.private intEither COMPONENT_FILTER, VECTOR_MAGNITUDE_FILTER, VECTOR_DIRECTION_FILTER, or ADAPTIVE_TRUNCATED_VECTOR_MEDIAN_FILTER For a vector filter the new red, green, and blue will all come from the same pixel.static final intstatic final intcross (2D only).static final int(3D only).private intUsed for 3D loop control.private floatUsed in adaptive truncated vector median filter used on color images If the changes in the RGB components are all less than a threshold delta then the color image pixels are not changed, otherwise they are replaced by the ATVMF.private booleantrue means apply to entire image, false only region.private intprivate booleanthe green channel.private int[]The kernel radius.static final inthorizontal (2D only).private booleanindicates the image is a color image.private intnumber of times to filter the image.private byte[][]mask to determine the region of pixels used in a median filter.private int[]The index of the kernel center.private float[][]The kernel.private intNumber of kernels used, more than 1 if adaptive filtering is usedprivate intuser-selectable shape of the region for neighbor-selection.private int[]dimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.).private float[][]private BitSetcontains VOI.private int[]The kernel.private intWhen adaptiveSize is true, the maximum size the kernel mask can be increased to.private intSmallest kernel size used in adaptive filteringprivate intUsed for 3D loop control.private boolean// if T, filter the red channel.private booleando all filtering slice-by-slice, rather than as a volume.static final intsquare kernel (2D only).(package private) intSource buffer number of slices.(package private) intSource buffer number of rows.(package private) intSource buffer number of columns.static final intprivate floatonly filter pixels with a value further than stdDevLimit from the mean.static final intstatic final intprivate intnumber of elements in a pixel.static final intstatic final intstatic final intvertical (2D only).static final intX-shaped kernel, from 1 corner to opposite corner.Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, 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
ConstructorsConstructorDescriptionAlgorithmMedian(ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean maskFlag) Constructor for 2D images in which changes are returned to the source image.AlgorithmMedian(ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean sliceBySlice, boolean maskFlag) Constructor for 3D images in which changes are returned to the source image.AlgorithmMedian(ModelImage destImg, ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean maskFlag) Constructor for 2D images in which changes are placed in a predetermined destination image.AlgorithmMedian(ModelImage destImg, ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean sliceBySlice, boolean maskFlag) Constructor for 3D images in which changes are placed in a predetermined destination image. -
Method Summary
Modifier and TypeMethodDescriptionprivate float[]adaptiveTruncatedVectorMedian(float r, float g, float b, float[] list) Only used with color images in vector filtering.private voidMedian filters the source image.private voidMedian filters the source image and replaces the source image with the median filtered image.private voidReplaces the original image with the Median filtered image.private voidMode filters the source image and replaces the source image with the mode filtered image.private voidThis function produces a new image that has been median filtered and places filtered image in the destination image.private voidThis function produces a new volume image that has been median filtered.private voidThis method produces a new image that has been mode filtered and places filtered image in the destination image.private voidMedian filters the source image and replaces the source image with the mode filtered image.private voidcopy2DSrcBufferToBdrBuffer(float[] srcBuffer, float[] bdrBuffer, int srcBufferOffsetIndex, int bdrBufferOffsetIndex) Method copies the data in srcBuffer centered in the border buffer That is, the src image is completely surrounded by a border.private voidcopy3DSrcBufferToBdrBuffer(float[] srcBuffer, float[] bdrBuffer) Method copies the data in srcBuffer so it is centered in the border buffer That is, the src image is completely surrounded by a border.voidfinalize()Prepares this class for destruction.private float[]getBorderBufferNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.private float[]getNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.private float[]getVectorNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.private voidForms kernel.private voidMakes the kernel mask.private floatmean(float[] list) Finds the mean value (average) in the list.private floatmedian(float[] list) Finds the median value of the list.voidStarts the algorithm.private voidsetCopyColorText(String colorText) If the progress bar is visible, sets the text to:
Copying all color values ...private voidFill in the mask for which pixels are used in filtering.voidsetRGBChannelFilter(int colorFilterType, boolean r, boolean g, boolean b, float delta) RGB images are median filtered by 'channel.'private voidsliceAdaptiveTruncatedVectorMedianFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered.private voidsliceFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered.private voidsliceFilterBorder(float[] srcBdrBuffer, float[] destBuffer, int srcBufferStartingPoint, int destBufferStartingPoint, boolean showProgress) Allows a single slice to be filtered.private voidsliceVectorDirectionFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered.private voidsliceVectorMagnitudeFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered.private floatstandardDeviation(float[] list, float average) Finds the standard deviation of the values in the input list (defined as: s = [(1/(N-1))*SUM (from 0 to N-1)[ (Xi -X )^2]]^(1/2)).private intvectorDirectionMedian(float[] list) Only used with color images in vector filtering.private intvectorMagnitudeMedian(float[] list) Only used with color images in vector filtering.private voidvolumeAdaptiveTruncatedVectorMedianColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with adaptive truncated vector median filtering.private voidvolumeColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel.private voidvolumeFilter(float[] srcBuffer, float[] destBuffer) Filter a 3D image with a 3D kernel.private voidvolumeFilterBorder(float[] srcBdrBuffer, float[] destBuffer) Method performs median filtering on a volume that has been centerend in a border buffer and places the result in the destination buffer.private voidvolumeVectorDirectionColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with vector direction filtering.private voidvolumeVectorMagnitudeColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with vector magnitude filtering.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
-
SQUARE_KERNEL
public static final int SQUARE_KERNELsquare kernel (2D only).- See Also:
-
CUBE_KERNEL
public static final int CUBE_KERNEL(3D only).- See Also:
-
CROSS_KERNEL
public static final int CROSS_KERNELcross (2D only).- See Also:
-
AXIAL_KERNEL
public static final int AXIAL_KERNEL(3D only).- See Also:
-
X_KERNEL
public static final int X_KERNELX-shaped kernel, from 1 corner to opposite corner.- See Also:
-
HORZ_KERNEL
public static final int HORZ_KERNELhorizontal (2D only).- See Also:
-
VERT_KERNEL
public static final int VERT_KERNELvertical (2D only).- See Also:
-
COMPONENT_FILTER
public static final int COMPONENT_FILTER- See Also:
-
VECTOR_MAGNITUDE_FILTER
public static final int VECTOR_MAGNITUDE_FILTER- See Also:
-
VECTOR_DIRECTION_FILTER
public static final int VECTOR_DIRECTION_FILTER- See Also:
-
ADAPTIVE_TRUNCATED_VECTOR_MEDIAN_FILTER
public static final int ADAPTIVE_TRUNCATED_VECTOR_MEDIAN_FILTER- See Also:
-
STANDARD
public static final int STANDARD- See Also:
-
ADAPTIVE_SIZE
public static final int ADAPTIVE_SIZE- See Also:
-
TRUNCATED_MEDIAN
public static final int TRUNCATED_MEDIAN- See Also:
-
SYMMETRICAL_TRIANGULAR_FUZZY_TRUNCATED_MEDIAN
public static final int SYMMETRICAL_TRIANGULAR_FUZZY_TRUNCATED_MEDIAN- See Also:
-
bdrBufferDepth
int bdrBufferDepthBorder buffer number of slices. -
bdrBufferHeight
int bdrBufferHeightBorder buffer number of rows. -
bdrBufferWidth
int bdrBufferWidthBorder buffer number of columns. -
srcBufferDepth
int srcBufferDepthSource buffer number of slices. -
srcBufferHeight
int srcBufferHeightSource buffer number of rows. -
srcBufferWidth
int srcBufferWidthSource buffer number of columns. -
bChannel
private boolean bChannelthe blue channel. -
currentSlice
private int currentSliceUsed for 3D loop control. -
entireImage
private boolean entireImagetrue means apply to entire image, false only region. -
gChannel
private boolean gChannelthe green channel. -
halfK
private int[] halfKThe kernel radius. -
isColorImage
private boolean isColorImageindicates the image is a color image. -
iterations
private int iterationsnumber of times to filter the image. -
kernel
private byte[][] kernelmask to determine the region of pixels used in a median filter. -
kernelCenter
private int[] kernelCenterThe index of the kernel center. -
kernelMask
private float[][] kernelMaskThe kernel. -
kernelVectorMask
private float[][] kernelVectorMask -
kernelShape
private int kernelShapeuser-selectable shape of the region for neighbor-selection. -
minimumSize
private int minimumSizeSmallest kernel size used in adaptive filtering -
kernelSize
private int[] kernelSizedimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.). -
filterType
private int filterType -
delta
private float deltaUsed in adaptive truncated vector median filter used on color images If the changes in the RGB components are all less than a threshold delta then the color image pixels are not changed, otherwise they are replaced by the ATVMF. -
maximumSize
private int maximumSizeWhen adaptiveSize is true, the maximum size the kernel mask can be increased to. -
kernelNumber
private int kernelNumberNumber of kernels used, more than 1 if adaptive filtering is used -
mask
contains VOI. -
maskCenter
private int[] maskCenterThe kernel. -
numberOfSlices
private int numberOfSlicesUsed for 3D loop control. -
rChannel
private boolean rChannel// if T, filter the red channel. -
sliceFiltering
private boolean sliceFilteringdo all filtering slice-by-slice, rather than as a volume. -
stdDevLimit
private float stdDevLimitonly filter pixels with a value further than stdDevLimit from the mean. -
valuesPerPixel
private int valuesPerPixelnumber of elements in a pixel. Monochrome = 1, Color = 4. (a, R, G, B) -
colorFilterType
private int colorFilterTypeEither COMPONENT_FILTER, VECTOR_MAGNITUDE_FILTER, VECTOR_DIRECTION_FILTER, or ADAPTIVE_TRUNCATED_VECTOR_MEDIAN_FILTER For a vector filter the new red, green, and blue will all come from the same pixel.
-
-
Constructor Details
-
AlgorithmMedian
public AlgorithmMedian(ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean maskFlag) Constructor for 2D images in which changes are returned to the source image.- Parameters:
srcImg- Source image model.iters- Number of interations of the median filter.kSize- Kernel size: dimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.).kShape- Kernel shape: element neighbors to include when finding the median.stdDev- Inner-bounds by which to process pixels (pixel values outside this bound will be median filtered).filterType- STANDARD, ADAPTIVE_SIZE, or TRUNCATED_MEDIANmaximumSize- If adaptiveSize is true, the maximum size the kernel mask can be increased to.maskFlag- Flag that indicates that the median filtering will be performed for the whole image if equal to true.
-
AlgorithmMedian
public AlgorithmMedian(ModelImage destImg, ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean maskFlag) Constructor for 2D images in which changes are placed in a predetermined destination image.- Parameters:
destImg- Image model where result image is stored.srcImg- Source image model.iters- Number of interations of the median filter.kSize- Kernel size: dimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.).kShape- Kernel shape: element neighbors to include when finding the median.stdDev- Inner-bounds by which to process pixels (pixel values outside this bound will be median filtered).filterType- STANDARD, ADAPTIVE_SIZE, or TRUNCATED_MEDIAN.maximumSize- If adaptiveSize is true, the maximum size the kernel mask can be increased to.maskFlag- Flag that indicates that the median filtering will be performed for the whole image if equal to true.
-
AlgorithmMedian
public AlgorithmMedian(ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean sliceBySlice, boolean maskFlag) Constructor for 3D images in which changes are returned to the source image.- Parameters:
srcImg- Source image model.iters- Number of interations of the median filter.kSize- Kernel size: dimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.).kShape- Kernel shape: element neighbors to include when finding the median.stdDev- Inner-bounds by which to process pixels (pixel values outside this bound will be median filtered).filterType- STANDARD, ADAPTIVE_SIZE, or TRUNCATED_MEDIANmaximumSize- If adaptiveSize is true, the maximum size the kernel mask can be increased to.sliceBySlice- Each slice in a volume image is to be filtered separately (when true), else the volume will use a kernel with 3 dimensions.maskFlag- Flag that indicates that the median filtering will be performed for the whole image if equal to true.
-
AlgorithmMedian
public AlgorithmMedian(ModelImage destImg, ModelImage srcImg, int iters, int kSize, int kShape, float stdDev, int filterType, int maximumSize, boolean sliceBySlice, boolean maskFlag) Constructor for 3D images in which changes are placed in a predetermined destination image.- Parameters:
destImg- Image model where result image is stored.srcImg- Source image model.iters- Number of interations of the median filter.kSize- Kernel size: dimension of the kernel (ie., 5 = 5x5, 7 = 7x7, 9 = 9x9, etc.).kShape- Kernel shape: element neighbors to include when finding the median.stdDev- Inner-bounds by which to process pixels (pixel values outside this bound will be median filtered).filterType- STANDARD, ADAPTIVE_SIZE, or TRUNCATED_MEDIANmaximumSize- If adaptiveSize is true, the maximum size the kernel mask can be increased to.sliceBySlice- Each slice in a volume image is filtered separately (when true), else the volume will use a kernel with 3 dimensions.maskFlag- Flag that indicates that the median filtering will be performed for the whole image if equal to true.
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()Starts the algorithm.- Specified by:
runAlgorithmin classAlgorithmBase
-
setRGBChannelFilter
public void setRGBChannelFilter(int colorFilterType, boolean r, boolean g, boolean b, float delta) RGB images are median filtered by 'channel.' That is, each color, red, blue and green, is filtered independently of the other two colors. This median filter permits selectively filtering any combination of the three channels instead of simply filtering all three.- Parameters:
colorFilterType- Either COMPONENT_FILTER, VECTOR_MAGNITUDE_FILTER, or VECTOR_DIRECTION_FILTERr- Filter red channel.g- Filter green channel.b- Filter blue channel.delta-
-
calcInPlace2D
private void calcInPlace2D()Median filters the source image. Replaces the original image with the filtered image. -
calcInPlace3D
private void calcInPlace3D()Median filters the source image and replaces the source image with the median filtered image. -
calcInPlaceBorder2D
private void calcInPlaceBorder2D()Replaces the original image with the Median filtered image.Make a copy of the srcImage in a buffer with borders for the kernel. Copy the closest rows and columns data into the added borders.
-
calcInPlaceBorder3D
private void calcInPlaceBorder3D()Mode filters the source image and replaces the source image with the mode filtered image. -
calcStoreInDest2D
private void calcStoreInDest2D()This function produces a new image that has been median filtered and places filtered image in the destination image. -
calcStoreInDest3D
private void calcStoreInDest3D()This function produces a new volume image that has been median filtered. Image can be filtered by filtering each slice individually, or by filtering using a kernel-volume. -
calcStoreInDestBorder2D
private void calcStoreInDestBorder2D()This method produces a new image that has been mode filtered and places filtered image in the destination image. -
calcStoreInDestBorder3D
private void calcStoreInDestBorder3D()Median filters the source image and replaces the source image with the mode filtered image. -
copy2DSrcBufferToBdrBuffer
private void copy2DSrcBufferToBdrBuffer(float[] srcBuffer, float[] bdrBuffer, int srcBufferOffsetIndex, int bdrBufferOffsetIndex) Method copies the data in srcBuffer centered in the border buffer That is, the src image is completely surrounded by a border. The values in the border locations are copies of nearby srcBuffer values.- Parameters:
srcBuffer- float [] the source image bufferbdrBuffer- float [] the border image buffersrcBufferOffsetIndex- offset into srcBufferbdrBufferOffsetIndex- offset into bdrBuffer
-
copy3DSrcBufferToBdrBuffer
private void copy3DSrcBufferToBdrBuffer(float[] srcBuffer, float[] bdrBuffer) Method copies the data in srcBuffer so it is centered in the border buffer That is, the src image is completely surrounded by a border. The values in the border locations are copies of nearby srcBuffer values.- Parameters:
srcBuffer- float [] the source image bufferbdrBuffer- float [] the border image buffer
-
getBorderBufferNeighborList
private float[] getBorderBufferNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.- Parameters:
kn- The kernel number; always 0 if adaptiveSize is falsei- The central pixel to find neighbors for.data- float [] Image datais2D- True indicates that the neighbors are found along a 2D slice (or 2D image) instead of neighbors in a 3D volume.- Returns:
- The neighboring pixel list corresponds to the kernel chosen.
-
getNeighborList
private float[] getNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.Color images are processed differently from the monochrome images because although colour images use the same size kernel as mono images, it fills the kernel with brightness levels that are spread out in the data set. The Neighbor list still reports the monochromatic brightness values. That is, for a color image: the neighbors of the central pixel with the same color are returned in the neighbor list's kernel.
- Parameters:
kn- The kernel number; always 0 if adaptiveSize is false.i- The central pixel to find neighbors for.data- float [] Image datais2D- True indicates that the neighbors are found along a 2D slice (or 2D image) instead of neighbors in a 3D volume.- Returns:
- The neighboring pixel list corresponds to the kernel chosen.
-
getVectorNeighborList
private float[] getVectorNeighborList(int kn, int i, float[] data, boolean is2D) Compiles a list of the values neighboring the desired pixel, that are defined in the kernel.Only used with color images in vector filtering. Returned float array has red, green, blue, red, green, blue, etc.
- Parameters:
kn- The kernel number; always zero if adaptiveSize is false.i- The central pixel to find neighbors for.data- float [] Image datais2D- True indicates that the neighbors are found along a 2D slice (or 2D image) instead of neighbors in a 3D volume.- Returns:
- The neighboring pixel list corresponds to the kernel chosen.
-
makeKernel
private void makeKernel()Forms kernel. -
makeKernelMask
private void makeKernelMask()Makes the kernel mask. The kernel mask is the list of values pulled from the image which will be used to find the median of the central pixel. Its length is (number of pixels to be used to determine median).Thus the kernel center (decided here), has the value of the location of the central pixel shown in the window. The value of the kernel center is the number of pixels picked up to median sort.
Note that for symmetric masks always have kernelCenter = count/2 and maskCenter = count/2.
-
mean
private float mean(float[] list) Finds the mean value (average) in the list.- Parameters:
list- float [] List of numbers- Returns:
- float The mean.
-
median
private float median(float[] list) Finds the median value of the list.- Parameters:
list- float [] List of numbers- Returns:
- The median.
-
vectorMagnitudeMedian
private int vectorMagnitudeMedian(float[] list) Only used with color images in vector filtering. Returns index of pixel whose sum of squares difference from the other pixels in the list is smallest.- Parameters:
list-- Returns:
-
vectorDirectionMedian
private int vectorDirectionMedian(float[] list) Only used with color images in vector filtering. Returns index of pixel whose sum of angles difference from the other pixels in the list is smallest.- Parameters:
list-- Returns:
-
adaptiveTruncatedVectorMedian
private float[] adaptiveTruncatedVectorMedian(float r, float g, float b, float[] list) Only used with color images in vector filtering. Returns red, green, blue in float array for adaptive truncated vector median filtering- Parameters:
r-g-b-list-- Returns:
-
setCopyColorText
If the progress bar is visible, sets the text to:
Copying all color values ...- Parameters:
colorText- The color to use. Eg., "red" or "blue".
-
setKernel
private void setKernel()Fill in the mask for which pixels are used in filtering. -
sliceFilter
private void sliceFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered. Note that a progressBar must be created first.- Parameters:
srcBuffer- float [] Source buffer.destBuffer- float[] Destination Buffer.bufferStartingPoint- Starting point for the buffer.msgString- A text message that can be displayed as a message text in the progressBar.
-
sliceVectorMagnitudeFilter
private void sliceVectorMagnitudeFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered. Note that a progressBar must be created first. Only used on color with vector magnitude filtering. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source buffer.destBuffer- float[] Destination Buffer.bufferStartingPoint- Starting point for the buffer.msgString- A text message that can be displayed as a message text in the progressBar.
-
sliceVectorDirectionFilter
private void sliceVectorDirectionFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered. Note that a progressBar must be created first. Only used on color with vector direction filtering. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source buffer.destBuffer- float[] Destination Buffer.bufferStartingPoint- Starting point for the buffer.msgString- A text message that can be displayed as a message text in the progressBar.
-
sliceAdaptiveTruncatedVectorMedianFilter
private void sliceAdaptiveTruncatedVectorMedianFilter(float[] srcBuffer, float[] destBuffer, int bufferStartingPoint, String msgString) Allows a single slice to be filtered. Note that a progressBar must be created first. Only used on color with adaptive truncated vector median filtering. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source buffer.destBuffer- float[] Destination Buffer.bufferStartingPoint- Starting point for the buffer.msgString- A text message that can be displayed as a message text in the progressBar.
-
sliceFilterBorder
private void sliceFilterBorder(float[] srcBdrBuffer, float[] destBuffer, int srcBufferStartingPoint, int destBufferStartingPoint, boolean showProgress) Allows a single slice to be filtered. Note that a progressBar must be created first.- Parameters:
srcBdrBuffer- float[] Source buffer.destBuffer- float[] Destination Buffer.srcBufferStartingPoint- Starting point for the buffer.destBufferStartingPoint- Starting point for the buffer.
-
standardDeviation
private float standardDeviation(float[] list, float average) Finds the standard deviation of the values in the input list (defined as: s = [(1/(N-1))*SUM (from 0 to N-1)[ (Xi -X )^2]]^(1/2)).- Parameters:
list- float [] The list of numbers.average- Arithmetic mean of the values in list.- Returns:
- The standard deviation.
-
volumeColorFilter
private void volumeColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel. Allows median filtering to include the picture elements at greater depths than only the current slice. This method allows selected band filtering, and does not filter the alpha band.- Parameters:
srcBuffer- float [] Source image.destBuffer- float [] Destination image.- See Also:
-
volumeVectorMagnitudeColorFilter
private void volumeVectorMagnitudeColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with vector magnitude filtering. Allows median filtering to include the picture elements at greater depths than only the current slice. This method does not filter the alpha band. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source image.destBuffer- float [] Destination image.- See Also:
-
volumeVectorDirectionColorFilter
private void volumeVectorDirectionColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with vector direction filtering. Allows median filtering to include the picture elements at greater depths than only the current slice. This method does not filter the alpha band. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source image.destBuffer- float [] Destination image.- See Also:
-
volumeAdaptiveTruncatedVectorMedianColorFilter
private void volumeAdaptiveTruncatedVectorMedianColorFilter(float[] srcBuffer, float[] destBuffer) Filter a Color 3D image with a 3D kernel with adaptive truncated vector median filtering. Allows median filtering to include the picture elements at greater depths than only the current slice. This method does not filter the alpha band. Red, green, and blue are all filtered together; that is, the new red, green, and blue will all come from the same pixel.- Parameters:
srcBuffer- float [] Source image.destBuffer- float [] Destination image.- See Also:
-
volumeFilter
private void volumeFilter(float[] srcBuffer, float[] destBuffer) Filter a 3D image with a 3D kernel. Allows median filtering to include the picture elements at greater depths than only the current slice.Note that this volume filter will correctly filter color images on all bands (aRGB) because the neighbor list is correct (see getNeighborList()). This means, however, it will not selectivly filter any bands (one may not filter only the Red channel, for instance), and will also filter all alpha values as well. Of course, progress bar updates will not include any color information. For these reasons it a useable, but limited color filter.
- Parameters:
srcBuffer- float[] Source image.destBuffer- float [] Destination image.
-
volumeFilterBorder
private void volumeFilterBorder(float[] srcBdrBuffer, float[] destBuffer) Method performs median filtering on a volume that has been centerend in a border buffer and places the result in the destination buffer.- Parameters:
srcBdrBuffer- float[]destBuffer- float[]
-