Overlay over imageplus

imageplus
overlay
imagej
Tags: #<Tag:0x00007fd541dc0c30> #<Tag:0x00007fd541dc0af0> #<Tag:0x00007fd541dc0988>

#1

i am trying to overlay text on specific image in imagePlus(of stack of 30 images), but didn’t getting any label over the image

     ImagePlus t= IJ.openImage("/home/mg/Downloads/tifs/image.tif");
		 Font font = new Font("Arial", Font.PLAIN, 30);
		 Roi textRoi = new TextRoi(0, 0, "ss", font);
		 textRoi.setStrokeColor(Color.RED);                         //Set the color of the overlay text to white
		 textRoi.setNonScalable(true);                                 //Don’t zoom the overlay text when zooming the image window
		 Overlay overlay = new Overlay(textRoi);
		 t.getStack().getProcessor(1).setOverlay(overlay);
                 t.show(); //it doesn't show overlay label text on image.

#2

Instead of the above, try:

t.setPosition(1, 1, 1);
t.setOverlay(overlay);

#3

It doesn’t work for me while doing
t.setPosition(1, 1, 1);
t.setOverlay(overlay); //it basically apply overlay on all images of the imageStack, but i want at a specific image.


#4

You might have to set the ROI position with setPosition before adding it to the overlay:

textroi.setPosition(1,1,1)

as an ImagePlus can only have a single Overlay, but each Overlay can contain many Rois.


#5

You have to set explicitly that you want to see the labels:

overlay.drawLabels(true); // allow labels
overlay.drawNames(true); // replace numbers with names