Calculating Rgb Values

Calculating RGB values for a Bayer Color Filter

A Bayer color filter is a matrix of colored pixels similar to the image below. When data is transmitted from a CMOS camera that uses the Bayer Color Filter Array (Bayer CFA) we get a stream of alternating values of Red (R) Green (G) for odd rows and alternating values of Green (G) and Blue (B) for even rows. In order to construct an RGB picture, we need to calculate Green and Blue values for each Red pixel, Blue and Red values for each Green pixel and Red and Green values for each Blue pixel. There are several ways to do that. From my own experiments and searching the internet I found that the simplest way of averaging neighbouring cells is the fastest and easiest way that give good enough results.

Calculating Green value for a Red or Blue pixel:

In order to calculate the green values for a red or blue pixel we do an avarage of the neighbouring green pixels to the left and right of the red pixel (If there is no neigbhouring green to the left or right you can take the green value below or above the red pixel.

Calculating Blue value for a Red pixel:

In order to calculate the blue values for a red pixel, you have to take the avarage of the four blue pixels that are diagonal to the red pixel.

Calculating Red value for a Blue pixel:

This is done similar to calculating the blue value for a red pixel by averaging the four red pixels that are diagonal to the blue pixel.

Calculating Red value for a Green pixel:

In order to calculate the red value for a green pixel you have to take the avarage of the two red pixels neibouring the green pixel, for odd rows the values are to the left and right, for even rows the values are above and below the pixel.

Calculating Blue value for a Green pixel:

This is done similar to calculating the Red value for a Green pixel by averaging the values of the neighbouring blue pixels, for odd rows the values are above and below the pixel and for even rows the values are left and right of the pixel.

 

<< PreviousWord BrowserNext >>
petrila
nawabshah
linaceae
permafrost (disambiguation)
tuathal teachtmhar
greece interstate 44
lochs of spiggie and brow
fa premier league 1997 98
dutch leonard
list of step (iso 10303) parts
mathmos
goserelin
clyde lassen
waldweistroff
bicalutamide
samantha mumba
king colobus
bierpinsel
football association of the czech republic
mugby junction
helmut knochen
muckross abbey
codlea
tamoxifen
greece dialing code 2610
fa premier league 1998 99
enskede rsta borough
ata al mulk juvayni
workshop on scientific presentation techniques
mao b
ally mcleod
altitude training
mao a
fulvestrant
fa premier league 1999 00
black forest
impersonation
urban areas in sweden
laurenz meyer
one cool guy
taunus
sharaf ad din ali yazdi
liljeholmen borough
hgersten borough