A Novel Approach to Spectral MRI
Tiffany A. Fetzner

Appendix E: IDL  code for  reading raw data images

PRO Read_skw_image

;read in raw data (rho.skw) image

 dimage=READ_SKW(PICKFILE(FILTER='*.skw')) ; read raw data (skw) file
 
; display image in display image space
 tv,dimage

END
 

IDL procedure code to read raw data (*.SKW)  images
 

FUNCTION READ_SKW, file_name

; read in SKW image and return image as an array of floats in the range of 0 to 255

OPENR, rho, file_name, /get_lun  ; open file as 'rho'
 file_stats = FSTAT(rho)  ; get file info
 width = ((2)^(FIX( ALOG( SQRT( file_stats.SIZE / 2 ) )/  ALOG(2) )))
     ; determine image size
 temp = intarr(width,width) ; create a 256x256 integer array 'temp'
 readu, rho, temp  ; read 'rho' into array 'temp'
;IF Mac and Unix architecture:
;
; simage=swap_endian(temp) ; swap endian of 'temp' into SKW image space:
;ELSE (for intel architecture)
 simage=temp  ; don't swap endian... just re-assign variable to
     ; different name.
;END architecture specific code.
     ; 0=black;4095=white
 close, rho   ; close 'rho'
 free_lun, rho   ; deallocate 'rho'
 dimage = FLOAT(simage)/16 ; convert SKW image space to display image
     ; space:  0=black;255=white

 RETURN, dimage
END

Table of Contents | Appendix  | Thesis