ij.gui.Overlay Java Examples

The following examples show how to use ij.gui.Overlay. 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: IJImager.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void append(ContainerImage container, RealSignal signal, String title, Imager.Type type, ArrayList<Line2D.Double> overlayLines) {		
	ImagePlus cont = (ImagePlus) container.object;
	if (container.object == null) {
		ImageStack stack = new ImageStack(signal.nx, signal.ny);
		stack.addSlice(build(signal, type).getProcessor());
		stack.addSlice(build(signal, type).getProcessor());
		container.object = new ImagePlus(title, stack);
		((ImagePlus)container.object).show();
	}
	else {
		cont.getStack().addSlice(build(signal, type).getProcessor());
		cont.setSlice(cont.getStack().getSize());
		cont.updateAndDraw();
		cont.getProcessor().resetMinAndMax();
	}
	if (cont != null)  {
		Overlay overlay = cont.getOverlay() == null ? new Overlay() : cont.getOverlay();
		for(Line2D.Double line : overlayLines) {
			ij.gui.Line roi = new ij.gui.Line(round(line.x1), round(line.y1), round(line.x2), round(line.y2));
			overlay.add(roi);
		}
		cont.setOverlay(overlay);
	}		
}
 
Example #2
Source File: Path.java    From SNT with GNU General Public License v3.0 6 votes vote down vote up
private void addPolyLineToOverlay(final FloatPolygon p, final int z_position, final int roi_id,
		final Overlay overlay) {
	if (p.npoints > 0) {
		if (p.npoints == 1) {
			// create 1-pixel length lines for single points
			p.xpoints[0] -= 0.5f;
			p.ypoints[0] -= 0.5f;
			p.addPoint(p.xpoints[0] + 0.5f, p.ypoints[0] + 0.5f);
		}
		final PolygonRoi polyline = new PolygonRoi(p, Roi.FREELINE);
		polyline.enableSubPixelResolution();
		// polyline.fitSplineForStraightening();
		if (name == null)
			setDefaultName();
		polyline.setStrokeColor(getColor());
		polyline.setName(String.format(name + "-%04d-Z%d", roi_id, z_position));
		polyline.setPosition(z_position + 1); // index 1
		overlay.add(polyline);
	}
}
 
Example #3
Source File: OrientedBoundingBoxPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Display the result of oriented bounding box extraction as overlay on a
 * given image.
 * 
 * @param target
 *            the ImagePlus used to display result
 * @param results
 *            the associative map between region label and bounding box
 */
private void showResultsAsOverlay(Map<Integer, OrientedBox2D> results, ImagePlus target)	
{
	// get spatial calibration of target image
	Calibration calib = target.getCalibration();
	
	// create overlay
	Overlay overlay = new Overlay();
	Roi roi;
	
	// add each box to the overlay
	for (int label : results.keySet()) 
	{
		// Coordinates of inscribed circle, in pixel coordinates
		OrientedBox2D box = results.get(label);
		roi = createUncalibratedRoi(box, calib);
		
		// draw inscribed circle
		roi.setStrokeColor(Color.GREEN);
		overlay.add(roi);
	}
	
	target.setOverlay(overlay);
}
 
Example #4
Source File: PointMatchClientTest.java    From render with GNU General Public License v2.0 6 votes vote down vote up
private static void showMatches(final String imageUrl,
                                final List<CanvasMatches> canvasMatchesList,
                                final boolean isP,
                                final Color[] colors) {

    final ImagePlus imagePlus = IJ.openImage(imageUrl);
    final Overlay overlay = new Overlay();

    int colorIndex = 0;
    for (final CanvasMatches canvasMatches : canvasMatchesList) {
        final double[][] points = isP ? canvasMatches.getMatches().getPs() : canvasMatches.getMatches().getQs();
        final float[] xPoints = toFloat(points[0]);
        final float[] yPoints = toFloat(points[1]);
        final PointRoi pointRoi = new PointRoi(xPoints, yPoints, xPoints.length);
        pointRoi.setStrokeColor(colors[colorIndex]);
        pointRoi.setSize(3); // 0: "Tiny", 1: "Small", 2: "Medium", 3: "Large", 4: "Extra Large"}
        overlay.add(pointRoi);
        colorIndex = (colorIndex + 1) % colors.length;
    }

    imagePlus.setOverlay(overlay);
    imagePlus.updateAndDraw();
    imagePlus.show();

}
 
Example #5
Source File: BoundingBoxPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Display the result of bounding box extraction as overlay on a given
 * image.
 * 
 * @param target
 *            the ImagePlus used to display result
 * @param results
 *            the associative map between region label and bounding box
 */
private void showResultsAsOverlay(Map<Integer, Box2D> results, ImagePlus target)	
{
	// get spatial calibration of target image
	Calibration calib = target.getCalibration();
	
	// create overlay
	Overlay overlay = new Overlay();
	Roi roi;
	
	// add each box to the overlay
	for (int label : results.keySet()) 
	{
		// Coordinates of inscribed circle, in pixel coordinates
		Box2D box = results.get(label);
		box = uncalibrate(box, calib);
		roi = createRoi(box);
		
		// draw inscribed circle
		roi.setStrokeColor(Color.BLUE);
		overlay.add(roi);
	}
	
	target.setOverlay(overlay);
}
 
Example #6
Source File: IJImager.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void show(RealSignal signal, String title, Imager.Type type, int z, ArrayList<Line2D.Double> overlayLines) {
	ImagePlus imp = build(signal, type);
	if (imp != null) {
		imp.setTitle(title);
		int nz = imp.getStackSize();
		imp.show();
		imp.setSlice(Math.max(1, Math.min(nz, z)));
		imp.getProcessor().resetMinAndMax();
	}
	
	if (imp != null) {
		Overlay overlay = imp.getOverlay() == null ? new Overlay() : imp.getOverlay();
		for(Line2D.Double line : overlayLines) {
			ij.gui.Line roi = new ij.gui.Line(round(line.x1), round(line.y1), round(line.x2), round(line.y2));
			overlay.add(roi);
		}
		imp.setOverlay(overlay);
	}
}
 
Example #7
Source File: GeodesicDiameterPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void drawPaths(ImagePlus target, Map<Integer, GeodesicDiameter.Result> geodDiams)
{
	Overlay overlay = new Overlay();
	Calibration calib = target.getCalibration();
	
	for (GeodesicDiameter.Result result : geodDiams.values())
	{
		Roi roi = createPathRoi(result.path, calib);
	    roi.setStrokeColor(Color.RED);
	    overlay.add(roi);
	}

	target.setOverlay(overlay);
}
 
Example #8
Source File: PDFWriter.java    From Colocalisation_Analysis with GNU General Public License v3.0 5 votes vote down vote up
private void drawLine(Histogram2D<T> histogram, Overlay overlay, long imgWidth, long imgHeight, double slope,
		double intercept) {

	double startX, startY, endX, endY;
	/*
	 * since we want to draw the line over the whole image we can directly
	 * use screen coordinates for x values.
	 */
	startX = 0.0;
	endX = imgWidth;

	// check if we can get some exta information for drawing
	// get calibrated start y coordinates
	double calibratedStartY = slope * histogram.getXMin() + intercept;
	double calibratedEndY = slope * histogram.getXMax() + intercept;
	// convert calibrated coordinates to screen coordinates
	startY = calibratedStartY * histogram.getYBinWidth();
	endY = calibratedEndY * histogram.getYBinWidth();

	/*
	 * since the screen origin is in the top left of the image, we need to
	 * x-mirror our line
	 */
	startY = (imgHeight - 1) - startY;
	endY = (imgHeight - 1) - endY;
	// create the line ROI and add it to the overlay
	Line lineROI = new Line(startX, startY, endX, endY);
	/*
	 * Set drawing width of line to one, in case it has been changed
	 * globally.
	 */
	lineROI.setStrokeWidth(1.0f);
	overlay.add(lineROI);
	
}
 
Example #9
Source File: PDFWriter.java    From Colocalisation_Analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handles a histogram the following way: create snapshot, log data, reset the
 * display range, apply the Fire LUT and finally store it as an iText PDF image.
 * Afterwards the image is reset to its orignal state again
 */
@Override
public void handleHistogram(Histogram2D<T> histogram, String name) {
	RandomAccessibleInterval<LongType> image = histogram.getPlotImage();
	ImagePlus imp = ImageJFunctions.wrapFloat( image, name );
	
	// make a snapshot to be able to reset after modifications
	imp.getProcessor().snapshot();
	imp.getProcessor().log();
	imp.updateAndDraw();
	imp.getProcessor().resetMinAndMax();
	IJ.run(imp,"Fire", null);
	
	Overlay overlay = new Overlay();
	
	/*
	 * check if we should draw a regression line for the current
	 * histogram.
	 */
	if (histogram.getDrawingSettings().contains(Histogram2D.DrawingFlags.RegressionLine)) {
		AutoThresholdRegression<T> autoThreshold = this.container.getAutoThreshold();
		if (histogram != null && autoThreshold != null) {
			drawLine(histogram, overlay, image.dimension(0), image.dimension(1),
					autoThreshold.getAutoThresholdSlope(), autoThreshold.getAutoThresholdIntercept());
			overlay.setStrokeColor(java.awt.Color.WHITE);
			imp.setOverlay(overlay);
		}
	}
	
	addImageToList(imp, name);
	// reset the imp from the log scaling we applied earlier
	imp.getProcessor().reset();
}
 
Example #10
Source File: MaxFeretDiameterPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void drawDiameters(ImagePlus target, Map<Integer, PointPair2D> geodDiams)
{
	Overlay overlay = new Overlay();
	Calibration calib = target.getCalibration();
	
	for (PointPair2D result : geodDiams.values())
	{
		Roi roi = createDiametersRoi(result, calib);
	    roi.setStrokeColor(Color.BLUE);
	    overlay.add(roi);
	}

	target.setOverlay(overlay);
}
 
Example #11
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Update the overlay in the display image based on
 * the current result and slice
 */
void updateResultOverlay()
{
	if( null != resultImage )
	{
		int slice = displayImage.getCurrentSlice();

		final String displayOption = (String) resultDisplayList.getSelectedItem();

		ImageRoi roi = null;

		if( displayOption.equals( catchmentBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidDamsText ) )
		{
			ImageProcessor lines = BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) );
			lines.invert();
			lines.setLut( LUT.createLutFromColor( Color.red ) );
			roi = new ImageRoi( 0, 0, lines );
			roi.setZeroTransparent( true );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( watershedLinesText ) )
		{
			roi = new ImageRoi(0, 0, BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( opacity );
		}

		displayImage.setOverlay( new Overlay( roi ) );
	}
}
 
Example #12
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Update the overlay in the display image based on 
 * the current result and slice
 */
void updateResultOverlay() 
{
	if( null != resultImage )
	{
		int slice = displayImage.getCurrentSlice();

		final String displayOption = (String) resultDisplayList.getSelectedItem();							

		ImageRoi roi = null;
		
		if( displayOption.equals( catchmentBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidDamsText ) )				
		{
			ImageProcessor lines = BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) );
			lines.invert();
			lines.setLut( LUT.createLutFromColor( Color.red ) );
			roi = new ImageRoi( 0, 0, lines );
			roi.setZeroTransparent( true );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( watershedLinesText ) )
		{
			roi = new ImageRoi(0, 0, BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidBasinsText ) )	
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( opacity );
		}
										
		displayImage.setOverlay( new Overlay( roi ) );
	}
}
 
Example #13
Source File: DrawTableValuesPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void drawValues(ImagePlus target)
	{
	    Overlay overlay = new Overlay();
//	    Calibration calib = target.getCalibration();
	    
        double[] xPos = getColumnValues(this.table, this.xPosHeaderName);
        double[] yPos = getColumnValues(this.table, this.yPosHeaderName);
        if (this.calibratedPosition)
        {
            Calibration calib = target.getCalibration();
            for (int i = 0; i < xPos.length; i++)
            {
                xPos[i] = xPos[i] * calib.pixelWidth  + calib.xOrigin;
                yPos[i] = yPos[i] * calib.pixelHeight + calib.yOrigin;
            }
        }
            
        double[] values = getColumnValues(this.table, this.valueHeaderName);

        for (int i = 0; i < xPos.length; i++)
        {
            Roi roi = new TextRoi(
                    xPos[i] + this.xOffset,
                    yPos[i] + this.yOffset,
                    String.format(this.pattern,  values[i]));
            overlay.add(roi);
        }

	    target.setOverlay(overlay);
	}
 
Example #14
Source File: InertiaEllipsePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Display the result of maximal inscribed circle extraction as overlay on a
 * given image.
 * 
 * @param target
 *            the ImagePlus used to display result
 * @param table
 *            the ResultsTable containing columns "xi", "yi" and "Radius"
 * @param the
 *            resolution in each direction
 */
private void showResultsAsOverlay(Map<Integer, Ellipse> results, ImagePlus target, boolean showEllipse, boolean showAxes)	
{
	// get spatial calibration of target image
	Calibration calib = target.getCalibration();
	
	// create overlay
	Overlay overlay = new Overlay();
	
	// add each ellipse to the overlay
	for (int label : results.keySet()) 
	{
		// Coordinates of inscribed circle, in pixel coordinates
		Ellipse ellipse = results.get(label);
		ellipse = uncalibrate(ellipse, calib);

		// roi corresponding to ellipse
		if (showEllipse)
		{
			addRoiToOverlay(overlay, createRoi(ellipse), Color.BLUE);
		}
		
		// the two roi corresponding to major axes
		if (showAxes)
		{
			addRoiToOverlay(overlay, createMajorAxisRoi(ellipse), Color.BLUE);
			addRoiToOverlay(overlay, createMinorAxisRoi(ellipse), Color.BLUE);
		}
	}
	
	target.setOverlay(overlay);
}
 
Example #15
Source File: RegionAdjacencyGraphPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void overlayRAG(Set<LabelPair> adjList, ImagePlus imagePlus, ImagePlus targetPlus)
{
	IJ.log("display RAG");
	
	// first compute centroids
	ImageProcessor image = imagePlus.getProcessor();
	int[] labels = LabelImages.findAllLabels(image);
	Map<Integer, Integer> labelMap = LabelImages.mapLabelIndices(labels);
	double[][] centroids = Centroid.centroids(image, labels);
	
	// create an overlay for drawing edges
	Overlay overlay = new Overlay();
	
	// iterate over adjacencies to add edges to overlay
	for (LabelPair pair : adjList)
	{
		// first retrieve index in centroid array
		int ind1 = labelMap.get(pair.label1);
		int ind2 = labelMap.get(pair.label2);
		
		// coordinates of edge extremities
		int x1 = (int) centroids[ind1][0];
		int y1 = (int) centroids[ind1][1];
		int x2 = (int) centroids[ind2][0];
		int y2 = (int) centroids[ind2][1];
		
		// draw current edge
		Roi roi = new Line(x1, y1, x2, y2);
		
		roi.setStrokeColor(Color.GREEN);
		roi.setStrokeWidth(2);
		overlay.add(roi);
	}
	
	targetPlus.setOverlay(overlay);
}
 
Example #16
Source File: EquivalentEllipsePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Display the result of maximal inscribed circle extraction as overlay on a
 * given image.
 * 
 * @param target
 *            the ImagePlus used to display result
 * @param table
 *            the ResultsTable containing columns "xi", "yi" and "Radius"
 * @param the
 *            resolution in each direction
 */
private void showResultsAsOverlay(Map<Integer, Ellipse> results, ImagePlus target, boolean showEllipse, boolean showAxes)	
{
	// get spatial calibration of target image
	Calibration calib = target.getCalibration();
	
	// create overlay
	Overlay overlay = new Overlay();
	
	// add each ellipse to the overlay
	for (int label : results.keySet()) 
	{
		// Coordinates of inscribed circle, in pixel coordinates
		Ellipse ellipse = results.get(label);
		ellipse = uncalibrate(ellipse, calib);

		// roi corresponding to ellipse
		if (showEllipse)
		{
			addRoiToOverlay(overlay, createRoi(ellipse), Color.BLUE);
		}
		
		// the two roi corresponding to major axes
		if (showAxes)
		{
			addRoiToOverlay(overlay, createMajorAxisRoi(ellipse), Color.BLUE);
			addRoiToOverlay(overlay, createMinorAxisRoi(ellipse), Color.BLUE);
		}
	}
	
	target.setOverlay(overlay);
}
 
Example #17
Source File: SimpleNeuriteTracer.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
private void removeMIPfromOverlay(final Overlay overlay) {
	if (overlay != null && overlay.size() > 0) {
		for (int i = overlay.size() - 1; i >= 0; i--) {
			final String roiName = overlay.get(i).getName();
			if (roiName != null && roiName.equals(OVERLAY_IDENTIFIER)) {
				overlay.remove(i);
				return;
			}
		}
	}
}
 
Example #18
Source File: RenderingOverlay.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static Overlay addPointsToOverlay(double[] xCoord, double[] yCoord, Overlay overlay, int slice, Color c, int markerType) {
    assert xCoord.length == yCoord.length;
    float[] xs = new float[xCoord.length];
    float[] ys = new float[yCoord.length];
    for(int i = 0; i < xCoord.length; i++) {
        xs[i] = (float) xCoord[i];
        ys[i] = (float) yCoord[i];
    }
    overlay.add(new MultiplePointsRoi(xs, ys, slice, c, markerType));
    return overlay;
}
 
Example #19
Source File: InertiaEllipsePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static final void addRoiToOverlay(Overlay overlay, Roi roi, Color color)
{
	roi.setStrokeColor(color);
	overlay.add(roi);
}
 
Example #20
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Get current segmentation results based on selected mode
 * @param mode selected result mode ("Overlaid basins", "Overlaid dams", "Catchment basins", "Watershed lines") 
 * @return result image
 */
ImagePlus getResult( ResultMode mode )
{
	String title = inputImage.getTitle();
	String ext = "";
	int index = title.lastIndexOf( "." );
	if( index != -1 )
	{
		ext = title.substring( index );
		title = title.substring( 0, index );				
	}
	
	ImagePlus result = null;
	
	// if the overlay is not shown
	if( showColorOverlay == false )
	{
		result = displayImage.duplicate();
		
		if ( applyGradient && showGradient )
			title += "-gradient";
		result.setTitle( title + ext );
		return result;
	}
	

	switch( mode ){
		case OVERLAID_BASINS:
			result = displayImage.duplicate();
			result.setOverlay( null ); // remove existing overlay
			ImageStack is = new ImageStack( displayImage.getWidth(), displayImage.getHeight() );
	
			for( slice=1; slice<=result.getImageStackSize(); slice++ )
			{
				ImagePlus aux = new ImagePlus( "", result.getImageStack().getProcessor( slice ) );
				ImageRoi roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
				roi.setOpacity( opacity );
				aux.setOverlay( new Overlay( roi ) );
				aux = aux.flatten();
				is.addSlice( aux.getProcessor() );
			}
			result.setStack( is );
			if( applyGradient && showGradient )
				title += "-gradient";
			result.setTitle( title + "-overlaid-basins" + ext );
			break;
		case BASINS:
			result = resultImage.duplicate();
			result.setTitle( title + "-catchment-basins" + ext );				
			break;
		case OVERLAID_DAMS:
			result = getWatershedLines( resultImage );
			result = ColorImages.binaryOverlay( displayImage, result, Color.red ) ;
			if( applyGradient && showGradient )
				title += "-gradient";
			result.setTitle( title + "-overlaid-dams" + ext );				
			break;
		case LINES:
			result = getWatershedLines( resultImage );
			IJ.run( result, "Invert", "stack" );
			result.setTitle( title + "-watershed-lines" + ext );								
			break;
	}

	return result;
}
 
Example #21
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Get current segmentation results based on selected mode
 * @param mode selected result mode ("Overlaid basins", "Overlaid dams", "Catchment basins", "Watershed lines") 
 * @return result image
 */
ImagePlus getResult( ResultMode mode )
{
	String title = inputImage.getTitle();
	String ext = "";
	int index = title.lastIndexOf( "." );
	if( index != -1 )
	{
		ext = title.substring( index );
		title = title.substring( 0, index );
	}

	ImagePlus result = null;

	// if the overlay is not shown
	if( showColorOverlay == false )
	{
		result = displayImage.duplicate();
		result.setTitle( title + ext );
		return result;
	}


	switch( mode ){
	case OVERLAID_BASINS:
		result = displayImage.duplicate();
		result.setOverlay( null ); // remove existing overlay
		ImageStack is = new ImageStack( displayImage.getWidth(), displayImage.getHeight() );

		for( slice=1; slice<=result.getImageStackSize(); slice++ )
		{
			ImagePlus aux = new ImagePlus( "", result.getImageStack().getProcessor( slice ) );
			ImageRoi roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( opacity );
			aux.setOverlay( new Overlay( roi ) );
			aux = aux.flatten();
			is.addSlice( aux.getProcessor() );
		}
		result.setStack( is );
		result.setTitle( title + "-overlaid-basins" + ext );
		break;
	case BASINS:
		result = resultImage.duplicate();
		result.setTitle( title + "-catchment-basins" + ext );
		break;
	case OVERLAID_DAMS:
		result = getWatershedLines( resultImage );
		result = ColorImages.binaryOverlay( displayImage, result, Color.red );
		result.setTitle( title + "-overlaid-dams" + ext );
		break;
	case LINES:
		result = getWatershedLines( resultImage );
		IJ.run( result, "Invert", "stack" );
		result.setTitle( title + "-watershed-lines" + ext );
		break;
	}

	return result;
}
 
Example #22
Source File: EquivalentEllipsePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static final void addRoiToOverlay(Overlay overlay, Roi roi, Color color)
{
	roi.setStrokeColor(color);
	overlay.add(roi);
}
 
Example #23
Source File: Path.java    From SNT with GNU General Public License v3.0 4 votes vote down vote up
public void drawPathAsPoints(final Overlay overlay) {
	drawPathAsPoints(overlay, ThreePanes.XY_PLANE);
}
 
Example #24
Source File: SingleWindowDisplay.java    From Colocalisation_Analysis with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the passed ImageResult on the ImagePlus of this class. If the image
 * is part of a CompositeImageResult then contained lines will also be drawn
 */
protected void drawImage(RandomAccessibleInterval<? extends RealType<?>> img) {
	// get ImgLib image as ImageJ image
	imp = ImageJFunctions.wrapFloat((RandomAccessibleInterval<T>) img, "TODO");
	imagePanel.updateImage(imp);
	// set the display range

	// check if a LUT should be applied
	if (listOfLUTs.containsKey(img)) {
		// select linked look up table
		IJ.run(imp, listOfLUTs.get(img), null);
	}
	imp.getProcessor().resetMinAndMax();

	boolean overlayModified = false;
	Overlay overlay = new Overlay();

	// if it is the 2d histogram, we want to show the regression line
	if (isHistogram(img)) {
		Histogram2D<T> histogram = mapOf2DHistograms.get(img);
		/*
		 * check if we should draw a regression line for the current
		 * histogram.
		 */
		if (histogram.getDrawingSettings().contains(Histogram2D.DrawingFlags.RegressionLine)) {
			AutoThresholdRegression<T> autoThreshold = dataContainer.getAutoThreshold();
			if (histogram != null && autoThreshold != null) {
				if (img == histogram.getPlotImage()) {
					drawLine(overlay, img, autoThreshold.getAutoThresholdSlope(),
							autoThreshold.getAutoThresholdIntercept());
					overlayModified = true;
				}
			}
		}
	}

	if (overlayModified) {
		overlay.setStrokeColor(java.awt.Color.WHITE);
		imp.setOverlay(overlay);
	}

	imagePanel.repaint();
}
 
Example #25
Source File: SingleWindowDisplay.java    From Colocalisation_Analysis with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the line on the overlay.
 */
protected void drawLine(Overlay overlay, RandomAccessibleInterval<? extends RealType<?>> img, double slope,
		double intercept) {
	double startX, startY, endX, endY;
	long imgWidth = img.dimension(0);
	long imgHeight = img.dimension(1);
	/*
	 * since we want to draw the line over the whole image we can directly
	 * use screen coordinates for x values.
	 */
	startX = 0.0;
	endX = imgWidth;

	// check if we can get some exta information for drawing
	if (isHistogram(img)) {
		Histogram2D<T> histogram = mapOf2DHistograms.get(img);
		// get calibrated start y coordinates
		double calibratedStartY = slope * histogram.getXMin() + intercept;
		double calibratedEndY = slope * histogram.getXMax() + intercept;
		// convert calibrated coordinates to screen coordinates
		startY = calibratedStartY * histogram.getYBinWidth();
		endY = calibratedEndY * histogram.getYBinWidth();
	} else {
		startY = slope * startX + intercept;
		endY = slope * endX + intercept;
	}

	/*
	 * since the screen origin is in the top left of the image, we need to
	 * x-mirror our line
	 */
	startY = (imgHeight - 1) - startY;
	endY = (imgHeight - 1) - endY;
	// create the line ROI and add it to the overlay
	Line lineROI = new Line(startX, startY, endX, endY);
	/*
	 * Set drawing width of line to one, in case it has been changed
	 * globally.
	 */
	lineROI.setStrokeWidth(1.0f);
	overlay.add(lineROI);
}