public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
if (filterType == DESPECKLE) {
filterType = MEDIAN;
radius = 1.0;
} else {
GenericDialog gd = new GenericDialog(command+"...");
radius = lastRadius[filterType]<=0 ? 2 : lastRadius[filterType];
gd.addNumericField("Radius", radius, 1, 6, "pixels");
int digits = imp.getType() == ImagePlus.GRAY32 ? 2 : 0;
if (filterType==OUTLIERS) {
gd.addNumericField("Threshold", lastThreshold, digits);
gd.addChoice("Which outliers", outlierStrings, outlierStrings[lastWhichOutliers]);
gd.addHelp(IJ.URL+"/docs/menus/process.html#outliers");
} else if (filterType==REMOVE_NAN)
gd.addHelp(IJ.URL+"/docs/menus/process.html#nans");
gd.addPreviewCheckbox(pfr); //passing pfr makes the filter ready for preview
gd.addDialogListener(this); //the DialogItemChanged method will be called on user input
gd.showDialog(); //display the dialog; preview runs in the now
if (gd.wasCanceled()) return DONE;
IJ.register(this.getClass()); //protect static class variables (filter parameters) from garbage collection
if (Macro.getOptions() == null) { //interactive only: remember parameters entered
lastRadius[filterType] = radius;
if (filterType == OUTLIERS) {
lastThreshold = threshold;