Dear
ImageJ, I am writing a software application using
ImageJ. I have 3 requirements related with overlay. 1. Need to display ‘some text’ as overlay
in stack of images. 2. The overlay text should be non-scalable
while zooming-in or out. 3. when I flatten the image (for saving
purposes), I donot want the text overlay in the flattened image, but the the
text overlay should be visible in the display. (FYI: There
are other ROIs in the image that need to be flattened and I only don’t want the
text overlay) I have the following code snippet for
handling 1st and
2nd requirements: Font
font = new Font("Arial", Font.PLAIN, 10); Roi textRoi = new
TextRoi(0, 0, overlayText, font); textRoi.setStrokeColor(Color.white); //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); imp.setOverlay(overlay); But
the overlay is not getting displayed, but after adding the following 2 lines of
code, imp.getProcessor().setColor(Color.white); textRoi.drawPixels(imp.getProcessor()); the
overlay is displayed properly, but the color of the display is not white, it is
relative to the image pixel value. -
How can I make the text overlay always
display in white? -
When I zoom-in or out, the text overlay is
also zoomed. How can I avoid it? I
thought setNonScalable() should help, but text overlay gets zoomed too. For
requiremnt 3 (to remove the text overlay for flattening), I called 1.
imp.
setHideOverlay(true), 2.
then flattened the image and 3.
then again called imp. setHideOverlay(false), but
the flattened image still has the text overlay. I tried few other options, but with no success. My
apologies if the answer is straight forward and I failed to see them. Thanks
for your time and help. Vidya Vidya |
On Nov 17, 2011, at 9:28 PM, vidya wrote:
> Dear > ImageJ, > > I am writing a software application using > ImageJ. I have 3 requirements related with overlay. > > 1. Need to display ‘some text’ as overlay > in stack of images. > 2. The overlay text should be non-scalable > while zooming-in or out. > 3. when I flatten the image (for saving > purposes), I donot want the text overlay in the flattened image, but the the > text overlay should be visible in the display. (FYI: There > are other ROIs in the image that need to be flattened and I only don’t want the > text overlay) Here is JavaScript that displays non-scalable text and a rectangle as an overlay, then flattens the image without the text. To keep the text out of the flattened image, it removes the text from the overlay, flattens the image, then restores the text. imp = IJ.createImage("Untitled", "8-bit Black", 512, 512, 10); text = "this is a line of text"; font = new Font("Arial", Font.PLAIN, 10); textRoi = new TextRoi(10, 10, text, font); textRoi.setStrokeColor(Color.white); textRoi.setNonScalable(true); overlay = new Overlay(textRoi); rectangle = new Roi(0, 0, 120, 40, 10); rectangle.setStrokeColor(Color.white); overlay.add(rectangle); imp.setOverlay(overlay); imp.show(); overlay.remove(textRoi); imp2 = imp.flatten(); overlay.add(textRoi); imp2.show(); -wayne > I have the following code snippet for > handling 1st and > 2nd requirements: > > Font > font = newFont("Arial", Font.PLAIN, 10); > Roi textRoi = newTextRoi(0, 0, overlayText, font); > textRoi.setStrokeColor(Color.white); //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 = newOverlay(textRoi); > imp.setOverlay(overlay); > > But > the overlay is not getting displayed, but after adding the following 2 lines of > code, > > imp.getProcessor().setColor(Color.white); > textRoi.drawPixels(imp.getProcessor()); > > the > overlay is displayed properly, but the color of the display is not white, it is > relative to the image pixel value. > > - How can I make the text overlay always > display in white? > - When I zoom-in or out, the text overlay is > also zoomed. How can I avoid it? I > thought setNonScalable() should help, but text overlay gets zoomed too. > > For > requiremnt 3 (to remove the text overlay for flattening), I called > 1. imp. > setHideOverlay(true), > 2. then flattened the image and > 3. then again calledimp. setHideOverlay(false), > > but > the flattened image still has the text overlay. I tried few other options, but with no success. > > My > apologies if the answer is straight forward and I failed to see them. > > Thanks > for your time and help. > Vidya > Vidya > > -- > View this message in context: http://imagej.588099.n2.nabble.com/Text-Overlay-question-tp7006672p7006672.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Dear Wayne, Thank you very much for the answer. This part of java code works in case of single image, I face this problem when using ImageStack. Sorry if I have missed stating this clearly in my previous mail. My understanding on why it does not work in case of ImageStack is, while adding slices to the ImageStack, I am using addSlice(imageLabel, imp.getProcessor()); // This method is called inside a for loop for all the images that has to go into the ImageStack. So the Text overlay(s) which I set in the ImagePlus object(s) is not available within ImageStack. When using TextRoi.drawPixles(imp.getProcessor()), it draws the TextRoi in
the processor itself and there is no handle to the text overlay in the processor which I can later use to remove or add while flattening. Also I assume this is the reason for scaling not working (setNonScalable method) I am not sure if my understading is correct. I didnot find a way to add ImagePlus objects directly to ImageStack (I only saw methods that takes in imageprocessor). Is there a better way of handling this? Looks like I am missing something.. Thank you, vidya
|
Dear All,
The OME is hiring. We have several positions that we are looking to fill: - We have five software developer positions currently open. - We are also looking to create an OME support team and have three open positions for software specialists. For more information, please see the attached adverts for these positions. Please feel free to forward to anyone who you think might be interested. Best wishes, Emma -- Emma Hill PhD OME Project Manager Tel: 01382 388797 How to Apply: To apply on-line please visit: www.dundee.ac.uk/jobs. If you are unable to apply on-line please contact Human Resources on (01382) 386209 (answering machine) for an application pack. Please quote reference number LS0119, Please quote reference number LS0122. For informal inquiries, please email: Emma Hill ([hidden email]). |
Free forum by Nabble | Edit this page |