Simple interpolation These algorithms are examples of
multivariate interpolation on a uniform grid, using relatively straightforward mathematical operations on nearby instances of the same color component. The simplest method is
nearest-neighbor interpolation which simply copies an adjacent pixel of the same color channel. It is unsuitable for any application where quality matters, but can be useful for generating previews given limited computational resources. Another simple method is
bilinear interpolation, whereby the red value of a non-red pixel is computed as the average of the two or four adjacent red pixels, and similarly for blue and green. More complex methods that interpolate independently within each color plane include
bicubic interpolation,
spline interpolation, and
Lanczos resampling. Although these methods can obtain good results in homogeneous image regions, they are prone to severe demosaicing artifacts in regions with edges and details when used with pure-color CFAs. However, linear interpolation can obtain very good results when combined with a spatio-spectral (panchromatic) CFA. One could exploit simple formation models of images for demosaicing. In natural images within the same segment, the ratio of colors should be preserved. This fact was exploited in an image sensitive interpolation for demosaicing.
Pixel correlation within an image More sophisticated demosaicing algorithms exploit the spatial and/or spectral correlation of pixels within a color image. Spatial correlation is the tendency of pixels to assume similar color values within a small homogeneous region of an image. Spectral correlation is the dependency between the pixel values of different color planes in a small image region. These algorithms include: •
Variable number of gradients (VNG) interpolation computes gradients near the pixel of interest and uses the lower gradients (representing smoother and more similar parts of the image) to make an estimate. It is used in first versions of
dcraw, and suffers from color artifacts. •
Pixel grouping (PPG) uses assumptions about natural scenery in making estimates. It has fewer color artifacts on natural images than the Variable Number of Gradients method; it was introduced in dcraw from rel. 8.71 as "Patterned Pixel Grouping". •
Adaptive homogeneity-directed (AHD) is widely used in the industry. It selects the direction of interpolation so as to maximize a homogeneity metric, thus typically minimizing color artifacts. It has been implemented in recent versions of dcraw. •
Aliasing minimization and zipper elimination (AMaZE) designed by Emil J. Martinec is slow but has great performance, especially on low noise captures. Implementations of AMaZE can be found in
RawTherapee and
darktable.
Video super-resolution/demosaicing It has been shown that
super-resolution and demosaicing are two faces of the same problem and it is reasonable to address them in a unified context. Note that both these problems face the aliasing issue. Therefore, especially in the case of video (multi-frame) reconstruction, a joint super-resolution and demosaicing approach provides the optimal solution.
Trade-offs Some methods may produce better results for natural scenes, and some for printed material, for instance. This reflects the inherent problem of estimating pixels that are not definitively known. Naturally, there is also the ubiquitous trade-off of speed versus quality of estimation. ==Use in computer image processing software==