I apologize in advance for the long post, but color space issues are always confusing so I'm trying to be as detailed as possible. All testing was on done Windows 7 with version 0.9.1 build 1714.
PhotoScan currently applies some undocumented, lossy, colorspace transformation to OpenEXR images. This makes it almost useless for generating HDR textures. To illustrate the problem I've provided several sample files at:
http://preview.tinyurl.com/n66sgfaDSC_0721_lnh.exr (
http://preview.tinyurl.com/l8zl78l) is the original scene linear source file that has been normalized following the standard convention where an 18% gray card has a luminance value of 0.18. Note that the brightest pixels in the image occur in the specular reflections on the upper left corner of the ColorChecker's frame and have luminances of ~1.4.
ps_color_test.psz (
http://preview.tinyurl.com/lxo2e47) is a minimal PhotoScan project where all that has been done is loading DSC_0721_lnh.exr.
export_image.py (
http://preview.tinyurl.com/luwp5ov) is a python script that, when run from within the above project, takes the source image and immediately saves it to DSC_7021_copied.exr then undistorts it and saves it to DSC_7021_undistorted.exr. As expected these two output images are very similar with the mean difference between pixels being ~0.002. However, They are vastly different from the source image.
The image at the bottom of this post shows the difference between the source and output images after conversion to sRGB for display using oiiotool:
oiiotool DSC_7021_lnh.exr --tocolorspace sRGB -o DSC_7021_srgb8.jpg
oiiotool DSC_7021_copied.exr --tocolorspace sRGB -o DSC_7021_copied_srgb8.jpg
Note how closely the pixel values of the Neutral 5 patch in the source image match the nominal sRGB values provided by x-rite (
http://preview.tinyurl.com/kh5snvc) and how much different they are in PhotoScan's version.
There are at least two major problems with the EXR files generate by PhotoScan.
- The highlights have been clipped. The output file is clipped to the range 0-1, however, even pixels that were well below 1 in the original image, for example the white strap behind the ColorChecker, have also been clipped.
- An undesired gamma correction of ~2.2 seems to have been applied at some point during PhotoScan's color pipeline as I can get closer to the correct colors by applying the inverse (0.455). This would be less of an issue if it weren't for #1. As long as the transformation was known it could be losslessly reversed if the data hadn't been clipped.
There are also a couple of more minor issues with the EXR output. First the original 16-bit half float image was promoted to a 32-bit float, which is probably not needed for most image data. If so much data had not been destroyed during the color conversions the size of the output image (61 MB) would have nearly doubled relative to the source image (37 MB). Finally, all of the metadata in the original EXR was destroyed, although this is probably less important in the typical workflow where PhotoScan is creating an image from scratch.
It would be great if Agisoft can fix these issues, ideally by letting a well tested third party library such as OpenColorIO handle color conversions.
