title
resume   publication   project   teaching   programming
  | Radiance Registry Key | Radiance (.pic) RGBE Format | Solaris Applet | Eclipse C/C++ | Somfy E+ Files |
 
Radiance (.pic) RGBE Picture File Format

What is it?

The Radiance RGBE (.pic) picture file format by Greg Ward stores pixels in 32 bits (4 bytes), with 1 bytes (0-255) for each color (red, green, and blue) channel and 1 byte for a shared exponent.
High Dynamic Range Image Encodings - Section "Radiance RGBE Encoding (HDR)" summarizes advantages and limitations.

Syntax
Sample .pic file generated by Radiance. Extension (.txt) appended for viewing in browser.

1. Header

• ASCII information header, begins with the line "#?RADIANCE"
• Lines describing commands used to generate the file, should include FORMAT=32-bit_rle_rgbe or FORMAT=32-bit_rle_xyze
• Pixels values must be divided by EXPOSURE or COLORCORR floats, if present
• Header Information terminated by an empty line

2. Resolution String

• Line describing resolution and pixel scanning order, -Y M +X N. See reference for more options.

3. Scanline Records

• Data can be either i) uncompressed, ii) old run-length encoded or iii) new run-length encoded.
• If format is RGB, units for each primary is spectral radiance (watt/steradian/sq.meter). e.g. Pixel value of (1,1,1) => total energy of 1 watt/steradian/sq.meter over visible spectrum.

Actual luminance (lumens/steradian/sq.meter):    luminance = 179 * (0.265*R + 0.670*G + 0.065*B)

Syntax for iii) new run-length encoded data

• X (height) number of scanline records listed in order
• # Each scanline record begins with 2 bytes equal to 2
• Next 2 bytes are the upper and lower btyes of scanline length, effectively using 15 bits to represent scanline length (2 x 8 bits minus 1 sign bit, ie. max length = 32767 or 0111 1111 1111 1111 i.e. 7F FF as 2 bytes).
• Next are 4 consecutive sets of listings for the r,g,b & e component values
• Byte pairs of Count and Values
When count is positive, it is a Dump, the indicated number of following values are dumped
When count is negative, it is a Run, the following value is repeated for the absolute nuber of times.
   e.g. hex record of the 6 btyes 03 85 89 87 85 88 ==> (85, 89, 87, 88, 88, 88, 88, 88)
   (03) means next 3 values (85, 89, 87) are to be dumped, then (85, -5 in decimal) means (88) is to be repeated 5 times.
   In decimal, the encodeded hex record 03 85 89 87 85 88 ==> (133, 137, 135, 136, 136, 136, 136, 136)

Documentation
Existing Code Implementations

Java Implementation

rgbe.java
Javadoc for documentation on usage

Implementation in Java of a rgbe class to parse .pic file with Run-Length Encoded data. The class allows easy access of the pixel information and translates the R, G & B components back to spectral radiance values (watt/steradian/sq.meter).

THIS CODE CARRIES NO GUARANTEE OF ANY KIND FOR ANY PURPOSE. USE STRICTLY AT YOUR OWN RISK.
Copyright (C) 2007 Yi Chun Huang. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Sample Usage

  • String path = "C:/Documents and Settings/yj/Desktop/test4_1 G.pic";    //path of the .pic file to be parsed
  • rgbe data = new rgbe();   //initializes a new rgbe object
  • data.parseFile(path);   //parses the .pic file as described by path
      the usage      if ( data.parseFile(path)!=1 )       can be used to catch the situation when the parse is unsuccessful.
  • float[] values = data.getImageData();   //the spectral radiance values are retrieved and stored in the float[] values

Run test.java (files here)
Line 9 in test.java is the path of the input .pic file, change this accordingly.
The .pic file is parsed and displayed in a JPanel. Note that all auxillary java files, including DrawingPanel.java are works-in-progress, use at your own risk.

Stuff
Updated 19 March 2007, YC Huang.
Back to Radiance RGBE Format