Java Code Examples for ij.gui.GenericDialog#addPreviewCheckbox()

The following examples show how to use ij.gui.GenericDialog#addPreviewCheckbox() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetLabelMapPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
public GenericDialog showDialog()
{

	// Create a new generic dialog with appropriate options
	GenericDialog gd = new GenericDialog("Set Label Map");
	gd.addChoice("Colormap", CommonLabelMaps.getAllLabels(), CommonLabelMaps.GOLDEN_ANGLE.getLabel());
	gd.addChoice("Background", CommonColors.getAllLabels(), CommonColors.WHITE.toString());
	gd.addCheckbox("Shuffle", true);

	gd.addPreviewCheckbox(null);
	gd.addDialogListener(this);
	parseDialogParameters(gd);
	gd.showDialog();

	return gd;
}
 
Example 2
Source File: GrayscaleAreaOpeningPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Gray Scale Area Opening");

	gd.addNumericField("Pixel Number", 100, 0, 10, "pixels");
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled())
       	return DONE;
		
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 3
Source File: GrayscaleBoxDiameterOpeningPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Gray Scale Box Diagonal Opening");

	gd.addNumericField("Diagonal Min.", 100, 0, 10, "pixels");
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled())
       	return DONE;
		
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 4
Source File: AreaOpeningPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Area Opening");

	gd.addNumericField("Pixel Number", 100, 0, 10, "pixels");
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled())
       	return DONE;
		
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 5
Source File: ShenCastan.java    From Scripts with GNU General Public License v3.0 6 votes vote down vote up
/** Displays the dialog prompt. */
@Override
public int showDialog(final ImagePlus imp, final String command, final PlugInFilterRunner pfr) {
	this.pfr = pfr;

	final String msg = "<html><div WIDTH=350>"
			+ "<a href='https://github.com/tferr/Scripts/blob/master/Segmentation/README.md#shen-castan-edge-detector'>"
			+ "Shen-Castan</a> filtering is an edge detection technique. It is an alternative "
			+ "to other popular approaches such as "
			+ "<a href='http://en.wikipedia.org/wiki/Canny_edge_detector'>Canny</a>-"
			+ "<a href='http://en.wikipedia.org/wiki/Deriche_edge_detector'>Deriche</a> filtering.</p>"
			+ "<p>The Shen-Castan coefficient corresponds to a smooting factor <i>alpha</i>. "
			+ "<i>Alpha</i> can vary between 0 (high smoothing, suitable for noisy images) "
			+ "and 1 (no smoothing, suitable for non-noisy images).</p></div></html>";

	final GenericDialog gd = new GenericDialog(command);
	gd.addSlider("Coefficient:", 0.0001d, 1.0001d, f);
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
	gd.addHelp(msg);
	gd.showDialog();
	if (gd.wasCanceled() || !dialogItemChanged(gd, null)) // read parameters
		return DONE;
	return IJ.setupDialog(imp, flags);
}
 
Example 6
Source File: BinaryOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public int showDialog (ImagePlus imp, String command, PlugInFilterRunner pfr) {
	if (doOptions) {
		this.imp = imp;
		this.pfr = pfr;
		GenericDialog gd = new GenericDialog("Binary Options");
		gd.addNumericField("Iterations (1-"+MAX_ITERATIONS+"):", iterations, 0, 3, "");
		gd.addNumericField("Count (1-8):", count, 0, 3, "");
		gd.addCheckbox("Black background", Prefs.blackBackground);
		gd.addCheckbox("Pad edges when eroding", Prefs.padEdges);
		gd.addChoice("EDM output:", outputTypes, outputTypes[EDM.getOutputType()]);
		if (imp != null) {
			gd.addChoice("Do:", operations, operation);
			gd.addPreviewCheckbox(pfr);
			gd.addDialogListener(this);
			previewing = true;
		}
		gd.addHelp(IJ.URL+"/docs/menus/process.html#options");
		gd.showDialog();
		previewing = false;
		if (gd.wasCanceled()) return DONE;
		if (imp==null) {                 //options dialog only, no do/preview
			dialogItemChanged(gd, null); //read dialog result
			return DONE;
		}
		return operation.equals(NO_OPERATION) ? DONE : IJ.setupDialog(imp, flags);
	} else {   //no dialog, 'arg' is operation type
		if (!imp.getProcessor().isBinary()) {
			IJ.error("8-bit binary (black and white only) image required.");
			return DONE;
		}
		return IJ.setupDialog(imp, flags);
	}
}
 
Example 7
Source File: ChamferDistanceMapPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) 
  {
  	// Store user data
  	this.imagePlus = imp;
  	this.baseImage = imp.getProcessor().duplicate();
  	this.pfr = pfr;

  	// Create a new generic dialog with appropriate options
  	GenericDialog gd = new GenericDialog("Chamfer Distance Map");
  	gd.addChoice("Distances", ChamferWeights.getAllLabels(), 
  			ChamferWeights.BORGEFORS.toString());			
  	String[] outputTypes = new String[]{"32 bits", "16 bits"};
  	gd.addChoice("Output Type", outputTypes, outputTypes[0]);
  	gd.addCheckbox("Normalize weights", true);	
  	gd.addPreviewCheckbox(pfr);
  	gd.addDialogListener(this);
      previewing = true;
gd.addHelp("https://imagej.net/MorphoLibJ");
      gd.showDialog();
      previewing = false;
      
  	// test cancel  
  	if (gd.wasCanceled())
  		return DONE;

  	// set up current parameters
  	String weightLabel = gd.getNextChoice();
  	floatProcessing = gd.getNextChoiceIndex() == 0;
  	normalize = gd.getNextBoolean();

  	// identify which weights should be used
  	weights = ChamferWeights.fromLabel(weightLabel);

  	return flags;
  }
 
Example 8
Source File: GrayscaleAttributeFilteringPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Gray Scale Attribute Filtering");

	gd.addChoice("Operation", Operation.getAllLabels(), Operation.OPENING.label);
	gd.addChoice("Attribute", Attribute.getAllLabels(), Attribute.AREA.label);
	gd.addNumericField("Minimum Value", 100, 0, 10, "pixels");
	gd.addChoice("Connectivity", connectivityLabels, connectivityLabels[0]);
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
	gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled())
       {
       	resetPreview();
       	return DONE;
       }	
       parseDialogParameters(gd);

       // clean up an return
	gd.dispose();
	return flags;
}
 
Example 9
Source File: MorphologicalFilterPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
{
	// Normal setup
   	this.imagePlus = imp;
   	this.baseImage = imp.getProcessor().duplicate();

	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Morphological Filters");
	
	gd.addChoice("Operation", Operation.getAllLabels(), 
			this.op.toString());
	gd.addChoice("Element", Strel.Shape.getAllLabels(), 
			this.shape.toString());
	gd.addNumericField("Radius (in pixels)", this.radius, 0);
	gd.addCheckbox("Show Element", false);
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
	gd.addHelp("http://imagej.net/MorphoLibJ#Morphological_filters");
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled()) 
       {
       	resetPreview();
       	return DONE;
       }	
       
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 10
Source File: RegionalMinAndMaxPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
	// Normal setup
   	this.imagePlus = imp;
   	this.baseImage = imp.getProcessor().duplicate();

	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Regional Min & Max");
	
	gd.addChoice("Operation", Operation.getAllLabels(), 
			Operation.REGIONAL_MINIMA.label);
	gd.addChoice("Connectivity", connectivityLabels, connectivityLabels[0]);
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
       gd.addHelp("https://imagej.net/MorphoLibJ");
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled())
       	return DONE;
		
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 11
Source File: ExtendedMinAndMaxPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
	// Normal setup
   	this.imagePlus = imp;
   	this.baseImage = imp.getProcessor().duplicate();

	// Create the configuration dialog
	GenericDialog gd = new GenericDialog("Extended Min & Max");
	
	gd.addChoice("Operation", Operation.getAllLabels(), Operation.EXTENDED_MINIMA.label);
	boolean isGray8 = (this.baseImage instanceof ByteProcessor);
	double minValue = isGray8 ? 1 : this.baseImage.getMin();
	double maxValue = isGray8 ? 255 : this.baseImage.getMax();
	gd.addSlider("Dynamic", minValue, maxValue, 10);
	gd.addChoice("Connectivity", connectivityLabels, connectivityLabels[0]);
	
	gd.addPreviewCheckbox(pfr);
	gd.addDialogListener(this);
       previewing = true;
       gd.addHelp("https://imagej.net/MorphoLibJ");
       gd.showDialog();
       previewing = false;
       
       if (gd.wasCanceled()) {
		return DONE;
       }
       
   	parseDialogParameters(gd);
		
	// clean up an return 
	gd.dispose();
	return flags;
}
 
Example 12
Source File: DirectionalFilteringPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr)
	{
		// Normal setup
    	this.imagePlus = imp;
    	this.baseImage = imp.getProcessor().duplicate();

		// Create the configuration dialog
		GenericDialog gd = new GenericDialog("Directional Filtering");
		
		gd.addChoice("Type", Type.getAllLabels(), this.type.toString());
		gd.addChoice("Operation", Operation.getAllLabels(), this.op.toString());
		gd.addNumericField("Line Length", this.lineLength, 0, 8, "pixels");
		gd.addNumericField("Direction Number", this.nDirections, 0);
		
		gd.addPreviewCheckbox(pfr);
		gd.addDialogListener(this);
        previewing = true;
//		gd.addHelp("http://imagejdocu.tudor.lu/doku.php?id=plugin:morphology:fast_morphological_filters:start");
        gd.showDialog();
        previewing = false;
        
        if (gd.wasCanceled()) 
        {
			return DONE;
        }
        
    	parseDialogParameters(gd);
			
		// clean up an return 
		gd.dispose();
		return flags;
	}
 
Example 13
Source File: RankFiltersOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
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;
				lastWhichOutliers = whichOutliers;
			}
		}
	}
	this.pfr = pfr;
	flags = IJ.setupDialog(imp, flags); //ask whether to process all slices of stack (if a stack)
	if ((flags&DOES_STACKS)!=0) {
		int size = imp.getWidth() * imp.getHeight();
		Roi roi = imp.getRoi();
		if (roi != null) {
			Rectangle roiRect = roi.getBounds();
			size = roiRect.width * roiRect.height;
		}
		double workToDo = size*(double)radius;	//estimate computing time (arb. units)
		if (filterType==MEAN || filterType==VARIANCE) workToDo *= 0.5;
		else if (filterType==MEDIAN) workToDo *= radius*0.5;
		if (workToDo < 1e6 && imp.getImageStackSize()>=numThreads) {
			numThreads = 1;				//for fast operations, avoid overhead of multi-threading in each image
			flags |= PARALLELIZE_STACKS;
		}
	}
	return flags;
}
 
Example 14
Source File: DistanceTransformWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int showDialog(
		ImagePlus imp,
		String command,
		PlugInFilterRunner pfr )
{
	if( !BinaryImages.isBinaryImage( imp ) )
	{
		IJ.error( "Distance Transform Watershed", "Input image is not"
				+ " binary (8-bit with only 0 or 255 values)" );
		return DONE;
	}
	// Store user data
	this.imagePlus = imp;
	this.baseImage = imp.getProcessor().duplicate();
	this.pfr = pfr;

	// Create a new generic dialog with appropriate options
	GenericDialog gd = new GenericDialog( "Distance Transform Watershed" );
	gd.setInsets( 0, 0, 0 );
	gd.addMessage( "Distance map options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addChoice( "Distances", ChamferWeights.getAllLabels(), weightLabel );
	String[] outputTypes = new String[]{"32 bits", "16 bits"};
	gd.addChoice( "Output Type", outputTypes, outputTypes[ floatProcessing ? 0:1 ]);
	gd.setInsets( 0, 0, 0 );
	gd.addCheckbox( "Normalize weights", normalize );
	gd.setInsets( 20, 0, 0 );
	gd.addMessage( "Watershed options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addNumericField( "Dynamic", dynamic, 2 );
	gd.addChoice( "Connectivity", Conn2D.getAllLabels(), connLabel );
	gd.setInsets( 20, 0, 0 );
	gd.addPreviewCheckbox( pfr );
	gd.addDialogListener(this);
	previewing = true;
	gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" );
	gd.showDialog();
	previewing = false;

	// test cancel
	if (gd.wasCanceled())
		return DONE;

	// set up current parameters
	weightLabel = gd.getNextChoice();
	floatProcessing = gd.getNextChoiceIndex() == 0;
	normalize = gd.getNextBoolean();
	dynamic = (int) gd.getNextNumber();
	connLabel = gd.getNextChoice();
	connectivity = Conn2D.fromLabel( connLabel ).getValue();

	// identify which weights should be used
	weights = ChamferWeights.fromLabel( weightLabel );

	return flags;
}