Text on Image Plugin (no Marco)

Hello, i have to put a Text on a Picture. I already programmed a dialog to insert a text, but i dont know how to show this text on the picture. Can you help me?

My idea is a Textlabel. The inserted text comes into the label and i want to set the label to visible. But the text isnt shown/visible.

1 Like

Depending on whether you want to:

  • have a non-destructive text overlay, or
  • “burn” the text into the pixel data of the image,

you can use one of the following:

  • create a TextRoi, put it into an Overlay (with addRoi(textRoi)), and update your ImagePlus (with setOverlay(overlay)) to show the overlay, or
  • use the drawString method in ImageProcessor.

Hope that helps.


Thank you :slight_smile: i will try it. For my project the Overlay should be the better solution, because the “burn”-method isnt accepted :smiley:
i will keep you updated

ImageProcessor doesn’t allow “show”. You need to create an ImagePlus. Try to understand the idea of ImageProcessor and ImagePlus and consult the API-docs.

1 Like

ImageProcessor doesn’t allow “setOverlay” in the way you expect.

1 Like

Ah okay i got it, thanks.

    ImagePlus implm = new ImagePlus("", ip);