karansher / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
1 stars 0 forks source link

Grayscale bayer => color rgb? #39

Open fares-soliman opened 1 year ago

fares-soliman commented 1 year ago

According to main.cpp, the image from the bayer function goes straight into the demosaic function.

Assuming the images from the README are correct, how is a grayscale bayer image supposed to turn into a colored rgb image? Even while looking at the pixels individually of bayer.png in paint, the GRGB block does not even contain the GRGB colors, its just different shades of gray.

abhimadan commented 1 year ago

Each pixel in a (grayscale) Bayer mosaic encodes the value from one of the colour channels from the original image. The selected colour channel depends on the 2x2 Bayer filter (GRGB). When we demosaic the image, each pixel's position tells us which colour channel was forwarded to the Bayer mosaic, so that gives us one of the 3 channel values for every pixel. The remaining two channels are determined by averaging neighbouring pixel values, and again each pixel's position tells us which formula to use for each channel. In other words, using a combination of pixel grayscale values and positions, we can reconstruct a pretty good estimate of the original image.