next up previous contents
Next: Bytscling and Hist_equalising Up: Greyscale images Previous: Greyscale images   Contents

Reading an image

IDL>
read_jpeg,'~lecjm/public_html/Teaching/IDL_course/Data/200407101200_MSG1_EVEB70.jpeg',meteosat

This has read in a greyscale image from the file met.png and put it in a variable called Meteosat. If we do

 
IDL> help,meteosat
           BYTE      = Array[900, 900]
IDL> tv,meteosat ;image too big
IDL> meteosat=rebin(meteosat,450,450)      ;RESIZE
IDL> showimage,meteosat,win=2
;ADD A COLORBAR - DAVID FANNING'S ROUTINE - a continuous colourbar
IDL> colorbar,range=[0,255],title='Intensity',divisions=7

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro showimage,image,window=window
; A short procedure to display an image in a window the same size as
; the image. The program refuses to display an image which is
; uselessly small. This is important as opening a window 0 pixels wide
; causes IDL to hang up.

; the if not keyword_set() is really useful for setting defaults for keywords
if not keyword_set(window) ne 1 then window=0

;SIZE gives:n_dimensions, size_dim1, size_dim2, ... size_dimn
siz=size(image)
if(siz(1) gt 4  and siz(2) gt 4 ) then begin
    
    window,window,xsize=siz(1),ysize=siz(2)
    tv,image

endif else print,'Image too small'

end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



lecjm 2008-11-06