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

The following examples show how to use ij.gui.GenericDialog#getNextNumber() . 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: KMeans_ClusteringJ.java    From IJ-OpenCV with GNU General Public License v3.0 6 votes vote down vote up
private boolean showDialog() {

        GenericDialog gd = new GenericDialog("Number of clusters");
        gd.addNumericField("N clusters", nclusters, 0);
        //gd.addNumericField("Gaussian Kernel width:", gaussianKernelWidth, 0);

        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }

        nclusters = (int) gd.getNextNumber();
        if (nclusters < 2) {
            nclusters = 2;
        }

        return true;
    }
 
Example 2
Source File: EfficientBayesianBased.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected boolean getOSEM()
{
	if ( osemspeedupIndex == 0 )
	{
		defaultOSEMspeedup = osemSpeedUp = 1;
	}
	else if ( osemspeedupIndex == 3 )
	{
		GenericDialog gdOSEM = new GenericDialog( "OSEM options" );
		gdOSEM.addNumericField( "Additional_acceleration = ", defaultOSEMspeedup, 2 );
		gdOSEM.showDialog();
		
		if ( gdOSEM.wasCanceled() )
			return false;
		
		defaultOSEMspeedup = osemSpeedUp = gdOSEM.getNextNumber();			
	}
	
	return true;
}
 
Example 3
Source File: WhiteHatJ_.java    From IJ-OpenCV with GNU General Public License v3.0 6 votes vote down vote up
private boolean showDialog() {

        GenericDialog gd = new GenericDialog("White Hat Kernel");
        gd.addNumericField("X size", xSize, 1);
        gd.addNumericField("Y size", ySize, 1);
        //gd.addNumericField("Gaussian Kernel width:", gaussianKernelWidth, 0);

        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }

        xSize = (int) gd.getNextNumber();
        if (xSize < 1) {
            xSize = 1;
        }
        ySize = (int) gd.getNextNumber();
        if (ySize < 1) {
            ySize = 1;
        }

        return true;
    }
 
Example 4
Source File: BlackHatJ_.java    From IJ-OpenCV with GNU General Public License v3.0 6 votes vote down vote up
private boolean showDialog() {

        GenericDialog gd = new GenericDialog("Black Hat Kernel");
        gd.addNumericField("X size", xSize, 1);
        gd.addNumericField("Y size", ySize, 1);
        //gd.addNumericField("Gaussian Kernel width:", gaussianKernelWidth, 0);

        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }

        xSize = (int) gd.getNextNumber();
        if (xSize < 1) {
            xSize = 1;
        }
        ySize = (int) gd.getNextNumber();
        if (ySize < 1) {
            ySize = 1;
        }

        return true;
    }
 
Example 5
Source File: RankFiltersOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
	radius = gd.getNextNumber();
	if (filterType == OUTLIERS) {
		threshold = gd.getNextNumber();
		whichOutliers = gd.getNextChoiceIndex();
	}
	int maxRadius = (filterType==MEDIAN || filterType==OUTLIERS || filterType==REMOVE_NAN) ? 100 : 1000;
	if (gd.invalidNumber() || radius<0 || radius>maxRadius || (filterType==OUTLIERS && threshold <0))
		return false;
	return true;
}
 
Example 6
Source File: MorphologicalFilterPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void parseDialogParameters(GenericDialog gd) 
  {
// extract chosen parameters
this.op 		= Operation.fromLabel(gd.getNextChoice());
this.shape 		= Strel.Shape.fromLabel(gd.getNextChoice());
this.radius 	= (int) gd.getNextNumber();		
this.showStrel 	= gd.getNextBoolean();
this.previewing = gd.getPreviewCheckbox().getState();
  }
 
Example 7
Source File: Specify_Calibration.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static boolean queryNewCal( final ArrayList< Cal > calibrations, final Cal maxCal )
{
	final GenericDialog gd = new GenericDialog( "Define new calibration" );
	
	gd.addNumericField( "Calibration_x", maxCal.getCal()[ 0 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 0 ] );
	gd.addNumericField( "Calibration_y", maxCal.getCal()[ 1 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 1 ] );
	gd.addNumericField( "Calibration_z", maxCal.getCal()[ 2 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 2 ] );
	gd.addStringField( "Unit", maxCal.unit() );

	if ( calibrations.size() > 1 )
		gd.addMessage( "WARNING: Calibrations are not the same for all\n" +
					   "view setups! All calibrations will be overwritten\n" +
					   "for all view setups if defined here.",
					   GUIHelper.mediumstatusfont, GUIHelper.warning );

	gd.addMessage( "Note: These values will be applied to selected view\n" +
				   "setups, existing registration are not affected and\n" +
				   "will need to be recomputed if necessary.",
				   GUIHelper.mediumstatusfont );

	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return false;
	
	maxCal.getCal()[ 0 ] = gd.getNextNumber();
	maxCal.getCal()[ 1 ] = gd.getNextNumber();
	maxCal.getCal()[ 2 ] = gd.getNextNumber();
	maxCal.setUnit( gd.getNextString() );

	return true;
}
 
Example 8
Source File: GlobalOptimizationParameters.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static GlobalOptimizationParameters askUserForParameters(boolean askForGrouping)
{
	// ask user for parameters
	final GenericDialog gd = new GenericDialog("Global optimization options");
	gd.addChoice( "Global_optimization_strategy", methodDescriptions, methodDescriptions[ defaultGlobalOpt ] );
	gd.addNumericField( "relative error threshold", 2.5, 3 );
	gd.addNumericField( "absolute error threshold", 3.5, 3 );
	if (askForGrouping )
		gd.addCheckbox( "show_expert_grouping_options", defaultExpertGrouping );
	gd.showDialog();

	if (gd.wasCanceled())
		return null;

	final double relTh = gd.getNextNumber();
	final double absTh = gd.getNextNumber();
	final int methodIdx = defaultGlobalOpt = gd.getNextChoiceIndex();
	final boolean expertGrouping = askForGrouping ? gd.getNextBoolean() : false;

	final GlobalOptType method;
	if (methodIdx == 0)
		method = GlobalOptType.SIMPLE;
	else if (methodIdx == 1)
		method = GlobalOptType.ITERATIVE;
	else
		method = GlobalOptType.TWO_ROUND;

	return new GlobalOptimizationParameters(relTh, absTh, method, expertGrouping);
}
 
Example 9
Source File: Distortion_Correction.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean readFields( final GenericDialog gd )
{
	SIFT.readFields( gd, sift );

	rod = ( float )gd.getNextNumber();

	maxEpsilon = ( float )gd.getNextNumber();
	minInlierRatio = ( float )gd.getNextNumber();
	expectedModelIndex = gd.getNextChoiceIndex();

	dimension = ( int )gd.getNextNumber();
	lambda = ( double )gd.getNextNumber();

	return !gd.invalidNumber();
}
 
Example 10
Source File: AbstractLayerAlignmentParam.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean setupSIFT( final String title )
{
	/* SIFT */
	final GenericDialog gdSIFT = new GenericDialog( title + "SIFT parameters" );

	SIFT.addFields( gdSIFT, ppm.sift );

	gdSIFT.addMessage( "Local Descriptor Matching:" );
	gdSIFT.addNumericField( "closest/next_closest_ratio :", ppm.rod, 2 );

	gdSIFT.addMessage( "Miscellaneous:" );
	gdSIFT.addCheckbox( "clear_cache", ppm.clearCache );
	gdSIFT.addNumericField( "feature_extraction_threads :", ppm.maxNumThreadsSift, 0 );

	gdSIFT.showDialog();

	if ( gdSIFT.wasCanceled() )
		return false;

	SIFT.readFields( gdSIFT, ppm.sift );

	ppm.rod = ( float )gdSIFT.getNextNumber();
	ppm.clearCache = gdSIFT.getNextBoolean();
	ppm.maxNumThreadsSift = ( int )gdSIFT.getNextNumber();

	return true;
}
 
Example 11
Source File: DifferenceOfMean.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected boolean setAdvancedValues( final Channel channel )
{
	final int channelId = channel.getId();
	
	final GenericDialog gd = new GenericDialog( "Advanced values for channel " + channel.getName() );

	String ch;

	if ( this.channelsToProcess.size() > 1 )
		ch = "_" + channel.getName().replace( ' ', '_' );
	else
		ch = "";

	gd.addMessage( "Advanced values for channel " + channel.getName() );
	gd.addNumericField( "Radius_1" + ch, defaultRadius1[ channelId ], 0 );
	gd.addNumericField( "Radius_2" + ch, defaultRadius2[ channelId ], 0 );
	gd.addNumericField( "Threshold" + ch, defaultThreshold[ channelId ], 4 );
	gd.addCheckbox( "Find_minima" + ch, defaultFindMin[ channelId ] );
	gd.addCheckbox( "Find_maxima" + ch, defaultFindMax[ channelId ] );

	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return false;
	
	this.radius1[ channelId ] = defaultRadius1[ channelId ] = (int)Math.round( gd.getNextNumber() );
	this.radius2[ channelId ] = defaultRadius2[ channelId ] = (int)Math.round( gd.getNextNumber() );
	this.threshold[ channelId ] = defaultThreshold[ channelId ] = gd.getNextNumber();
	this.findMin[ channelId ] = defaultFindMin[ channelId ] = gd.getNextBoolean();
	this.findMax[ channelId ] = defaultFindMax[ channelId ] = gd.getNextBoolean();
	
	return true;
}
 
Example 12
Source File: Align.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean readRegularizationFields( final GenericDialog gd )
{
	regularizerModelIndex = gd.getNextChoiceIndex();
	lambda = gd.getNextNumber();

	return !gd.invalidNumber();
}
 
Example 13
Source File: BGR_Histogram_ComparisonJ_.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
private boolean showDialog() {

        GenericDialog gd = new GenericDialog("BGR Histogram Comparison");
        gd.addNumericField("Blue bins", blueBins, 0);
        gd.addNumericField("Green bins", greenBins, 0);
        gd.addNumericField("Red bins", redBins, 0);
        //gd.addNumericField("Gaussian Kernel width:", gaussianKernelWidth, 0);

        gd.showDialog();
        if (gd.wasCanceled()) {
            return false;
        }

        blueBins = (int) gd.getNextNumber();
        if (blueBins < 1) {
            blueBins = 1;
        }
        if (blueBins > 255) {
            blueBins = 255;
        }

        greenBins = (int) gd.getNextNumber();
        if (greenBins < 1) {
            greenBins = 1;
        }
        if (greenBins > 255) {
            greenBins = 255;
        }
        redBins = (int) gd.getNextNumber();
        if (redBins < 1) {
            redBins = 1;
        }
        if (redBins > 255) {
            redBins = 255;
        }

        return true;
    }
 
Example 14
Source File: Bead_Registration.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static double[][] getAdvancedIntegralImageParameters( final int[] channelIndices )
{
	if ( channelIndices == null || channelIndices.length == 0 )
		return null;
	
	if ( defaultintegralParameters == null || defaultintegralParameters.length != channelIndices.length || defaultIntegralRadius == null || defaultIntegralRadius.length != channelIndices.length )
	{
		defaultintegralParameters = new double[ channelIndices.length ];
		defaultIntegralRadius = new int[ channelIndices.length ][ 2 ];
		
		for ( int i = 0; i < channelIndices.length; ++i )
		{
			defaultintegralParameters[ i ] = 0.02;
			defaultIntegralRadius[ i ][ 0 ] = 2; // r=3
			defaultIntegralRadius[ i ][ 1 ] = 3; // r=5
		}
	}

	final GenericDialog gd = new GenericDialog( "Select Integral Image Parameters" );
	
	for ( int i = 0; i < channelIndices.length; ++i )
	{
		final int channel = channelIndices[ i ];

		gd.addNumericField( "Channel_" + channel + "_radius_1", defaultIntegralRadius[ i ][ 0 ], 0 );
		gd.addNumericField( "Channel_" + channel + "_radius_2", defaultIntegralRadius[ i ][ 1 ], 0 );
		gd.addNumericField( "Channel_" + channel + "_Threshold", defaultintegralParameters[ i ], 4 );
	}
	
	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return null;
	
	final double[][] integralParameters = new double[ channelIndices.length ][ 3 ];
	
	for ( int i = 0; i < channelIndices.length; ++i )
	{
		defaultIntegralRadius[ i ][ 0 ] = (int)Math.round( gd.getNextNumber() );
		defaultIntegralRadius[ i ][ 1 ] = (int)Math.round( gd.getNextNumber() );
		defaultintegralParameters[ i ] = gd.getNextNumber();
					
		if ( defaultIntegralRadius[ i ][ 0 ] < 1 )
			defaultIntegralRadius[ i ][ 0 ] = 1;
		
		if ( defaultIntegralRadius[ i ][ 1 ] < defaultIntegralRadius[ i ][ 0 ] )
			defaultIntegralRadius[ i ][ 1 ] = defaultIntegralRadius[ i ][ 0 ] + 1;
		
		if ( defaultintegralParameters[ i ] <= 0 )
			defaultintegralParameters[ i ] = Float.MIN_VALUE;
		
		integralParameters[ i ][ 0 ] = defaultIntegralRadius[ i ][ 0 ];
		integralParameters[ i ][ 1 ] = defaultIntegralRadius[ i ][ 1 ];
		integralParameters[ i ][ 2 ] = defaultintegralParameters[ i ];
	}
	
	return integralParameters;
}
 
Example 15
Source File: LegacyStackImgLoaderIJ.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
protected static Parameters queryParameters()
{
	final GenericDialog gd = new GenericDialog( "Opening 32bit TIFF as 16bit" );

	gd.addMessage( "You are trying to open 32-bit images as 16-bit (resaving as HDF5 maybe). Please define how to convert to 16bit.", GUIHelper.mediumstatusfont );
	gd.addMessage( "Note: This dialog will only show up once for the first image.", GUIHelper.mediumstatusfont );
	gd.addChoice( "Convert_32bit", Generic_Resave_HDF5.convertChoices, Generic_Resave_HDF5.convertChoices[ Generic_Resave_HDF5.defaultConvertChoice ] );

	gd.showDialog();

	if ( gd.wasCanceled() )
		return null;

	Generic_Resave_HDF5.defaultConvertChoice = gd.getNextChoiceIndex();

	if ( Generic_Resave_HDF5.defaultConvertChoice == 2 )
	{
		if ( Double.isNaN( Generic_Resave_HDF5.defaultMin ) )
			Generic_Resave_HDF5.defaultMin = 0;

		if ( Double.isNaN( Generic_Resave_HDF5.defaultMax ) )
			Generic_Resave_HDF5.defaultMax = 5;

		final GenericDialog gdMinMax = new GenericDialog( "Define min/max" );

		gdMinMax.addNumericField( "Min_Intensity_for_16bit_conversion", Generic_Resave_HDF5.defaultMin, 1 );
		gdMinMax.addNumericField( "Max_Intensity_for_16bit_conversion", Generic_Resave_HDF5.defaultMax, 1 );
		gdMinMax.addMessage( "Note: the typical range for multiview deconvolution is [0 ... 10] & for fusion the same as the input intensities., ",GUIHelper.mediumstatusfont );

		gdMinMax.showDialog();

		if ( gdMinMax.wasCanceled() )
			return null;

		Generic_Resave_HDF5.defaultMin = gdMinMax.getNextNumber();
		Generic_Resave_HDF5.defaultMax = gdMinMax.getNextNumber();
	}
	else
	{
		Generic_Resave_HDF5.defaultMin = Generic_Resave_HDF5.defaultMax = Double.NaN;
	}

	return new Parameters( false, null, null, null, null, false, false, 0, 0, false, 0, Generic_Resave_HDF5.defaultConvertChoice, Generic_Resave_HDF5.defaultMin, Generic_Resave_HDF5.defaultMax );
}
 
Example 16
Source File: Treeline.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
protected boolean askAdjustRadius(final Node<Float> nd) {

		final GenericDialog gd = new GenericDialog("Adjust radius");
		final Calibration cal = layer_set.getCalibration();
		String unit = cal.getUnit();
		if (!unit.toLowerCase().startsWith("pixel")) {
			final String[] units = new String[]{"pixels", unit};
			gd.addChoice("Units:", units, units[1]);
			gd.addNumericField("Radius:", nd.getData() * cal.pixelWidth, 2);
			final TextField tfr = (TextField) gd.getNumericFields().get(0);
			((Choice)gd.getChoices().get(0)).addItemListener(new ItemListener() {
				@Override
                public void itemStateChanged(final ItemEvent ie) {
					final double val = Double.parseDouble(tfr.getText());
					if (Double.isNaN(val)) return;
					tfr.setText(Double.toString(units[0] == ie.getItem() ?
									val / cal.pixelWidth
								      : val * cal.pixelWidth));
				}
			});
		} else {
			unit = null;
			gd.addNumericField("Radius:", nd.getData(), 2, 10, "pixels");
		}
		final String[] choices = {"this node only", "nodes until next branch or end node", "entire subtree"};
		gd.addChoice("Apply to:", choices, choices[0]);
		gd.showDialog();
		if (gd.wasCanceled()) return false;
		double radius = gd.getNextNumber();
		if (Double.isNaN(radius) || radius < 0) {
			Utils.log("Invalid radius: " + radius);
			return false;
		}
		if (null != unit && 1 == gd.getNextChoiceIndex() && 0 != radius) {
			// convert radius from units to pixels
			radius = radius / cal.pixelWidth;
		}
		final float r = (float)radius;
		final Node.Operation<Float> op = new Node.Operation<Float>() {
			@Override
			public void apply(final Node<Float> node) throws Exception {
				node.setData(r);
			}
		};
		// Apply to:
		try {
			layer_set.addDataEditStep(this);
			switch (gd.getNextChoiceIndex()) {
				case 0:
					// Just the node
					nd.setData(r);
					break;
				case 1:
					// All the way to the next branch or end point
					nd.applyToSlab(op);
					break;
				case 2:
					// To the entire subtree of nodes
					nd.applyToSubtree(op);
					break;
				default:
					return false;
			}
			layer_set.addDataEditStep(this);
		} catch (final Exception e) {
			IJError.print(e);
			layer_set.undoOneStep();
		}

		calculateBoundingBox(layer);
		Display.repaint(layer_set);

		return true;
	}
 
Example 17
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;
}
 
Example 18
Source File: ICPRefinement.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
public static boolean getGUIParametersAdvanced( final SpimData2 data, final ICPRefinementParameters params )
{
	//
	// get advanced parameters
	//
	final GenericDialog gd = new GenericDialog( "Expert Refine by ICP" );

	final ArrayList< String > labels = getAllLabels( params.viewIds, data );

	if ( labels.size() == 0 )
	{
		IOFunctions.println( "No interest point defined, please detect interest point and re-run" );
		new Interest_Point_Detection().detectInterestPoints( data, params.viewIds );
		return false;
	}

	final String[] labelChoice = new String[ labels.size() ];

	for ( int i = 0; i < labels.size(); ++i )
		labelChoice[ i ] = labels.get( i );

	if ( defaultLabelDialog >= labelChoice.length )
		defaultLabelDialog = 0;

	gd.addChoice( "Interest_Points", labelChoice, labelChoice[ defaultLabelDialog ] );
	gd.addNumericField( "ICP_maximum_error", defaultICPError, 2 );
	gd.addChoice( "Transformation model", TransformationModelGUI.modelChoice, TransformationModelGUI.modelChoice[ defaultModel ] );
	gd.addCheckbox( "Regularize_model", defaultRegularize );

	final ArrayList< Channel > channels = SpimData2.getAllChannelsSorted( data, params.viewIds );
	final String[] channelChoice = new String[ 2 + channels.size() ];
	channelChoice[ 0 ] = "Do not group";
	channelChoice[ 1 ] = "Group all";
	for ( int i = 0; i < channels.size(); ++i )
		channelChoice[ i + 2 ] = "Only channel " + channels.get( i ).getName();
	if ( defaultChannelChoice >= channelChoice.length )
		defaultChannelChoice = 0;

	gd.addChoice( "Group_channels", channelChoice, channelChoice[ defaultChannelChoice ] );
	gd.addCheckbox( "Group_tiles", false );
	gd.addCheckbox( "Group_illuminations", false );

	gd.showDialog();
	if ( gd.wasCanceled() )
		return false;

	params.label = labels.get( defaultLabelDialog = gd.getNextChoiceIndex() );
	params.maxError = defaultICPError = gd.getNextNumber();
	TransformationModelGUI model = new TransformationModelGUI( defaultModel = gd.getNextChoiceIndex() );

	if ( defaultRegularize = gd.getNextBoolean() )
		if ( !model.queryRegularizedModel() )
			return false;

	params.transformationModel = model.getModel();

	final int channelGroup = gd.getNextChoiceIndex();
	if ( channelGroup > 0 )
	{
		params.groupChannels = true;
		if ( channelGroup >= 2 )
		{
			for ( int i = 0; i < channels.size(); ++i )
			{
				if ( channelGroup - 2 != i )
					params.doNotGroupChannels.add( channels.get( i ).getId() );
				else
					IOFunctions.println( "Only grouping tiles & illuminations for channel: " + channels.get( i ).getName() );
			}
		}
	}
	else
	{
		params.groupChannels = false;
	}
	params.groupTiles = gd.getNextBoolean();
	params.groupIllums = gd.getNextBoolean();

	params.transformationDescription = "Expert ICP Refinement";

	return true;
}
 
Example 19
Source File: DistanceTransformWatershed3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Plugin run method
 */
public void run(String arg) {
	
	ImagePlus image = WindowManager.getCurrentImage();
	if ( image == null ) 
	{
		IJ.error("Distance Transform Watershed 3D",
				"Need at least one image to work");
		return;
	}

	if( !BinaryImages.isBinaryImage( image ) )
	{
		IJ.error( "Distance Transform Watershed 3D", "Input image is not"
				+ " binary (8-bit with only 0 or 255 values)" );
	}

	// Create a new generic dialog with appropriate options
	GenericDialog gd = new GenericDialog( "Distance Transform Watershed 3D" );
	gd.setInsets( 0, 0, 0 );
	gd.addMessage( "Distance map options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addChoice( "Distances", ChamferWeights3D.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", Conn3D.getAllLabels(),
			connectivity.label );
	gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" );
	gd.showDialog();

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

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

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

	long t0 = System.currentTimeMillis();

	final ImagePlus result;
	if (floatProcessing)
		result = processFloat( image, weights.getFloatWeights(), normalize );
	else
		result = processShort( image, weights.getShortWeights(), normalize );

	Images3D.optimizeDisplayRange( result );

	// Display the result image
	result.show();
	result.setSlice( image.getCurrentSlice() );

	// Display elapsed time
	long t1 = System.currentTimeMillis();
	IJUtils.showElapsedTime( "Distance Transform Watershed 3D",
			t1 - t0, image );
}
 
Example 20
Source File: EfficientBayesianBased.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean parseAdditionalParameters( final GenericDialog gd )
{
	defaultFFTImgType = gd.getNextChoiceIndex();

	if ( defaultFFTImgType == 0 )
		computeFactory = new ArrayImgFactory< FloatType >();
	else if ( defaultFFTImgType == 1 )
		computeFactory = new ImagePlusImgFactory< FloatType >();
	else
		computeFactory = new CellImgFactory< FloatType >( 256 );

	saveMemory = defaultSaveMemory = gd.getNextBoolean();
	defaultIterationType = gd.getNextChoiceIndex();

	if ( defaultIterationType == 0 )
		iterationType = PSFTYPE.OPTIMIZATION_II;
	else if ( defaultIterationType == 1 )
		iterationType = PSFTYPE.OPTIMIZATION_I;
	else if ( defaultIterationType == 2 )
		iterationType = PSFTYPE.EFFICIENT_BAYESIAN;
	else //if ( defaultIterationType == 3 )
		iterationType = PSFTYPE.INDEPENDENT;

	defaultWeightType = gd.getNextChoiceIndex();

	if ( defaultWeightType == 0 )
		weightType = WeightType.PRECOMPUTED_WEIGHTS;
	else if ( defaultWeightType == 1 )
		weightType = WeightType.VIRTUAL_WEIGHTS;
	else if ( defaultWeightType == 2 )
		weightType = WeightType.NO_WEIGHTS;
	else
		weightType = WeightType.WEIGHTS_ONLY;

	osemspeedupIndex = defaultOSEMspeedupIndex = gd.getNextChoiceIndex();
	numIterations = defaultNumIterations = (int)Math.round( gd.getNextNumber() );
	debugMode = defaultDebugMode = gd.getNextBoolean();
	adjustBlending = defaultAdjustBlending = gd.getNextBoolean();
	useTikhonovRegularization = defaultUseTikhonovRegularization = gd.getNextBoolean();
	lambda = defaultLambda = gd.getNextNumber();
	blockSizeIndex = defaultBlockSizeIndex = gd.getNextChoiceIndex();
	computationTypeIndex = defaultComputationTypeIndex = gd.getNextChoiceIndex();
	extractPSFIndex = defaultExtractPSF = gd.getNextChoiceIndex();
	displayPSF = defaultDisplayPSF = gd.getNextChoiceIndex();

	return true;
}