Display Binary Data
If your image data is in a nonstandard image format, you can use the READ_BINARY routine to read binary information from the file.
Example 1 - Binary Data
The following example reads byte data out of the file nyny.dat in IDL's examples/data subdirectory into an IDL variable named nyny.
The code shown below creates the graphic shown above. You can copy the entire block and paste it into the IDL command line to run it.
file = FILEPATH('nyny.dat', $
SUBDIRECTORY = ['examples', 'data'])
nyny = READ_BINARY(file, DATA_DIMS = [768, 512])
im = IMAGE(nyny, RGB_TABLE=36)
Example 2 - Regular-Grid Data
Regular-grid data points are presented by two-dimensional arrays. The following example shows one way of importing and displaying this type of data. The 248-by-248 two-dimensional array contained within the convec.dat binary file in the examples/data directory is imported into IDL with the READ_BINARY function. The image function then displays this data as an image.
The code shown below creates the graphic shown above. You can copy the entire block and paste it into the IDL command line to run it.
file = FILEPATH('convec.dat', $
SUBDIRECTORY = ['examples', 'data'])
data = READ_BINARY(file, DATA_DIMS = [248, 248])
IM = IMAGE(data)
Example 3 - Assign an RGB Table
This example uses the surface.dat example data, which is elevation data from the Maroon Bells mountain range in Colorado, USA. This data is stored as integer data in a binary file.
The code shown below creates the graphic shown above. You can copy the entire block and paste it into the IDL command line to run it.
file = FILEPATH('surface.dat', $
SUBDIRECTORY = ['examples', 'data'])
mbells = READ_BINARY(file, DATA_DIMS = [350, 450])
IM = IMAGE(mbells, rgb_table=6)
Property Used in the Example
- RGB_TABLE - defines the color table used to display the image. If no color table is defined, this image displays in gray scale.
Resources