public class GaussianBlur extends Object implements ExtendedPlugInFilter, DialogListener
KEEP_PREVIEW
CONVERT_TO_FLOAT, DOES_16, DOES_32, DOES_8C, DOES_8G, DOES_ALL, DOES_RGB, DOES_STACKS, DONE, FINAL_PROCESSING, KEEP_THRESHOLD, NO_CHANGES, NO_IMAGE_REQUIRED, NO_UNDO, NO_UNDO_RESET, PARALLELIZE_IMAGES, PARALLELIZE_STACKS, ROI_REQUIRED, SNAPSHOT, STACK_REQUIRED, SUPPORTS_MASKING
Constructor and Description |
---|
GaussianBlur() |
Modifier and Type | Method and Description |
---|---|
boolean |
blur(ImageProcessor ip,
double radius)
Deprecated.
|
void |
blur1Direction(FloatProcessor ip,
double sigma,
double accuracy,
boolean xDirection,
int extraLines)
Blur an image in one direction (x or y) by a Gaussian, using multiple threads on multiprocessor machines
|
void |
blurFloat(FloatProcessor ip,
double sigmaX,
double sigmaY,
double accuracy)
Gaussian Filtering of a FloatProcessor.
|
void |
blurGaussian(ImageProcessor ip,
double sigma)
Gaussian Filtering of an ImageProcessor
|
void |
blurGaussian(ImageProcessor ip,
double sigmaX,
double sigmaY,
double accuracy)
Gaussian Filtering of an ImageProcessor
|
boolean |
dialogItemChanged(GenericDialog gd,
AWTEvent e)
Listener to modifications of the input fields of the dialog
|
float[][] |
makeGaussianKernel(double sigma,
double accuracy,
int maxRadius)
Create a 1-dimensional normalized Gaussian kernel with standard deviation sigma
and the running sum over the kernel
Note: this is one side of the kernel only, not the full kernel as used by the
Convolver class of ImageJ.
|
static void |
resetOutOfRoi(ImageProcessor ip,
int radius)
Set the processed pixels above and below the roi rectangle back to their
previous value (i.e., snapshot buffer).
|
void |
run(ImageProcessor ip)
This method is invoked for each slice during execution
|
void |
setNPasses(int nPasses)
Set the number of passes of the blur1Direction method.
|
int |
setup(String arg,
ImagePlus imp)
Method to return types supported
|
int |
showDialog(ImagePlus imp,
String command,
PlugInFilterRunner pfr)
Ask the user for the parameters
|
void |
showProgress(boolean showProgressBar) |
public int setup(String arg, ImagePlus imp)
setup
in interface PlugInFilter
arg
- unusedimp
- The ImagePlus, used to get the spatial calibrationpublic int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
showDialog
in interface ExtendedPlugInFilter
imp
- The active image already passed in the
setup(arg, imp)
call. It will be null, however, if
the NO_IMAGE_REQUIRED
flag has been set.command
- The command that has led to the invocation of
the plugin-filter. Useful as a title for the dialog.pfr
- The PlugInFilterRunner calling this plugin-filter.
It can be passed to a GenericDialog by addPreviewCheckbox
to enable preview by calling the run(ip)
method of this
plugin-filter. pfr
can be also used later for calling back
the PlugInFilterRunner, e.g., to obtain the slice number
currently processed by run(ip)
.PlugInFilter
and
ExtendedPlugInFilter
.public boolean dialogItemChanged(GenericDialog gd, AWTEvent e)
dialogItemChanged
in interface DialogListener
gd
- A reference to the GenericDialog.e
- The event that has been generated by the user action in the dialog.
Note that e
is null
if the
dialogItemChanged method is called after the user has pressed the
OK button or if the GenericDialog has read its parameters from a
macro.public void setNPasses(int nPasses)
setNPasses
in interface ExtendedPlugInFilter
public void run(ImageProcessor ip)
run
in interface PlugInFilter
ip
- The image subject to filtering. It must have a valid snapshot if
the height of the roi is less than the full image height.@Deprecated public boolean blur(ImageProcessor ip, double radius)
public void blurGaussian(ImageProcessor ip, double sigma)
ip
- The ImageProcessor to be filtered.sigma
- Standard deviation of the Gaussian (pixels)ImageProcessor.blurGaussian(double)
public void blurGaussian(ImageProcessor ip, double sigmaX, double sigmaY, double accuracy)
ip
- The ImageProcessor to be filtered.sigmaX
- Standard deviation of the Gaussian in x direction (pixels)sigmaY
- Standard deviation of the Gaussian in y direction (pixels)accuracy
- Accuracy of kernel, should not be above 0.02. Better (lower)
accuracy needs slightly more computing time.public void blurFloat(FloatProcessor ip, double sigmaX, double sigmaY, double accuracy)
ip
- The FloatProcessor to be filtered.sigmaX
- Standard deviation of the Gaussian in x direction (pixels)sigmaY
- Standard deviation of the Gaussian in y direction (pixels)accuracy
- Accuracy of kernel, should not be above 0.02. Better (lower)
accuracy needs slightly more computing time.public void blur1Direction(FloatProcessor ip, double sigma, double accuracy, boolean xDirection, int extraLines)
ip
- The Image with the original data where also the result will be storedsigma
- Standard deviation of the Gaussianaccuracy
- Accuracy of kernel, should not be > 0.02xDirection
- True for bluring in x direction, false for y directionextraLines
- Number of lines (parallel to the blurring direction)
below and above the roi bounds that should be processed.public float[][] makeGaussianKernel(double sigma, double accuracy, int maxRadius)
sigma
- Standard deviation, i.e. radius of decay to 1/sqrt(e), in pixels.accuracy
- Relative accuracy; for best results below 0.01 when processing
8-bit images. For short or float images, values of 1e-3 to 1e-4
are better (but increase the kernel size and thereby the
processing time). Edge smoothing will fail with very poor
accuracy (above approx. 0.02)maxRadius
- Maximum radius of the kernel: Limits kernel size in case of
large sigma, should be set to image width or height. For small
values of maxRadius, the kernel returned may have a larger
radius, however.maxRadius
.public static void resetOutOfRoi(ImageProcessor ip, int radius)
ip
- The image to be processedradius
- The range above and below the roi that should be processedpublic void showProgress(boolean showProgressBar)
Copyright © 1997–2020 NIH. All rights reserved.