Clearing text from image

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Clearing text from image

Douglas Benn-2
Could anybody please tell me if there is a simple way to clear a text string written as a label onto an image using drawString()  ? I tried writing the same string but with 0,0,0 as the color - I am assuming that is black. I cannot find a simple description of how overlay text is represented. I thought of importing the original image slice but this seems very clumsy so I expect there are easier ways. Also is there a description of different colors and their numeric representations?

Thank you.

Douglas

Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal College of Radiologists, England).
Professor
Dept of General Dentistry
Creighton University Dental School
2500 California Plaza
Omaha
Nebraska 68178

Tel: (402)280 5025
Fax: (402)280 5094
Reply | Threaded
Open this post in threaded view
|

Re: Clearing text from image

Rasband, Wayne (NIH/NIMH) [E]
On Mar 26, 2010, at 11:09 PM, Benn, Douglas K. wrote:

> Could anybody please tell me if there is a simple way to clear a text string written as a label onto an image using drawString()  ? I tried writing the same string but with 0,0,0 as the color - I am assuming that is black. I cannot find a simple description of how overlay text is represented. I thought of importing the original image slice but this seems very clumsy so I expect there are easier ways. Also is there a description of different colors and their numeric representations?

The drawString() macro function destructively renders the text onto the image. Use makeText() and the Image>Overlay>Add Selection command to display text using a non-destructive overlay. Here is a macro that displays "Hello" in red as an an overlay, clears it two seconds later, and two seconds after that displays "Goodbye" in green.

   requires("1.43p");
   makeText("Hello", 50, 50);
   run("Add Selection...", "stroke=red font=48 new");
   run("Select None");
   wait(2000);
   run("Hide Overlay");
   wait(2000);
   makeText("Goodbye", 50, 50);
   run("Add Selection...", "stroke=green font=48 new");
   run("Select None");

Another example is at

    http://rsbweb.nih.gov/ij/macros/examples/BlinkingText.txt

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Clearing text from image

Douglas Benn-2
Dear Wayne,

Thanks very much.

Douglas

Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal College of Radiologists, England).
Professor
Dept of General Dentistry
Creighton University Dental School
2500 California Plaza
Omaha
Nebraska 68178

Tel: (402)280 5025
Fax: (402)280 5094



-----Original Message-----
From: ImageJ Interest Group on behalf of Rasband, Wayne (NIH/NIMH) [E]
Sent: Fri 3/26/2010 11:39 PM
To: [hidden email]
Subject: Re: Clearing text from image
 
On Mar 26, 2010, at 11:09 PM, Benn, Douglas K. wrote:

> Could anybody please tell me if there is a simple way to clear a text string written as a label onto an image using drawString()  ? I tried writing the same string but with 0,0,0 as the color - I am assuming that is black. I cannot find a simple description of how overlay text is represented. I thought of importing the original image slice but this seems very clumsy so I expect there are easier ways. Also is there a description of different colors and their numeric representations?

The drawString() macro function destructively renders the text onto the image. Use makeText() and the Image>Overlay>Add Selection command to display text using a non-destructive overlay. Here is a macro that displays "Hello" in red as an an overlay, clears it two seconds later, and two seconds after that displays "Goodbye" in green.

   requires("1.43p");
   makeText("Hello", 50, 50);
   run("Add Selection...", "stroke=red font=48 new");
   run("Select None");
   wait(2000);
   run("Hide Overlay");
   wait(2000);
   makeText("Goodbye", 50, 50);
   run("Add Selection...", "stroke=green font=48 new");
   run("Select None");

Another example is at

    http://rsbweb.nih.gov/ij/macros/examples/BlinkingText.txt

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Clearing text from image

Douglas Benn-2
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Dear Wayne,

The makeText works fine. However, is it possible to write several labels on the same image which are all visible at the same time? Your two examples are not able to do this even though I experimented with them.

Thank you.

Douglas

Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal College of Radiologists, England).
Professor
Dept of General Dentistry
Creighton University Dental School
2500 California Plaza
Omaha
Nebraska 68178

Tel: (402)280 5025
Fax: (402)280 5094



-----Original Message-----
From: ImageJ Interest Group on behalf of Rasband, Wayne (NIH/NIMH) [E]
Sent: Fri 3/26/2010 11:39 PM
To: [hidden email]
Subject: Re: Clearing text from image
 
On Mar 26, 2010, at 11:09 PM, Benn, Douglas K. wrote:

> Could anybody please tell me if there is a simple way to clear a text string written as a label onto an image using drawString()  ? I tried writing the same string but with 0,0,0 as the color - I am assuming that is black. I cannot find a simple description of how overlay text is represented. I thought of importing the original image slice but this seems very clumsy so I expect there are easier ways. Also is there a description of different colors and their numeric representations?

The drawString() macro function destructively renders the text onto the image. Use makeText() and the Image>Overlay>Add Selection command to display text using a non-destructive overlay. Here is a macro that displays "Hello" in red as an an overlay, clears it two seconds later, and two seconds after that displays "Goodbye" in green.

   requires("1.43p");
   makeText("Hello", 50, 50);
   run("Add Selection...", "stroke=red font=48 new");
   run("Select None");
   wait(2000);
   run("Hide Overlay");
   wait(2000);
   makeText("Goodbye", 50, 50);
   run("Add Selection...", "stroke=green font=48 new");
   run("Select None");

Another example is at

    http://rsbweb.nih.gov/ij/macros/examples/BlinkingText.txt

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Clearing text from image

Rasband, Wayne (NIH/NIMH) [E]
On Mar 27, 2010, at 2:09 AM, Benn, Douglas K. wrote:

> Dear Wayne,
>
> The makeText works fine. However, is it possible to write several labels on the same image which are all visible at the same time? Your two examples are not able to do this even though I experimented with them.

The makeText() function will display multiple lines if you insert new line characters ('\n') into the text. And you can have the text from several makeText() calls visible at the same time as long as only the first is added to the overlay using the 'new' keyword ("New Overlay" option in Image>Overlay>Add Selection dialog).

Here is an example that adds two text selections (one red and the other green) to the overlay, waits four seconds, then hides the overlay.

   requires("1.43p");
   makeText("Here are two\nlines of text.", 50, 50);
   run("Add Selection...", "stroke=red font=24 new");
   makeText("Here are three\nlines of text in a \ndifferent color.", 50, 120);
   run("Add Selection...", "stroke=green font=24");
   run("Select None");
   wait(4000);
   run("Hide Overlay");

-wayne
 

>
> -----Original Message-----
> From: ImageJ Interest Group on behalf of Rasband, Wayne (NIH/NIMH) [E]
> Sent: Fri 3/26/2010 11:39 PM
> To: [hidden email]
> Subject: Re: Clearing text from image
>
> On Mar 26, 2010, at 11:09 PM, Benn, Douglas K. wrote:
>
>> Could anybody please tell me if there is a simple way to clear a text string written as a label onto an image using drawString()  ? I tried writing the same string but with 0,0,0 as the color - I am assuming that is black. I cannot find a simple description of how overlay text is represented. I thought of importing the original image slice but this seems very clumsy so I expect there are easier ways. Also is there a description of different colors and their numeric representations?
>
> The drawString() macro function destructively renders the text onto the image. Use makeText() and the Image>Overlay>Add Selection command to display text using a non-destructive overlay. Here is a macro that displays "Hello" in red as an an overlay, clears it two seconds later, and two seconds after that displays "Goodbye" in green.
>
>   requires("1.43p");
>   makeText("Hello", 50, 50);
>   run("Add Selection...", "stroke=red font=48 new");
>   run("Select None");
>   wait(2000);
>   run("Hide Overlay");
>   wait(2000);
>   makeText("Goodbye", 50, 50);
>   run("Add Selection...", "stroke=green font=48 new");
>   run("Select None");
>
> Another example is at
>
>    http://rsbweb.nih.gov/ij/macros/examples/BlinkingText.txt
>
> -wayne