Showing posts with label ISIS. Show all posts
Showing posts with label ISIS. Show all posts

Thursday, December 18, 2014

What is the ISIS 3 cube format

ISIS 3 Cube Format - http://isis.astrogeology.usgs.gov/ or Wikipedia

Overview: ISIS (Integrated Software for Imaging Spectrometers) is a generalized software system that has been designed to optimize cartographic and scientific processing of images in planetary datasets. ISIS versions 2 and version 3 both have their own format called an ISIS cube which contains a label area and a data area. The label describes the data and uses a "keyword=value" text format. The label is normally embedded at the top of the file, but ISIS also supports "detached" labels where the label and image block are divided into separate files.

The data area is a 3-dimensional image with axis: samples, lines, and bands. Typically, the sample and line dimensions are used to represent spatial information while the band dimension represents spectral information. Pixels can be stored in 8-bit unsigned integer, 16-bit signed integer, or 32-bit floating-point format. When cubes are created in ISIS3, unless specifically specified, the file will be written using tiles (blocks of pixels). Tiles can be variable in size as defined in the label. In addition to valid numerical pixel values, five types of "special" pixel values are supported: null, high/low instrument saturation, and high/low representation saturation.

Type
Description
8bit Unsigned
16bit Signed
32bit Floating-Point
Null
Pixel has no data available
0
-32768
\xFF7FFFFB (-3.40282265508890445e+38)
Lis
Pixel lower bound was saturated on the instrument
0
-32767
\xFF7FFFFC
His
Pixel higher bound was saturated on the instrument
0
-32766
\xFF7FFFFD
Lrs
Pixel lower bound was saturated during processing
255
-32765
\xFF7FFFFE
Hrs
Pixel higher bound was saturated during processing
255
-32764
\xFF7FFFFF

Applications with read support for ISIS 3 cubes
  1. IsisDlm (ISIS IDL Interface Documentation) - http://www.astro.cornell.edu/~carcich/LRO/doc/html/main.html 
  2. Geospatial Data Abstraction Library (GDAL). http://www.gdal.org/, http://www.gdal.org/frmt_isis3.html 
  3.  Davinci (AZ State University) - http://davinci.asu.edu/index.php?title=ISIS3_I/O 

Simple command-line GDAL Conversion examples 
Examples:
$  gdal_translate –of GTiff input_32bit.cub output_32bit.tif
$  gdal_translate –of GTiff input_16bit.cub output_16bit.tif
$  gdal_translate –of GTiff input_8bit.cub output_8bit.tif
$  gdal_translate –of Jpeg –ot Byte –scale input.cub output_8bit.jpg
$  gdal_translate –of PNG –ot Byte –scale input.cub output_8bit.png





Figure 1. Illustration of an ISIS image cube, showing the three dimensions of an Isis image: width (samples), height (lines), and depth (bands).

Saturday, June 28, 2014

Using ISIS 2/3 image cubes in GIS software

Below contains recommended methods to directly use or convert ISIS 3 (and ISIS v2) into a well-formed GIS compatible format.
Recommended Rules of the Road:
  • Before ingesting any file (PDS, ISIS, other) into a GIS it should be map projected.
  • If file is to meant for visual purposes only (e.g. mapping on), it is highly recommended to stretch the images to 8bit (see below)
  • Don't use funky projections (e.g.; ISIS's oblique cylindrical)
  • Best to use positive East longitudes and a –180 to 180 longitude system.
  • For Longitude systems 180 or 360 it is highly recommended to:
    • if the set longitude system = 180 (-180 to 180), then set center longitude = 0 (or center of the image).
    • if the set longitude system = 360 (0 to 360), then set center longitude = 180 (or center of the image).
  • Don't use ISIS's method, isis2std, to convert files to Tiffs, Jpeg2000, Jpgs or PNGs. Why? It does not create a fully-formed GIS format with defined projection. It supports a GIS worldfile (simply the image registration in the current projected Cartesian plane) but not the projection definition.
  • Do use GDAL's tools, gdal_translate, to convert files from ISIS3 to one of many output formats (GeoTiff, GeoJpeg2000, Jpeg, PNG, ENVI, ect.).
Direct support: There is fairly good support for reading ISIS3 cubes (and version 2) files in the GDAL library. This means packages which use GDAL can usually read most map projected ISIS 2,3 and PDS files directly. This includes packages like QGIS, ArcMap GIS, Mirone, Saga GIS, Opticks, GRASS, and soon GMT, more). Since the GDAL reader only support one NoDATA value for 32bit and 16bit files there might be issues for the application to understand the valid data range. In this case, it is best to use stretch in ISIS to set the 5 supported special pixel values to valid or NoDATA (see below).
Conversion support: As stated above, I recommend using the GDAL utility application gdal_translate to convert from ISIS2, 3 or PDS format to another format for your application. Forth coming thread on GDAL tips for planetary data…
a few conversion examples:
  • gdal_translate –of GTiff input_32bit.cub output_32bit.tiff
  • gdal_translate –of GTiff input_16bit.cub output_16bit.tiff
  • gdal_translate –of GTiff input_8bit.cub output_8bit.tiff
  • gdal_translate –of Jpeg –ot Byte –scale input.cub output_8bit.jpg
  • gdal_translate –of Jp2kak –co quality=100 input_16bit.cub output_16bit.jp2
Conversion from 32bit to 8bit in ISIS before conversion:
My currently favorite method to convert to 8bit in ISIS (before using gdal to convert to geoTiff or GeoJpeg2000 or other format). I can't recommend the ISIS program bit2bit since it pushes valid data which is clipped into NoDATA (not good for viewing the image).

ISIS Stretch method 1:>stretch from=input.cub to=output_8bit.cub+8bit+1:254 USEPERCENTAGES=true pairs="0:1 100:254" null=0 lis=1 lrs=1 his=255 hrs=255
    This allows you to specify input percentages for the mapping pairs. Thus when
    USEPERCENTAGES=true is set pairs="0:1 100:254" means:
    map 0% to 1 (or the file's min value to 1) and 100% to 254 (file's max value).

ISIS Stretch method 2:This also means you can apply a recommended 0.5% clip to remove the potential extraneous lows and highs like:
>stretch from=input.cub to=output_8bit.cub+8bit+1:254 USEPERCENTAGES=true pairs="0:1 0.5:1 99.5:254 100:254" null=0 lis=1 lrs=1 his=255 hrs=255

Now once in an 8bit format convert to GeoTiff or other for easy and fast viewing. For huge files take advantage of BigTiff or Jpeg2000 lossy support
  • gdal_translate –ot GTiff –co Bigtiff=if_safer –co tiled=yes input_8bit.cub output_8bit.tif
  • gdal_translate –ot Jp2kak input_8bit.cub output_8bit.jp2

----simple example Csh Script to force output scale to 1 to 255.
mag{90}> more /usgs/cdev/contrib/bin/to8bit_gdal_tif.csh
Code: 
#!/bin/csh
#usage: to8bit_gdal_tif.csh input.ext output.tif
#Note the use of $3 in gdal_translate which just allows you to add in other options. By default it will just be blank.
set in=$1
set out=$2

set stats = `gdalinfo -stats $in > /tmp/xxxtemp_stats.junk`
set min = `cat /tmp/xxxtemp_stats.junk | grep MINIMUM | awk -F= '{print $2}' | sed 's/ //g'`
set max = `cat /tmp/xxxtemp_stats.junk | grep MAXIMUM | awk -F= '{print $2}' | sed 's/ //g'`

gdal_translate -ot byte -of GTIFF -co compress=lzw -ot Byte $3 -a_nodata 0 -scale $min $max 1 255 $in $out
/bin/rm -f /tmp/xxxtemp_stats.junk
 
-Trent