Axel Mertes
Well-known member
ok...
question about going from Red/SDK rgb...to Cineform Raw through back sampling...or really remosaicing(did I just invent a word?)
as far as I can tell...mathematically in an ideal situation there would be no loss of quality....
correct me if I'm wrong of course...I may be overlooking something
If the bayer pattern is known....and I assume it is....
Then a bayer pixel would be known to be either R,B,or G
If a bayer pixel is known to be G....and the developed image(demosaiced) contains anything other than G....then the resulting R and B values can be discarded....Since this is an RGB Raw sampling to begin with, the other color values should not affect luminance...the way YUV would.
the same would also hold true for the Blue and Red bayer pixels as well.Each known pixel...(known as in there position and color filtering on the bayer sensor) would have the other 2 non native color channels discarded.
Being that seperate channels are recorded for each value this should be simple.
Some caveats....
1.If the bayer pattern is unknown(how many are there really?) then this is assumption
2.If there is some baked in sharpening ect ect that would be anything but the Raw RGB
3.If the origional debayering gave a pixel....green for example....more or less green then was natively recorded due to it's neighbouring pixels via some color weighting algorithm
If these are all not factors, and unless I'm missing something(quite possible) then the mathematics of remosaicing is quite simple, and should be mathematically perfect. At least the remosaic part.
The algorithm that would again demosaic it, of course would be different...and could lead to different results
Remosaicing? Cinemaphotographers would do that...?
I think your observations are correct, matching my own.
I did some deBayer algorythms my own in the past. The starting point was always a native RGB image (source was 3 colored per pixel and downsampled to gain "correctness" of averaged color per pixel). The I stripped off two color components per pixel on a Bayer pattern style like
R G
G B
Basically a Bayer pattern is always 2 green, 1 red and 1 blue pixel, where green is diagonal, and red and blue on the free corners. You can rotate or mirror that pattern, but essentially there is not much options.
Clearly its helpful to know the pattern of the camera to do what David does with Cineform tools now.
My tests for the algorythms where always to compare the deBayered image (from the artifical Bayer image) with the original source RGB image (from which the artigicial Bayer image was derived). The closer I get, the better the algorythm.
Clearly there is often more involved that resampling the missing color pixels. When coming from a sensor, the RAW data needs to be adjusted for certain artefacts, like:
1. black noise level (the values the "photosite" recognizes without any light being received at all)
2. individual pixel gamma/gain noise (technically you can have a 1D-LUT per pixel/photosite to make it perfect)
3. color cross talk (done by using matrix computations etc.)
In a perfect world the above artefacts would be resolved PRIOR to storing the RAW file, making it a perfact RAW file - as this kind of corrections only relate to "failures" of the sensor not returning the perfect image. Every sensor has some differences, this is why we need to do black shading for instance. Point #2 is not very likely to happen on most cameras, as its exessively computing intensive. The Drake camera did that, though... - their images were so good that even the vendors of the sensor couldn't believe it.
4. sharpening
5. any kind of "intelligent" deBayering etc.
4 and 5 I'd prefer not to baked into the RAW (and RED seems to feel the same
There may be more to do, thats just what I have in mind right now.
So basically - if the deBayer algorythm keeps the real pixel values of the Bayer pattern pixels unchanged, going back from RGB to RAW and back to RGB should not change the image in ANY way, except you used a different algorythm.
The biggest point IMHO is color cross talk / matrix computation. If that is not included in the RAW itself, it could become tricky... But as the RED RGB includes it for sure, the approach David is showing feels pretty OK to me. And in the end, David did it for the time being until RED gives us all the desired RAW access via SDK.
I hope their developers find some time between the many new stuff on their roadmap, to implement this basic feature. It is hopefully not to far away, as it must be inside their code anyway (how else would they extract RGB otherwise from it). Its just that they should allow to skip the RED deBayer and provide access to a 12 bit "grayscale" Bayer pattering bitmap after decoding their RED CODE compression. The last is clearly something that belongs to their SDK, but the deBayer step should be open.
I'd like to repeat that if RED is hesitating to release RAW access for not being sure about being judged correctly on the final image quality if other deBayer methods are used, then all it requires would be to make it a must of any SDK licensee to include an option (beside own deBayer methods) to use the RED SDK deBayer method.
I believe many companies would use RED SDK for rendering, while doing their own stuff for realtime editing / grading / processing of any kind. It would be a workflow advantage IMHO.
But back to speed, beside the (always uncomfortable) transcoding times, Davids approach is very potentially giving us lots of speed in the post production.
I need to call him
Axel