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

Home » Public Forums » archive » Image question.
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
Image question. [message #2909] Wed, 12 October 1994 09:20 Go to next message
pvemulakonda is currently offline  pvemulakonda
Messages: 5
Registered: September 1994
Junior Member
How can I read an image on the screen into an integer array and store it as
a data file (im.dat) consisting of integer data. Plz somebody help me with
this.

Thanks.
Re: Image question. [message #2969 is a reply to message #2909] Fri, 14 October 1994 09:17 Go to previous message
8015 is currently offline  8015
Messages: 52
Registered: November 1993
Member
In article <37jsf9$k4n@reznor.larc.nasa.gov>,
Joseph M Zawodny <zawodny@arbd0.larc.nasa.gov> wrote:
> In article <37jkfp$l7p@hacgate2.hac.com> 8015@sbsun0010.sbrc.hac.com (Mike Schienle) writes:

< a lot of steps deleted >

>>
>> Mike Schienle
>
> Sure this works, but why do so much work when the following will suffice:
>

< fewer steps deleted >

I can think of two reasons:

1) I get paid by each line of code I write.
2) I didn't think of doing it the much simpler way you presented.

One of these reasons is correct. The other is wishful thinking.

Thanks,

Mike Schienle Hughes Santa Barbara Research Center
8015@sbsun0010.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
Re: Image question. [message #2983 is a reply to message #2909] Fri, 14 October 1994 08:59 Go to previous message
amaravad is currently offline  amaravad
Messages: 11
Registered: September 1994
Junior Member
In article <1994Oct12.112035.26360@msuvx1.memphis.edu> pvemulakonda@cc.memphis.edu (PAVAN VEMULAKONDA) writes:
> How can I read an image on the screen into an integer array and store it as
> a data file (im.dat) consisting of integer data. Plz somebody help me with
> this.
>
> Thanks.

You can use IDL's TVRD function. The following code may work.

result = tvrd()
result=fix(result)
openw, 1, 'im.dat'
writeu, 1,result

Any comments welcome.


Ratnakar Amaravadi Software/Hardware Engineer
Division of Imaging Sciences PET Research Program
Department of Radiology I.U. School of Medicine
Indianapolis IN 46202

Ph. : (317)274-1843 (w) amaravad@indiana.edu
(317)274-4074 (fax) amaravad@silver.ucs.indiana.edu
(317)632-5144 (h) ratty@foyt.indyrad.iupui.edu
--
Ratnakar Amaravadi Software/Hardware Engineer
Division of Imaging Sciences PET Research Program
Department of Radiology I.U. School of Medicine
Indianapolis IN 46202
Re: Image question. [message #2989 is a reply to message #2909] Thu, 13 October 1994 08:41 Go to previous message
8015 is currently offline  8015
Messages: 52
Registered: November 1993
Member
In article <1994Oct12.112035.26360@msuvx1.memphis.edu>,
PAVAN VEMULAKONDA <pvemulakonda@cc.memphis.edu> wrote:
> How can I read an image on the screen into an integer array and store it as
> a data file (im.dat) consisting of integer data. Plz somebody help me with
> this.
>
> Thanks.

If the image is already on the display, use the the TVRD() function.
Something like:

IDL> image = tvrd() ; options for size and 24-bit may be included here
IDL> s = size(image) ; get the size of the image array
IDL> intimage = intarr(s(1), s(2)) ; create an int array using sizes
The '*' below allow you to fill the intimage array rather than recreate it
IDL> intimage(*,*) = image(*,*)
IDL> openw, lun, 'im.dat', /get_lun ; open the output file
IDL> writeu, lun, intimage ; write the image to the output file
IDL> free_lun, lun ; free the lun

Mike Schienle Hughes Santa Barbara Research Center
8015@sbsun0010.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
Re: Image question. [message #2990 is a reply to message #2909] Thu, 13 October 1994 17:57 Go to previous message
rob is currently offline  rob
Messages: 10
Registered: July 1991
Junior Member
:Sure this works, but why do so much work when the following will suffice:
[...]
:IDL> close,lun ; close the output file
:IDL> free_lun, lun ; free the lun

Furthermore, the CLOSE is redundant, as FREE_LUN does it.
Re: Image question. [message #2991 is a reply to message #2989] Thu, 13 October 1994 10:58 Go to previous message
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In article <37jkfp$l7p@hacgate2.hac.com> 8015@sbsun0010.sbrc.hac.com (Mike Schienle) writes:
> In article <1994Oct12.112035.26360@msuvx1.memphis.edu>,
> PAVAN VEMULAKONDA <pvemulakonda@cc.memphis.edu> wrote:
>> How can I read an image on the screen into an integer array and store it as
>> a data file (im.dat) consisting of integer data. Plz somebody help me with
>> this.
>>
>> Thanks.
>
> If the image is already on the display, use the the TVRD() function.
> Something like:
>
> IDL> image = tvrd() ; options for size and 24-bit may be included here
> IDL> s = size(image) ; get the size of the image array
> IDL> intimage = intarr(s(1), s(2)) ; create an int array using sizes
> The '*' below allow you to fill the intimage array rather than recreate it
> IDL> intimage(*,*) = image(*,*)
> IDL> openw, lun, 'im.dat', /get_lun ; open the output file
> IDL> writeu, lun, intimage ; write the image to the output file
> IDL> free_lun, lun ; free the lun
>
> Mike Schienle

Sure this works, but why do so much work when the following will suffice:

IDL> openw, lun, 'im.dat', /get_lun ; open the output file
IDL> writeu, lun, fix(tvrd()) ; write the image to the output file
IDL> close,lun ; close the output file
IDL> free_lun, lun ; free the lun

--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: zawodny@arbd0.larc.nasa.gov MS-475, Hampton VA, 23681-0001
TCP/IP: ko4lw@ko4lw.ampr.org Packet: ko4lw@n4hog.va.usa
Re: Image question. [message #2992 is a reply to message #2909] Fri, 14 October 1994 08:59 Go to previous message
ratnakar amaravadi is currently offline  ratnakar amaravadi
Messages: 14
Registered: April 1994
Junior Member
In article <1994Oct12.112035.26360@msuvx1.memphis.edu> pvemulakonda@cc.memphis.edu (PAVAN VEMULAKONDA) writes:
> How can I read an image on the screen into an integer array and store it as
> a data file (im.dat) consisting of integer data. Plz somebody help me with
> this.
>
> Thanks.

You can use IDL's TVRD function. The following code may work.

result = tvrd()
result=fix(result)
openw, 1, 'im.dat'
writeu, 1,result

Any comments welcome.


Ratnakar Amaravadi Software/Hardware Engineer
Division of Imaging Sciences PET Research Program
Department of Radiology I.U. School of Medicine
Indianapolis IN 46202

Ph. : (317)274-1843 (w) amaravad@indiana.edu
(317)274-4074 (fax) amaravad@silver.ucs.indiana.edu
(317)632-5144 (h) ratty@foyt.indyrad.iupui.edu
--
Ratnakar Amaravadi Software/Hardware Engineer
Division of Imaging Sciences PET Research Program
Department of Radiology I.U. School of Medicine
Indianapolis IN 46202
Re: Image question. [message #2996 is a reply to message #2909] Thu, 13 October 1994 06:40 Go to previous message
Geoff.Sobering is currently offline  Geoff.Sobering
Messages: 14
Registered: June 1994
Junior Member
In article <1994Oct12.112035.26360@msuvx1.memphis.edu>,
pvemulakonda@cc.memphis.edu (PAVAN VEMULAKONDA) wrote:

> How can I read an image on the screen into an integer array and store
> it as a data file (im.dat) consisting of integer data.

It is a two step process:

1) Copy the image on the screen (I assume in an IDL window) into an
array using 'tvrd' (p. 16-5 in my 3.1 "User's Guide").

2) Write the array to disk as unformatted data using 'writeu'
(p. 17-27 in the "User's Guide").

I use the following routine all the time for writing "raw" binary files:

PRO wrbblk, filename, image_array

get_lun,unit ;get logical unit number
openw,unit,filename ;open file

writeu, unit, image_array

close,unit ;close file
free_lun,unit ;free logical unit number

RETURN
END

--
Geoff Sobering (Geoff.Sobering@nih.gov)
In Vivo NMR Research Center
National Institutes of Health
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: rounding function
Next Topic: Bug regarding plot limits when setting RANGE and TICKS

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

Current Time: Wed Oct 08 09:14:10 PDT 2025

Total time taken to generate the page: 0.00768 seconds