HDR imaging library for Haskell based on pfsutils

Written by Jeff Heard on August 28th, 2009

PFS stands for Portable Floating-point Streams, and it’s a framework for reading and writing HDR images in a variety of formats and also tonemapping them. The HDRUtils library is an Haskell library for reading these streams and formatting them into Haskeller friendly 2D C-compatible arrays of 32bit floats.On top of these are a simple index/assign bijection that uses Russell O’Connor’s Data.Colour package to deal with colorspaces in a human-perception centric way.  Most tonemapping algorithms are based loosely on human perception models, so Haskell is ideally suited to developing new tonemapping algorithms based on roconnor’s model.

The general procedure for working with the streams is something like:

import Graphics.Image.PFS
import Graphics.Image.PixelMap

main = getFrame >>= myToneMappingProcedure . toPixelMap >>= putFrame . fromPixelMap

Where myToneMappingProcedure is something that takes pixels and rewrites them algorithmically.  I intend soon to add a more functional layer to this, using immutable arrays or STArrays, but I haven’t decided on the best way to do it yet. This at least makes the library available.  I’d like to see GdkPixbuf or DevIL images map to PixelMaps, eventually, and to see frame-aligning algorithms, convolutions, and other things layer on top of this library as applicative combinators.  In the meantime, however, have fun with what I have, and if you have a good idea for a combinator architecture, let me know and we’ll work it out.

This project is Open Sourced on github

Leave a Comment