Close Show/hide page

{zero point nine} personal experiments, etc.

Webcam image compositor, creating PNG48's

Thumbnail - Click me Click to run demo

How it would look if you took a webcam or camera, and captured several frames of the same scene in quick succession, and then essentially averaged them out and composited them into one image? My guess was that the resulting image would retain most of its sharpness but lose most of the 'noise'.

Here is an example of my results (before and after). The images were captured with a Logitech Quickcam Pro 9000 at a resolution of 1600x1200 (averaged from 128 (!) still images), and were not scaled or retouched (just cropped).

Example - single frame Example - composited version

As a side benefit, if the camera -- or something in the foreground of the scene -- moves during the image capturing process, you can get photography-like effects that look like a long exposure...

A PNG48 encoder class...

Taking multiple samples in this way yields a wider range of color channel information than that of a single snapshot. For example, a device that saves 8-bits-per-channel can only store a value for red between 0-255. If you added together the color information from 16 "identical" images, you get a range from 0 to 4095 (in other words, 12 bits per channel instead of 8). The value of that extra information is potentially open to debate, but I think it's clear that at least in the case about that there's more there there than there was before... If nothing else, doing lots of Photoshop-like post-processing of the image would probably lead to less color degradation, banding, etc.

To store that data internally, I'm using a long, flat array of floating point values. Although calculations on floats are much slower than with integers, it of course offers much more granularity, making the image information essentially free from the constraints of a regular bit-length-based implementation. At this point, multiple calculations can be done on the data set without losing information due to rounding as would be the case with an integer-based format. At the point you want to re-output the image to the screen, a function converts the color array into a data structure with 8 bits per color channel, ie, into BitmapData.

All these considerations inevitably led to the idea of outputting to a 16-bit image file format. It turns out that, thankfully, PNG fits the bill. I was able to modify Tinic Uro's PNGEnc class to output PNG's with 16 bits per channel.

Here are the two interesting utility classes coming out of this experiment:

View or post a comment