hdrexpo
hdrexpo is a simple Perl script for adjusting the exposure in HDR images. This is useful for adjusting the luminance values following a spot-meter calibration.
Prerequisites
- Perl
- Scripting language.
- pvalue, total and falsecolor
- Part of Radiance and only used for testing.
Overview
Below is the help output.
$ hdrexpo.pl --help Usage: hdrexp.pl factor original.hdr > modified.hdr
How it works
The Radiance HDR image format consists of a text header, followed by the image body in 32-bit RLE binary:
#?RADIANCE CAMERA= NIKON E995 version E995v1.6 EXPOSURE=4.108856e+00 CAPDATE= 2006:01:07 17:14:12 PRIMARIES= 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600 0.3127 0.3290 FORMAT=32-bit_rle_rgbe -Y 960 +X 1280 <lots of binary garbage next...>
The photometric pixel value (in cd/m²) is the product of the pixel value stored in the image body and the exposure value from the header. By simply adusting the EXPOSURE= line in the header, the luminance values may be adjusted for the whole image. This is done by dividing the EV by the calibration factor.
Please note that I don't know if the implementation of the Radiange RGBE image format is correct for all applications in that it honours the image exposure. When in doubt, simply try it out.
Usage
The following example assumes that you have an HDR image, before.hdr, which requires exposure calibration like explained on WebHDR. The spot reading with a luminance meter gave a reading which is twice as high as the values taken from the HDR image, so the calibration factor is 2.0.
$ ls -l *.hdr -rw-rw-r-- 1 axel axel 1492005 2008-11-03 18:50 before.hdr $ hdrexpo.pl 2.0 before.hdr > after.hdr $ ls -l *.hdr -rw-rw-r-- 1 axel axel 1492005 2008-11-03 18:50 after.hdr -rw-rw-r-- 1 axel axel 1492005 2008-11-03 18:45 before.hdr
To see if the result is as expected, we can use Radiance tools to compute the average image brightness...
$ pvalue -h -H -d -b -o before.hdr |total -m 2.25595038 $ pvalue -h -H -d -b -o after.hdr |total -m 4.51190374
..., or we could generate a false colour image like this:
$ falsecolor -s 2000 -l cd/m2 -n 10 -e -lw 60 -ip after.hdr > after_fc.hdr $ falsecolor -s 2000 -l cd/m2 -n 10 -e -lw 60 -ip before.hdr > before_fc.hdr
Download
- hdrexpo-0.1.1.tgz
(gzipped TAR ball, 13 kB), containing:
- The Perl script hdrexpo.pl (View),
- A copy of the GNU General Public License.
License
hdrexpo is published under the GNU General Public License.