ij.gui.ImageWindow Java Examples

The following examples show how to use ij.gui.ImageWindow. 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: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Segment current image (GUI needs to be running)
 * 
 * @param dynamic string containing dynamic value (format: "dynamic=[integer value]")
 * @param calculateDams string containing boolean flag to create dams (format: "calculateDams=[boolean])
 * @param connectivity string containing connectivity value (format: "connectivity=[4 or 8 / 6 or 26])
 * @param usePriorityQueue string containing boolean flag to use priority queue (format: "usePriorityQueue=[boolean])
 * 
 * @deprecated the priority queue method is now the only one
 */
public static void segment(
		String dynamic,
		String calculateDams,
		String connectivity,
		String usePriorityQueue )
{		
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		//IJ.log( "GUI detected" );			
		final CustomWindow win = (CustomWindow) iw;
		win.setDynamic( Double.parseDouble( dynamic.replace( "tolerance=", "" ) ) );
		win.setCalculateDams( calculateDams.contains( "true" ) );
		win.setConnectivity( Integer.parseInt( connectivity.replace( "connectivity=", "" ) ) );
		win.runSegmentation( win.getSegmentText() );			
	}
	else
		IJ.log( "Error: Morphological Segmentation GUI not detected." );
}
 
Example #2
Source File: InteractivePlotter.java    From Scripts with GNU General Public License v3.0 6 votes vote down vote up
private ArrayList<PlotInstance> getPlots() {
	final ArrayList<PlotInstance> plots = new ArrayList<>();
	final int[] ids = WindowManager.getIDList();
	if (ids != null) {
		for (final int id : ids) {
			final ImagePlus pImp = WindowManager.getImage(id);
			if (pImp == null)
				continue;
			final ImageWindow win = pImp.getWindow();
			if (win == null)
				continue;
			if (win instanceof PlotWindow) {
				if (win.equals(pw))
					continue;
				plots.add(new PlotInstance((PlotWindow) win));
			}
		}
	}
	return plots;
}
 
Example #3
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Segment current image (GUI needs to be running)
 *
 * @param calculateDams string containing boolean flag to create dams (format: "calculateDams=[boolean])
 * @param connectivity string containing connectivity value (format: "connectivity=[4 or 8 / 6 or 26])
 */
public static void segment(
		String calculateDams,
		String connectivity )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.setCalculateDams( calculateDams.contains( "true" ) );
		win.setConnectivity( Integer.parseInt( connectivity.replace( "connectivity=", "" ) ) );
		win.runSegmentation( win.getSegmentText() );
	}
	else
		IJ.log( "Error: Interactive Marker-controlled Watershed GUI not detected." );
}
 
Example #4
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Segment current image (GUI needs to be running)
 * 
 * @param dynamic string containing dynamic value (format: "dynamic=[integer value]")
 * @param calculateDams string containing boolean flag to create dams (format: "calculateDams=[boolean])
 * @param connectivity string containing connectivity value (format: "connectivity=[4 or 8 / 6 or 26])
 */
public static void segment(
		String dynamic,
		String calculateDams,
		String connectivity )
{		
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		//IJ.log( "GUI detected" );			
		final CustomWindow win = (CustomWindow) iw;
		win.setDynamic( Double.parseDouble( dynamic.replace( "tolerance=", "" ) ) );
		win.setCalculateDams( calculateDams.contains( "true" ) );
		win.setConnectivity( Integer.parseInt( connectivity.replace( "connectivity=", "" ) ) );
		win.runSegmentation( win.getSegmentText() );			
	}
	else
		IJ.log( "Error: Morphological Segmentation GUI not detected." );
}
 
Example #5
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Toggle current result overlay image
 */
public static void toggleOverlay()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.toggleOverlay();
	}
}
 
Example #6
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Merge labels that are selected either by a freehand or a point ROI.
 * Label of value 0 (watershed line) is skipped.
 */
public static void mergeLabels()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.mergeLabels();
	}
}
 
Example #7
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Shuffle LUT of current display image.
 */
public static void shuffleColors()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.shuffleColors();
	}
}
 
Example #8
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Show current result in a new image
 */
public static void createResultImage()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		String mode = win.getResultDisplayOption();
		
		ImagePlus result = null;

		if( mode.equals( MorphologicalSegmentation.catchmentBasinsText) )
			result = win.getResult( ResultMode.BASINS );
		else if( mode.equals( MorphologicalSegmentation.overlaidBasinsText ) )
			result = win.getResult( ResultMode.OVERLAID_BASINS );
		else if( mode.equals( MorphologicalSegmentation.watershedLinesText ) )
			result = win.getResult( ResultMode.LINES );
		else if( mode.equals( MorphologicalSegmentation.overlaidDamsText ))
			result = win.getResult( ResultMode.OVERLAID_DAMS );

		if( null != result )
		{
			result.show();
			result.setSlice( win.getImagePlus().getCurrentSlice() );
		}
	}
}
 
Example #9
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set input image type 
 * @param type input image type (border or object)
 */
public static void setInputImageType( String type )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		
		if( type.equals( "object" ) )
			win.setInputImageType( objectImageText );
		else if( type.equals( "border" ) )
			win.setInputImageType( borderImageText );
	}			
}
 
Example #10
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set GUI to show gradient image in the main canvas
 * @param bool true to display gradient image and false to display input image
 */
public static void setShowGradient( String bool )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		if( bool.equals( "true" ) )
			win.setShowGradient( true );
		else if( bool.equals( "false" ) )
			win.setShowGradient( false );	
	}
}
 
Example #11
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the display format in the GUI
 * @param format output mode ("Overlaid basins", "Overlaid dams", "Catchment basins", "Watershed lines")
 */
public static void setDisplayFormat( String format )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.setResultDisplayOption( format );
		if( win.isShowResultOverlaySelected() )
			win.updateResultOverlay();
	}
}
 
Example #12
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the gradient radius
 * @param radius gradient radius size (in pixels)
 */
public static void setGradientRadius( String radius )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.setGradientRadius( Integer.parseInt( radius ) );			
	}
}
 
Example #13
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the gradient method to use
 * @param method name of the gradient method to use
 */
public static void setGradientType( String method )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.setGradientType( method );
	}
}
 
Example #14
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Toggle current result overlay image
 */
public static void toggleOverlay()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.toggleOverlay();
	}
}
 
Example #15
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Merge labels that are selected either by a freehand or a point ROI.
 * Label of value 0 (watershed line) is skipped.
 */
public static void mergeLabels()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.mergeLabels();
	}
}
 
Example #16
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Shuffle LUT of current display image.
 */
public static void shuffleColors()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.shuffleColors();
	}
}
 
Example #17
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Show current result in a new image
 */
public static void createResultImage()
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		String mode = win.getResultDisplayOption();

		ImagePlus result = null;

		if( mode.equals( InteractiveMarkerControlledWatershed.catchmentBasinsText) )
			result = win.getResult( ResultMode.BASINS );
		else if( mode.equals( InteractiveMarkerControlledWatershed.overlaidBasinsText ) )
			result = win.getResult( ResultMode.OVERLAID_BASINS );
		else if( mode.equals( InteractiveMarkerControlledWatershed.watershedLinesText ) )
			result = win.getResult( ResultMode.LINES );
		else if( mode.equals( InteractiveMarkerControlledWatershed.overlaidDamsText ))
			result = win.getResult( ResultMode.OVERLAID_DAMS );

		if( null != result )
		{
			result.show();
			result.setSlice( win.getImagePlus().getCurrentSlice() );
		}
	}
}
 
Example #18
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the display format in the GUI
 * @param format output mode ("Overlaid basins", "Overlaid dams", "Catchment basins", "Watershed lines")
 */
public static void setDisplayFormat( String format )
{
	final ImageWindow iw = WindowManager.getCurrentImage().getWindow();
	if( iw instanceof CustomWindow )
	{
		final CustomWindow win = (CustomWindow) iw;
		win.setResultDisplayOption( format );
		if( win.isShowResultOverlaySelected() )
			win.updateResultOverlay();
	}
}
 
Example #19
Source File: RoiPicker.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Functional method of the RoiPicker. Determines which Rois match the x,y
 * coordinates of the received MouseEvent and the C,Z,T coordinates of the
 * active image. The user can cycle through these Rois with repeated clicks.
 */
@Override
public void mouseReleased(MouseEvent e) {
	ImageCanvas source = (ImageCanvas) e.getSource();
	if (source != canvas) {
		// We changed image window. Update fields accordingly
		ImageWindow window = (ImageWindow) source.getParent();
		imp = window.getImagePlus();
		canvas = source;
	}
	// Convert global coords to local
	double x = canvas.offScreenXD(e.getX());
	double y = canvas.offScreenYD(e.getY());
	// Get the RoiManager
	RoiManager rm = RoiManager.getInstance();
	if (rm == null) return;

	Roi[] rois = rm.getRoisAsArray();
	// Get the active ImagePlus's current z,c,t coords
	int[] position = imp.convertIndexToPosition(imp.getCurrentSlice());

	Set<Integer> matchedSet = new HashSet<Integer>();
	List<Integer> matchedIndices = new ArrayList<Integer>();

	// generate list of all rois containing x,y and matching the ImagePlus's
	// position
	for (int i = 0; i < rois.length; i++) {
		Roi r = rois[i];
		// Check position
		if (containsPoint(r, position, x, y)) {
			// Matched. Add to the matched set and list
			Integer index = i;
			matchedSet.add(index);
			matchedIndices.add(index);
		}
	}

	// If we discovered the currently known roi set, display the next roi in
	// the series
	if (same(roiSet, matchedSet)) {
		incrementIndex();
	}
	else {
		// otherwise, update the cached indices and display the union of the rois
		roiSet = matchedSet;
		roiIndices = matchedIndices;
		roiIndex = roiIndices.size();
	}

	// Perform the roi selection
	if (matchedIndices.size() > 0) selectRois(rm);
}