| Re: annotated text without using graphics device in IDL? [message #35059 is a reply to message #35058] |
Wed, 07 May 2003 10:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Howard Taylor (howard.taylor@jhuapl.edu) writes:
> I'd like to annotate an image without having to first draw the text on the
> active graphics display and then read the image back. This undesirable
> method might look like:
>
> a=indgen(256,256)
> tv,a
> xyouts,100,100,'this text',/device
> b=tvrd()
>
>
> Instead, I'd like an approach that doesnt rely on the graphics device at
> all. It might be called in this way:
>
> a=findgen(256,256)
> b = imgtext( a, 100,100,'this text' )
>
> As a result, b is an image whose contents have been altered to include the
> text.
>
> Anybody seen this sort of thing for IDL?
Here is the two minute version, written as I am leaving
the office to play tennis:
FUNCTION ImgText, image, xloc, yloc, text
s = Image_Dimensions(image, XSize=xs, YSize=ys)
oldWindow = !D.Window
Window, /Free, /Pixmap, XSize=xs, YSize=ys
TVImage, image, /TV
XYOutS, xloc, yloc, text, /Device
textImage = TVRead()
WDelete, !D.Window
IF oldWindow GE 0 THEN WSet, oldWindow
RETURN, textImage
END
You will need a couple of Coyote programs:
http://www.dfanning.com/image_dimensions.pro
http://www.dfanning.com/tvimage.pro
http://www.dfanning.com/tvread.pro
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|