comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: annotated text without using graphics device in IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: annotated text without using graphics device in IDL? [message #35058] Wed, 07 May 2003 11:11
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
"Howard Taylor" <howard.taylor@jhuapl.edu> wrote in message
news:b9bfce$b5j$1@houston.jhuapl.edu...
> 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?

I don't think you can avoid having some sort of graphics device selected.

However you can use the Z-buffer graphics device which exists only in
memory, and does not require a graphics window:

ncol = 256
nrow = 256
a = dist(ncol, nrow)
entry_device = !d.name
set_plot, 'Z'
device, set_resolution=[ncol, nrow], set_colors=256, z_buffering=0
tv, bytscl(a)
xyouts,100,100, 'this text', /device
b = tvrd()
set_plot, entry_device

Note that the image was byte scaled since the Z-buffer is an 8-bit device.
Finally, you might get different character sizes in the Z-buffer compared to
a normal graphics window. To make sure the character sizes match, set the
character size explicitly in either case using a command like

device, set_character_size=[10, 12] ; width 10 pixels, height 12 pixels

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: annotated text without using graphics device in IDL? [message #35059 is a reply to message #35058] Wed, 07 May 2003 10:53 Go to previous message
David Fanning is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: annotated text without using graphics device in IDL?
Next Topic: decoding the JPEG format

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 09:14:19 PDT 2025

Total time taken to generate the page: 0.96216 seconds