Image question. [message #2909] |
Wed, 12 October 1994 09:20  |
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 #2983 is a reply to message #2909] |
Fri, 14 October 1994 08:59  |
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  |
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  |
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  |
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  |
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  |
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
|
|
|