Understanding bayer, pixel res, and debayering.

Started by ItsMeLenny, June 01, 2014, 07:02:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ItsMeLenny

Whilst I do have some knowledge on the subject, I am just trying to wrap my head around some last bits of understanding for that ahhhh moment.

Here is my example bayer pattern:
RGRGRG
GBGBGB
RGRGRG
GBGBGB

I'll get back to it.
When a sensor (such as 550D) is said to have a resolution of 5184×3456, is this the amount of pixels of different colours?
As a resolution that size does result in jpeg images that size, or is this all due to the way it debayers.

So would the above bayer pattern have a resolution of:
A) 6x4
B) 3x2 (grouping in 4s)
C) 5x3 (weird debayering which I think is happening)

Weird debayering example:




RG
GB
GR
BG
RG
GB
GR
BG
RG
GB
GB
RG
BG
GR
GB
RG
BG
GR
GB
RG
RG
GB
GR
BG
RG
GB
GR
BG
RG
GB
(Grouping of 'sensels' from my example bayer pattern above.)

Resulting in one less pixel each way because of the half a pixel on each end.

Or am I totally confused on everything.

The reason I ask also is to do with raw video; when recording 960x540 I was originally under the impression it would record 1920x1080 pixels (black and white of each bayered colour - if you get what I mean).

chmee

lets name the parts differently :) one part of the sensor is a sensel, a piece of a picture is a pixel. indeed every sensel ends as a pixel in the picture, but their values are 66% synthetic. look on the first sensel in the first row. its only red, therefore green and blue are recreated from neighbouring senselvalues. this mathematical technique is named demosaicing or debayering. thats the typical behaviour, yes.

your "weird" sensor example will end as a 10x6 pixel picture. your first example is a 6x4 picture (a).
if you record 1920x1080 (sensels), it will result in a 1920x1080 picture
[size=2]phreekz * blog * twitter[/size]

ItsMeLenny

Sorry, my weird debayering example is the grouping of 'sensels',
so it related to the first picture, but i've grouped the sensels into pixels.

ItsMeLenny

Quote from: chmee on June 01, 2014, 07:49:41 AM
if you record 1920x1080 (sensels), it will result in a 1920x1080 picture

Which is 960x540 red, 960x540 blue, and 960x1080 green?

chmee

if you wouldnt do a demosaicing, you would get this, yes. so, finally you can say, every bayer-based picture is 1/3 native, 2/3 synthetic.
[size=2]phreekz * blog * twitter[/size]

a1ex

In this example, after debayering, you have 960x540 of real red data, and the rest is interpolated (guessed). Same for blue. Green has twice as much real resolution, so half of the green pixels are real, half interpolated.

The color resolution in a debayered image is usually lower, but most algorithms are able to reconstruct full-resolution luma by exploiting inter-channel correlation.

Check resolution with "dcraw -i -v". For example, on 5D3 photo:


Thumb size:  5760 x 3840
Full size:   5920 x 3950


The small one is called "active area", and it has valid pixel data. The rest is called "optical black", and it's used by the electronics for black level clamping, and then by software for estimating noise level, fine-tuning black level and so on.

Canon JPEG is a little smaller: the JPEG size is 36 pixels smaller than the active area IIRC. With dcraw, you can squeeze a few more pixels (it's in the dcraw FAQ), but it may still throw away a tiny number of border pixels.

With raw video, the active area sizes (rounded a bit) is here: http://www.magiclantern.fm/forum/index.php?topic=6215

The exact sizes can be found from a silent picture (DNG), because they also include the optical black areas. Raw video does not record these, for speed reasons.

On 5D3, the full raw size is 2080x1318 (exact), active area is 1934x1290 (maybe 2-3 pixels more) , and the YUV buffer size is 1904x1274.

If you develop with "dcraw -h", you will skip the debayer process and get a half-resolution image, with no interpolated values. If you downsample it from a full-res debayered image, you should get better results (you can run some comparisons), so the guesswork from the debayering algorithms is usually pretty good.

Some good info: http://pixinsight.com/doc/tools/Debayer/Debayer.html

ItsMeLenny

Ok, I think I get it. Or at least I get it enough for me to be satisfied. I probably don't fully understand it from the perspective of someone who does :P
Thanks very much chmee and a1ex.

chmee

maybe this picture can help a little bit.



regards chmee
[size=2]phreekz * blog * twitter[/size]