hdr is a high dynamic range image processing library for double-precision image processing. The lib is able to handle OpenEXR files , which is a HDR image file format, allowing a set of operations such as copying pixels, re-sampling channels or adding new ones.
The library provides a class to handle post processing effects, allowing the developer to apply several filters using a queue. Some of the available filters include Bokeh, Gaussian blur, threshold, bloom, multiply, Vignette and linear fog. Filters are applied in chunks, avoiding huge CPU spikes.
Sample
package { import eu.liquify.hdr.Image; import eu.liquify.hdr.ImageMapper; import flash.display.*; import flash.text.*; public class ExposureExample extends Sprite { private var image:Image; private var displays:Vector.<Number>; private var displayIndex:int = -1; // Exposure values for the different grid examples private var exposures:Vector.<Number> = new [0.01, 0.1, 1, 10]; private var mapper:ImageMapper; private var label:TextField; public function ExposureExample() { // Create 320x180 image with default attributes (few if any other settings are supported at this time). image = new Image(320, 180); generateImage(); initDisplays(); mapper = new ImageMapper(); mapper.addEventListener(Event.COMPLETE, mappingComplete); label = new TextField(); label.defaultTextFormat = new TextFormat("Arial", 12, 0xFFFFFF); label.autoSize = TextFieldAutoSize.LEFT; nextDisplay(); } // Generate a sample HDR image from a few funky math functions. private function generateImage():void { var w:int = image.width; var h:int = image.height; // Get each color channel as a Vector of Numbers var r:Vector.<Number> = image.getChannel("R").values; var g:Vector.<Number> = image.getChannel("G").values; var b:Vector.<Number> = image.getChannel("B").values; for (var iy:int = 0; iy < h; iy++) { for (var ix:int = 0; ix < w; ix++) { var index:int = ix+iy*w; var dx:Number = ix-w*0.5; var dy:Number = iy-h*0.5; var dist:Number = Math.sqrt(dx*dx+dy*dy); r[index] = Math.sin(dist*0.1+0/3*Math.PI*2)/(1+dist)*20; g[index] = Math.sin(dist*0.1+1/3*Math.PI*2)/(1+dist)*20; b[index] = Math.sin(dist*0.1+2/3*Math.PI*2)/(1+dist)*20; } } } // Initialize a grid of some display bitmaps for displaying different results. private function initDisplays():void { displays = new Vector.<Number>(4, true); for (var i:int = 0; i < displays.length; i++) { var data:BitmapData = new BitmapData(image.width, image.height); var display:Bitmap = new Bitmap(data); display.x = (i%2)*image.width; display.y = int(i/2)*image.height; addChild(display); displays[i] = display; } } // Process next display example bitmap in the grid. private function nextDisplay():void { displayIndex++; if (displayIndex >= displays.length) return; var display:Bitmap = displays[displayIndex]; // Initialize the mapper with the HDR image and LDR BitmapData, this alone only sets internal state, remap() is required for processing to actually begin. mapper.init(image, display.bitmapData); // Exposure controls how bright or dark the mapped image comes out as, you can think of it as how long the "image film" gets exposed for. mapper.exposure = exposures[displayIndex]; // Initiate the asynchronous remapping process, Event.COMPLETE is dispatched when it completes. mapper.remap(); } // When HDR -> LDR image mapping completes (async for preview / performance reasons), add exposure label and render the next display. private function mappingComplete(e:Event):void { label.text = "Exposure: "+exposures[displayIndex]; displays[displayIndex].bitmapData.draw(label); nextDisplay(); } } }
RT @as3gamegears: New: hdr (high dynamic range image library for double-precision image processing) http://t.co/gCgm1N6kaZ #as3 #flash #gam…
@as3gamegears this looks interesting for my generative reaction diffusion stuff.
@as3gamegears hey, that’s my lib! I’m glad you found it useful. Thanks for writing about it, something I need to work on more