Main
Photo Portfolio
Baseball
ShutterSounds Blog
Projects
Resumé (pdf)
About

Exampe 5: Edge-sensing bilinear interpolation

Edge-sensing
Edge-sensing Bilinear

A failure of non-adaptive algorithms such as bilinear and smooth hue transition interpolation is the indiscriminate averaging without regards to spatial features in the image - this is what causes the "zipper" effect seen in the output of both. Edge-sensing bilinear interpolation is a so-called "adaptive" algorithm, which analyzes the image and chooses an interpolation formula based on surrounding pixels. Edge-sensing works by attempting to detect edges in an image (harsh intensity transitions), and interpolating only values parallel to the edge and ignoring the values perpendicular to it. In this implementation, the pixels are interpolated in bilinear fashion - however any of the previously mentioned interpolation methods can be used; the idea of edge-sensing is simply to choose which pixels to interpolate, depending on nearby spatial features.

As can be seen here, edge-sensing interpolation removes most of the "zipper" artifacts, but in this simple edge-sensing implementation using only the 8 immediately adjacent pixels in a standard Bayer pattern, edge detection is only possible in either the horizontal/vertical directions for interpolation of green pixels or diagonal directions for interpolation of red at blue pxiels and blue at red pixels. Thus slight zipper pattern and color artifacts are still produced, most visibly at angled edges not conforming to horizontal, vertical, or 45-degree directions.

Edge-sensing Bilinear resized 3x
(Resized 3x for clarity)

Algorithms

Choose an algorithm from the left. Feel free to send suggestions/links for new ones to thedailynathan at gmail.

Shown here is the original image for reference, and the simulated Bayer raw data which the different algoriths are run on. The simulated Bayer data is generated by taking only green, red, and blue values from the corresponding pixel in a 2x2 GRGB Bayer pattern. Assuming the image used is a 100% crop taken from an image with the top-left pixel (at position 0,0) being a first green photosite (G1), this should be a fairly accurate representation of the actual raw data (assuming of course, that a camera using a Bayer filter sensor was used, and ignoring any compression losses due to compression to 24-bit true color and possible JPEG lossy compression).

Note that this demo does not quite work as effectively with resized images (this demo resizes images greater than 300x300 for performance reasons), or images not generated from a camera using a Bayer sensor. In these cases, resolution can approach or exceed that of a Bayer sensor and anti-aliasing (AA) filter combination, and severe mosaicing artifacts should be expected to appear, no matter the algorithm.

Pixel-binned
Original image
Pixel-binned
Simulated Bayer raw data