refinery
RAW file processor
Public Types | Public Member Functions

refinery::Interpolator Class Reference

Transforms a sensor image to an RGB or CMYK image. More...

#include <refinery/interpolate.h>

List of all members.

Public Types

enum  Type { INTERPOLATE_AHD, INTERPOLATE_BILINEAR }
 

Algorithm, to pass to the constructor.

More...

Public Member Functions

 Interpolator (const Type &type)
 Constructor.
RGBImageinterpolate (const GrayImage &image)
 Produce a colorful image from a gray one.

Detailed Description

Transforms a sensor image to an RGB or CMYK image.

When most cameras capture an image, their sensors only gather one color value per pixel. The other values must be added in software, by the Interpolator.

Crucial in the incoming image is the Image::filters() return value, which describes which colors go where on the camera sensor array.

There are several strategies for guessing the missing color values on each pixel. One, INTERPOLATE_BILINEAR, takes an average from the color values of adjacent pixels. Another, INTERPOLATE_AHD, chooses either vertical or horizontal averages per pixel, depending on which one gives the crispest image.

It's straightforward to interpolate a camera-sensor image:

 GrayImage gray = somehowGetGrayImage();
 Interpolator interpolator(Interpolator.INTERPOLATE_AHD);
 RGBImage* rgb = interpolator.interpolate(gray);
Examples:

util/raw2ppm.cc.

Definition at line 35 of file interpolate.h.


Member Enumeration Documentation

Algorithm, to pass to the constructor.

Enumerator:
INTERPOLATE_AHD 

For each pixel, takes the best average.

Two averages are calculated: one with pixels which line up horizontally, and the other with pixels lined up vertically. For each pixel, an average is chosen which gives the least blurry result.

INTERPOLATE_BILINEAR 

For each missing color value, take the average of its neighbors.

For example, on a typical RGB sensor any non-green pixel will have a green pixel above, below, to the left and to the right. Sum those and divide by four, and call that the green for that pixel.

This can make slightly blurry pictures, but it's fast.

Definition at line 40 of file interpolate.h.


Constructor & Destructor Documentation

refinery::Interpolator::Interpolator ( const Type type)

Constructor.

Parameters:
[in]typeAlgorithm this interpolator uses.

Member Function Documentation

RGBImage* refinery::Interpolator::interpolate ( const GrayImage image)

Produce a colorful image from a gray one.

This relies upon GrayImage::filters() to determine what the sensor colors are. This ought to be set automatically from the Exif data, but if the output has cartoony color problems, that might have failed.

It's up to the caller to free the resulting image, with delete.

Parameters:
[in]imageGrayscale (from sensor data) image to interpolate.
Returns:
A new, colorful image with the same width, height and Exif data.
Examples:
util/raw2ppm.cc.

The documentation for this class was generated from the following file:
 All Classes Functions Variables Typedefs Enumerations Enumerator