Hi,
I want to draw some text on an image. Right now I do: TR = TextRoi(0,0,'text') TR.setStrokeColor(Color.white); TR.setNonScalable(True); TR.drawPixels(ip) where ip is of type ShortProcessor. First of all, the text gets displayed in black, which is bad because we have a dark background. I also tried ip.drawRoi(TR), the text color just wont change. So how do I display 'text' in white ? Secondly, I actually try to annotate little image crops which are only 80x80 in pixel size. Is there a way to have a better resolution for the displayed text as the ImageProcessor natively has? The annotation looks pretty 80's style right now.. Regards, Greg |
Hi Greg,
(1) The drawing color for text is the current foreground color. You can modify it: Toolbar.setForegroundColor(java.awt.Color.WHITE); The foreground color value will be converted to a pixel value. Thus, if you change the range of pixel values mapped to the grayscale range between black and white (setMinAndMax of the ImageProcessor or Brightness&Contrast panel), the text may become gray. (2) For higher resolution, enlarge the image to a larger size, then draw with a larger font. For use inside ImageJ, i.e., if you do not need to export the image, it is easier to use an overlay instead of drawing the pixels. The overlay scales with the image and the text will always look nice. Michael ________________________________________________________________ On Jul 30, 2015, at 14:11, Greg wrote: > Hi, > > I want to draw some text on an image. Right now I do: > > TR = TextRoi(0,0,'text') > TR.setStrokeColor(Color.white); > TR.setNonScalable(True); > TR.drawPixels(ip) > > where ip is of type ShortProcessor. First of all, the text gets displayed in > black, which is bad because we have a dark background. I also tried > ip.drawRoi(TR), the text color just wont change. So how do I display 'text' > in white ? > > Secondly, I actually try to annotate little image crops which are only 80x80 > in pixel size. Is there a way to have a better resolution for the displayed > text as the ImageProcessor natively has? The annotation looks pretty 80's > style right now.. > > Regards, > Greg > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Drawing-Text-Rois-tp5013813.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
thx for your quick reply! Your first answer worked perfectly. I would like to apply the overlay method, isn't it possible to 'flatten' the image with the overlay on top for exporting? Anyways, how would I use overlays together with TextRois to have a higher resolution for the text? Best, Gregor |
On Jul 30, 2015, at 15:06, Greg wrote:
> I would like to apply the overlay method, isn't it possible to 'flatten' the > image with the overlay on top for exporting? Hi Greg, if you have a text overlay, you can flatten the image (Image>Overlay>Flatten), but that will be at a scale of 1, so you will get a pixelated font again. An alternative is displaying the image with a high zoom factor and using Plugins>Utilities>Capture Image, but it will only show the area currently visible at the screen. So it will depend on the location on the screen and the screen size whether you can display the full image like this, and probably it won't work at all for images that are not visible on the screen (I have never tried). Both 'Flatten' and 'Capture Image' will produce an RGB image, i.e. 8 bits per color channel (convert it to grayscale if you don't use color). If you start with 16-bit data, you will lose information. > Anyways, how would I use overlays together with TextRois to have a higher > resolution for the text? Overlays are just collections of ROIs. So you can add your TextRois to the overlay of the ImagePlus. For the API, see ij.gui.Overlay, ImagePlus.setOverlay, ImagePlus.getOverlay. Michael -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |