CVL lets you tinker with HDR images on your GPU

138

Author: Ben Martin

If your desktop hardware includes a graphics processing unit (GPU), you can do some cool image processing with the CVL suite of tools, which includes in image viewer, an image tone mapper, and a command-line tool for non-interactive image processing.

The suite comprises three tools. CVLView is image viewer for PFS files, CVLTonemap is an image viewer designed to quickly handle high dynamic range (HDR) images, and cvtool is a command-line tool that lets you apply transformations, color manipulations, blending, and filtering to images. They take advantage of the processing power of your GPU to allow you to apply tone-mapping changes to an image in real time. You need to have an Nvidia GeForce 6.x or later graphics card to use the tools.

An HDR image normally contains more color information than your display device can make use of. For example, many normal “low dynamic range” (LDR) formats use eight bits for each of red, green, and blue, whereas an HDR image might be based on 32-bit floating point numbers. The job of tone-mapping software is to produce a nice rendering of an HDR image on an LDR display such as an LCD computer monitor.

One method of producing an HDR image is to mount your digital camera on a tripod and use exposure bracketing to take exactly the same picture with different exposure settings. A collection of such photos can be combined to produce a single HDR image using a tool like fotoxx.

The CVL suite includes three programs: CVLView, CVLTonemap, and cvtool. The first two programs are graphical, using the Qt 4.2 or above toolkit, and the latter is a command-line tool. All three programs use the PFS image format, so to use the CVL tools you will want to have pfstools installed.
The PFS format is described as a simple generic HDR image format, though I could not find out if PFS is an acronym or just three
random letters used for the file format extension.
Both cvtool and CVLView can also natively handle the netpbm format.

The pfstools package allows you to read and write other image formats and convert them to and from PFS. The pfstools FAQ says that the PFS format is not compressed and is designed to be used to easily pass image data to and from applications. For example, the below command line reads an HDR image file, converts it into a PFS file, sends it to cvtool for a Gauss effect, and saves it as a PNG image.

pfsin foo.hdr | cvtool gauss --sigma=1.2 | pfsout bar.png

Because CVLTonemap is a graphical application, you cannot use it in processing pipelines like the one shown above. However, CVLTonemap will notice if pfstools is installed and automatically take advantage of it if it is available. The result for you is that CVLTonemap will offer to load other image formats from its open and save dialogs, taking advantage of pfstools behind the scenes to handle these formats.

pfstools is available as a 1-Click install for openSUSE 11 and is in Debian lenny and sid, but it is not packaged for Fedora. The CVL suite is not packaged in the standard repositories of openSUSE, Debian, or Fedora. I installed both from source on a 64-bit Fedora 9 machine is equipped with an Intel Q6600 CPU and an Nvidia GeForce 7900 GS graphics card. I built cvlview version 0.3.1, cvltonemap 0.2.2, cvtool 0.2.5 , and pfstools 1.6.5. The CVL suite requires Qt 4.2 or later and the glew library, the latter of which is packaged for Fedora, openSUSE, and Debian

You install pfstools using the normal ./configure; make; sudo make install procedure. Pay attention to the output generated at the end of the configure run, as it will tell you which image-handling libraries pfstools has detected and thus let you know whether your build will be able to handle JPEG-HDR and OpenEXR image files.

The CVL suite is distributed as three tarballs, each follows the normal ./configure; make; sudo make install procedure. You need to install cvtool before you can build CVLView and CVLTonemap. I had the error shown below when compiling CVLView. To get around this error, add #include <limits> to the top of gllib/glvm.h.

In file included from arcball.cpp:24: glvm.h:1192: error: 'numeric_limits' is not a member of 'std' ...

The description of CVLView states that it is a “viewer for arbitrary floating point data that is stored in pfs files” — not for image manipulation. Loading the examples from the CVLView home page I ran into a few issues. First, the panels in the sidebar of the application were always slightly smaller than they needed to be to show each pane. This turned out to be an issue with KDE 4 version together with my theme settings. Running CVLView as a different user (thus with no theme settings) allowed each page in the side panel to display fully.

When you load an HDR image the “Range Selection” will probably be set so that you will only see black and must manually adjust the range in order to focus on the area that contains data values (and thus produces an image). The “3D View” mode uses three dimensions to display a greater value range for each pixel than your monitor can handle. In the case of the screenshot to the left of the Nancy Cathedral, the light from the windows is brighter than the current range selection I am using for the image and is shown as pixels above the image with the distance of the pixel from the plane indicating how far the value is away from the range of pixel values that I have selected to view.

You can click on an image and drag it around and scroll in and out with the mouse wheel. Zooming in and out is an instant operation. When in 3D View mode, holding down the right mouse button allows you to rotate the image so you can see the values that do not fit into your range selection.

CVLTonemap allows you to change the part of the color range of an image you can see on your screen, with most changes taking place in real time. I found that when using more advanced tone-mapping techniques like L Durand 02 there was a noticeable lag between changing a slider and the image being updated. But then again I am only running a Shader Model 3 graphics card instead of a GeForce 8 or above, which support Shader Model 4.

I found that keeping CVLView open with the nancy_cathedral_2 image and attempting to open it in CVLTonemap too resulted in an “invalid framebuffer operation.” When I closed both tools and started only CVLTonemap, it loaded the image fine. This leads me to believe that I had run out of memory on the graphics card when I tried to open the image in both programs at once.

The command-line cvtool allows you to apply various image operations non-interactively. The manual page for cvtool, like those of CVLView and CVLTonemap, is extremely spartan, but better documentation is available on its Web site. Invocation follows the template cvtool commandoptions < input.pfs > output.pfs. The example invocation below will scale the image to 20% of its original size. To get more information (including valid values that might not be shown in the documentation) execute cvtool help command.

$ cvtool scale --factor 0.2 --interpolation=bicubic-b-spline < nancy_cathedral_2.pfs > nancy_cathedral_2_small.pfs $ cvtool help scale cvtool: [REQ] help: scale [-w|--width=<width>] [-h|--height=<height>] cvtool: [REQ] help: [-i|--interpolation=none|bilinear|biquadratic|bicubic|bicubic-b-spline|bicubic-cr-spline] cvtool: [REQ] help: scale -x|--factor-x=<factor-x> -y|--factor-y=<factor-y> cvtool: [REQ] help: [-i|--interpolation=none|bilinear|biquadratic|bicubic|bicubic-b-spline|bicubic-cr-spline] cvtool: [REQ] help: scale -f|--factor=<factor> cvtool: [REQ] help: [-i|--interpolation=none|bilinear|biquadratic|bicubic|bicubic-b-spline|bicubic-cr-spline] cvtool: [REQ] help: cvtool: [REQ] help: Scale frames to new size. The default interpolation type is cvtool: [REQ] help: bilinear. cvtool: [REQ] help: First form: Give new width and/or height. If one value is cvtool: [REQ] help: missing, it is computed from the other so that the aspect cvtool: [REQ] help: ratio remains the same. cvtool: [REQ] help: Second form: Give scale factors for width and height. cvtool: [REQ] help: Third form: Give one scale factor for both width and height.

Being able to modify in real time how an image is rendered that has more color information in it than your display can represent is wonderful. If you are planning to do some exposure-bracketed photography or work with HDR images, then CVLTonemap is a great tool to have installed. CVLTonemap allows you to select from many algorithms and see the results of varying settings like sharpness and saturation in real time or near real time for slower algorithms, depending on the size of your image and how modern your machine is. For a deeper understanding of these tone-mapping algorithms, and how the parameters interact, see the book High Dynamic Range Imaging: Acquisition, Display and Image-Based Lighting.

Category:

  • Graphics & Multimedia