Raster Images in IDL - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Raster Images in IDL

Description:

NTSG, Univ. of MT. Outline. Review of topics from last time. Dimensioning two-dimensional data types. Reading in raster data ... variable you read using tvrd ... – PowerPoint PPT presentation

Number of Views:701
Avg rating:3.0/5.0
Slides: 18
Provided by: ntsg6
Category:
Tags: idl | images | mt | raster

less

Transcript and Presenter's Notes

Title: Raster Images in IDL


1
Raster Images in IDL
  • Matt Jolly
  • NTSG, Univ. of MT.

2
Outline
  • Review of topics from last time
  • Dimensioning two-dimensional data types
  • Reading in raster data
  • Focusing on reading binary images
  • Displaying images in IDL
  • Writing images as graphic files

3
Review
  • Data types define the type of information stored
    in a variable
  • Floats store decimal values
  • Integers store whole numbers
  • Files are read into IDL variables using the OPEN
    and READ commands
  • Procedure for reading data OPEN, READ, CLOSE

4
Procedure for reading rasters into IDL
  • Dimension the raster variable
  • Open the file containing the image of interest
  • Read the information from the file into the
    variable
  • Close the file
  • Use the variable for display or analysis

5
What you need to know ahead of time
  • The rows and columns of the image to read in
  • The data type of the image
  • Remember, sometimes if you dont know the data
    type you can figure it out
  • Filesize rows columns number of bytes

6
Dimensioning the variable
  • As discussed in our last meeting, data types
    should be determined from the type of information
    being read in
  • Use the appropriate array dimensioning function
  • Normally intarr(x,y), bytarr(x,y), fltarr(x,y)
    or dblarr(x,y)
  • MyVar intarr(573,361) (columns,rows)

7
Opening the file
  • Use the OPENR command to open the file
  • OPENR, 1, dialog_pickfile()
  • OPENR,lun,pickfile(),/get_lun

8
Read the file as binary
  • Read using the unformatted read command
  • READU,1,MyVar
  • MyVar is the variable you intialized earlier
  • Once you have read from the file, close it!
  • Close,1
  • Free_lun, lun

9
Color tables in IDL
  • Before displaying a color image in IDL, you
    should set the decompose state to zero and load a
    color table
  • Device, decompose0
  • Loadct, ltcolor table numbergt OR
  • Xloadct to select your color table

10
Indexing in IDL
  • Cartesian coordinates are always based from the
    lower left corner
  • Images usually start from the upper left corner
  • You can switch the origin in IDL
  • Tvscl,MyVar,/Order
  • /Order tells IDL to plot using the upper left
    corner as the origin
  • Or do it for all images by setting the system
    variable
  • !order1

11
Displaying your newly read image
  • Create a new window first
  • Window, xsizeltxgt, ysizeltygt
  • Where ltxgt is the x dimension of the data and ltygt
    is the y dimension of the data
  • Use the TVSCL command in most cases
  • This command commands byte-scaling and display
    into a single function
  • Tvscl, MyVar
  • Or you can combine the TV command with the bytscl
    function
  • tv,bytscl(ltMyVargt,min0,max5000)

12
  • !order1
  • !order0

(0,0)
(0,0)
13
Writing a JPEG of your image
  • Read the true color values into an array
  • Use the Write_Jpeg function

14
Reading the true color values into an array
  • The display colors must be read in true color
    (I.E. R,G,B)
  • Outimg tvrd(true1)

15
Writing a JPEG
  • Use the write_jpeg function
  • Write_jpeg,ltfilenamegt,ltoutimggt, true1,quality
    100,/order
  • ltfilenamegt is the output filename (you can use
    pickfile() here to select your own filename)
  • ltoutimggt is the true color image variable you
    read using tvrd()
  • True1 tells IDL to treat the variable as a true
    color image (RGB)
  • Quality 100 tells IDL not to compress the image
    (Low loss)
  • /Order is the same as earlier

16
Example
  • Data intarr(890,561)
  • Openr,1,pickfile()
  • Readu,1,data
  • Close,1
  • Device,decompose0
  • Loadct,5
  • Window,xsize890,ysize561
  • Tv,bytscl(data,min0)
  • Imgtvrd(true1)
  • Write_jpeg,c\temp\img.jpeg,img,true1,quality1
    00,/order

17
Your task Make this image
Write a Comment
User Comments (0)
About PowerShow.com