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.
 |
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) |
|
- Ward Larson, Greg, and Rob A. Shakespeare. 1998. Rendering with Radiance: The Art and Science of Lighting Visualization. San Francisco CA: Morgan Kaufmann Publishers.
Chapter 18 available online only. Main documentation on syntax, no details on encoding.
- Ward, Greg. 1991. Real Pixels. In James Arvo Ed., Graphic Gems II, Chapter 11.5, pp.80-83. Cambridge MA: AP Professional.
Primary source of RGBE idea, no mention on syntax
- LBNL Radiance Documentation
Explanation of header, mentions scanline compression, refers to color.c
- Reinhard, Erik, Greg Ward, Sumanta Pattanaik, and Paul Debevec. 2006. High Dynamic Range Imaging: Acquisition, Display and Image-based Lighting. San Francisco CA: Morgan Kaufmann Publishers.
Math for conversions from floats to 3-mantissa to 3X8 bit with shared component
- Glassner, S. Andrew. 1991. Adaptive Run-length Encoding. In James Arvo Ed., Graphic Gems II, Chapter 11.8, pp.89-92. Cambridge MA: AP Professional.
Reference for new run-length encoded (3rd type) data in .pic format
| Existing Code Implementations |
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. |
|
|