MaximDL’s
built in debayer tool (ConvertRGB) uses a derivation of the Nearest Neighbor
Replication algorithm. This is fast, but fairly simplistic in it’s results,
producing artifacts around the edges of bright stars.

The
algorithm is described below:

**Nearest Neighbor Replication**

- In this interpolation
method[2][3][4][5], each interpolated output pixel is assigned the value
of the nearest pixel in the input image. The nearest neighbor can be any
one of the upper, lower, left and right pixels.

- An example is
illustrated below in Figure 2 for a 3x3 block in green plane. Here we
assume the left neighboring pixel value is used to fill the missing ones.

There are several well known alternative algorithms and the plugin below implements the smooth hue transition interpolation algorithm, also described below:

**Smooth **

- One of the key objection
of the bilinear interpolation is that the hues of adjacent pixels change
abruptly and in an unnatural manner. The Bayer CFA pattern, on the other
hand, can be thought of as consisting of a luminance channel (the
relatively numerous green pixels) and a chrominance channel (the relative
sparse red and blue pixels). A scheme can be created to interpolate these
channels differently.

- For convenience, figure
1 is duplicated here

- Interpolation of green pixels : same as in bilinear
interpolation. Also note interpolation of green pixels has to be done
before interpolations of red/blue pixels.

- Interpolation of red/blue
pixels :

- The idea here is to
try to impose a smooth transition in hue from pixel to pixel.
- To do so, define blue "hue value" as : B/G. And red "hue value" can be analogously
defined.
- Considering the
interpolation of blue pixel values :
there are three different cases of blue pixel value interpolations.
- estimating blue pixel
value at the green position and the adjacent blue pixels are on left and
right : e.g. B7 = G7 / 2 * (B6 / G6 + B8 / G8)
- estimating blue pixel
value at the green position and the adjacent blue pixels are on top and
bottom : e.g. B13 = G13 / 2 * (B8 / G8 + B18 / G18)
- estimating blue pixel
value at the red postion : e.g. B12 = G12 / 4 * (B6 / G6 + B8 / G8 + B16
/ G16 + B18 / G18)
- Interpolation of red pixel values can be carried out analogously

My plugin implementation of the smooth hue transition interpolation debayer algorithm is available here:

**Release notes:**

V1.0 – Initial release – includes optional CCD spectral response compensation

smooth hue transition debayer v1.0

If you use this plugin, please give me feedback via the MaximDL yahoo group, or by email to winfij_AT_gmail_DOT_com

Regards,

John

(Algorithm descriptions courtesy of Ting Chen)