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

Home » Public Forums » archive » Re: Another IDL twist
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: Another IDL twist [message #18277] Fri, 17 December 1999 00:00
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Ben Tupper wrote:
> I don't know why, but I do know it drove me bananas. I wrote the
> following as a wrapper for most of the READ_* procedures. It is in the
> form of a FUNCTION rather than PROCEDURE. I've only tried it on TIFF,
> JPEG and GIF so far. If you try and have suggestions, please send them
> along.

I'm guessing that most people who read TIFF, JPEG, and GIF images from
disk actually want to *display* the images in IDL. Hence, I wrote a
procedure which makes it rather easy.

SHOWIMAGE displays images in GIF, BMP, PICT, TIFF, or JPEG format (the
format is detected automatically), e.g.

IDL> file = filepath('rose.jpg', subdir='examples/data')
IDL> showimage, file

Check it out at:
http://cimss.ssec.wisc.edu/~gumley/imagetools.html

Note that IDL 5.2 is required, to allow automatic detection of image
format (i.e. the query_gif, query_bmp etc. functions in IDL 5.2 are
used).

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
Re: Another IDL twist [message #18278 is a reply to message #18277] Fri, 17 December 1999 00:00 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
edward.s.meinel@aero.org wrote:

> Does anyone know the rhyme or reason for the calling methods for the
> built-in IDL READ_* procedures? Sometimes it is:
>

I don't know why, but I do know it drove me bananas. I wrote the
following as a wrapper for most of the READ_* procedures. It is in the
form of a FUNCTION rather than PROCEDURE. I've only tried it on TIFF,
JPEG and GIF so far. If you try and have suggestions, please send them
along.

Thanks,

Ben


;+
; NAME:
; ReadImage
;
; PURPOSE:
; This function returns the 2 or 3 plane image specified by the file
keyword.
; The utility of this function is that the user doesn't need to remember
which
; image reading procedures are actually fumctions. The user can
optionally
; query the image only, or return the query structure and the image.
The _extra
; keyword is applied each of the apllicable image input procedures that
have keywords.
;
; CATEGORY:
; Input/Output
;
; CALLING SEQUENCE:
; Result = ReadImage()
;
;
; INPUTS:
; All inputs are optional keywords. If file is not specified the user
is prompted to selected one
;
;
; KEYWORD PARAMETERS:
; File: A string specifying the location of the image. If not provided,
the user
; is prompted to select a file.
; Query: Set this keyword to a named vaiable that, on output, will
contain the info
; structure retruned from the QUERY_IMAGE fucntion.
; JustQuery: Set this keyword to a non zero scalar to simply return the
Query structure.
; In this case, Image is returned as -1.
; Red, Green ,Blue: Set these keywords to named variables that, on
output, contain
; the red, green and blue color vectors stored with the image. If the
image
; has no color vectors stored these values are undefined.
; ColorTable: Set this keyword to a named varaible that, on output
contains the
; the 3,n color table array. This feature is available for JPEG images
only. If the image
; have a defined colortable stored, this value is undefined.
; _Extra: This keyword allows the user to set any of the many different
keywords
; for each image type. See documentation fpor each image type for
keywords
; that can be passed.
; Cancel: This keyword is set to 1 if the user cancels the
dialog_pickfile prompted, it is set to
; 0 (zero) otherwise.
;
; OUTPUTS:
; The ReadImage function returns the image specified by the file
keyword. If the JUSTQUERY
; keyword is set, the user cancels the Dialog_PickFIle prompted, or an
error occurs then
; the fucntion returns -1.
;
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None known.
;
; RESTRICTIONS:
; Requires the function ParseFileName.
;
; EXAMPLE:
; The following returns the image 'c:/images/image.tif', the red, green,
and blue
; color tables associated with the image (if any.) Also returned are
the GeoTiff structure
; (if the image is GeoTiff format) and the Info Structure returned by
the
; function QUERY_TIFF.
;
; Result = ReadImage( File='c:/images/image.tif', Red = Red, Green =
Green, Blue = Blue,$
; Query= Query, GeoTiff = GeoTiff)
;
; MODIFICATION HISTORY:
; Written by: Ben Tupper 26 SEP 99
; Pemaqid River Company
; email pemaquidriver@tidewater.net
; tel: (207) 563 - 1048
; 248 Lower Round Pond Road
; POB 106
; Bristol, ME 04539-0106
;
;
;-




FUNCTION ReadImage, File=File, $
Query = Query, _Extra = _Extra, $
Red=Red, Green = Green, Blue = Blue, ColorTable = ColorTable,$
JustQuery = JustQuery, cancel = cancel

Image = -1
Query = -1
Cancel = 1

If n_elements(JustQuery) EQ 0 Then JustQuery = 0
if n_elements(File) EQ 0 Then File = Dialog_PickFile()

if File EQ '' Then Begin
Return, Image
EndIf



FileName = StrLowCase(ParseFileName(File[0]))

Extension = FileName[2]

Case Extension of

'bmp': Result = Query_BMP(File, Query)
'dcm': Result = Query_DICOM(File, Query)
'gif': Result = Query_GIF(FIle, Query)
'jpg': Result = Query_JPEG(File,Query)
'pic': Result = Query_PICT(FIle, Query)
'png': Result = Query_PNG(FIle, Query)
'ppm': Result = Query_PPM(File,Query)
'pgm': Result = Query_PPM(File,Query)
'srf': Result = Query_SRF(File, Query)
'tif': Result = Query_TIFF(File,Query)

EndCase

If Result EQ 0 Then Return, Image

Cancel = 0

If (JustQuery NE 0) Then Begin
Return, Image
EndIf


Case Extension of

'bmp': Image = Read_BMP(File, Red, Green, Blue,Ihdr,_Extra = _Extra)
'dcm': Image = Read_DICOM(File, Red,Green,Blue, _Extra=_Extra)
'gif': Read_GIF,FIle, Image, Red,Green,Blue, _Extra=_Extra
'jpg': Read_JPEG,File,Image, ColorTable, _Extra=_Extra
'pic': Read_PICT, FIle, Image, Red, Green, Blue
'png': Image = Read_PNG(FIle, Red, Green, Blue, _Extra=_Extra)
'ppm': Read_PPM, File,Image, _Extra=_Extra
'pgm': Read_PPM, File,Image, _Extra=_Extra
'srf': Read_SRF, File, Image, Red, Green, Blue
'tif': Image = Read_TIFF(File,Red, Green, Blue, _Extra=_Extra)

EndCase

Cancel = 0

Return, Image

End


--
Ben Tupper
Pemaquid River Company
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Z-range
Next Topic: Re: widget fonts

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

Current Time: Wed Oct 08 13:48:16 PDT 2025

Total time taken to generate the page: 0.00373 seconds