Attempting to find color matrix from firmware - page 2 - General Discussion and Assistance - CHDK Forum

Attempting to find color matrix from firmware

  • 22 Replies
  • 15618 Views
*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: Attempting to find color matrix from firmware
« Reply #10 on: 24 / January / 2009, 03:16:02 »
Advertisements
I just tried to change one of these values in RAM, and yes, the colors in the resulting jpeg change. So I can see a semi-analytical  way to reverse the meaning of these coefficients: changing them one at a time and shooting some kind of color checker with a few well separated color patches. Then transform the resulting colors to standard linear color spaces (sRGB, XYZ) and find the corresponding transformation (matrix) from the original image, where the colors were not fiddled with. Hopefully, in some color space the corresponding matrixes will appear particularly simple, and...

But I'm too old for that. Besides, I already have a nice color matrix.

Edit: since live view changes too, one can start off by just looking at live RGB histo while changing coefs in RAM...
« Last Edit: 24 / January / 2009, 03:35:24 by whoever »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Attempting to find color matrix from firmware
« Reply #11 on: 24 / January / 2009, 05:07:38 »
Aren't you missing an indirection here? In my ROM, I read a value from 0xb344, take that pointer (normally 1b7404), then add 0x80, 0x84, etc to THAT pointer.

Ooooopsie, you are right of course! How sloppy of me...With offset 0x18157C I now get

862 -862 92 -92 316
196 136 376 -250 250
1068 -1068 86 134 40

I'll modify the script post shortly.

Re: Attempting to find color matrix from firmware
« Reply #12 on: 24 / January / 2009, 05:30:35 »
I have a little idea on how the matrix values may work

the last three, as I said before, seem to be the main R G B multipliers. Lets call those values A, B and C. In a 3x3 matrix that would give a simple matrix

A 0 0
0 B 0
0 0 C

If you were to make a RGGB -> RGB matrix this would become

A 0    0    0
0 B/2 B/2 0
0 0    0    C

Maybe to get the final matrix, we should multiple this 'white balance' matrix with the other 12 numbers left in the 15-number array, presenting a final matrix. I will play around with this to see if this works later.

I think we can be pretty sure this is the real color matrix now though :) (yay)
« Last Edit: 24 / January / 2009, 05:33:34 by sharky »

Re: Attempting to find color matrix from firmware
« Reply #13 on: 24 / January / 2009, 05:38:33 »
on the other hand, since jpg is yuv-based, we may have to look at rggb->yuv ..


*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: Attempting to find color matrix from firmware
« Reply #14 on: 24 / January / 2009, 08:23:10 »
Let's get some algebra straightened out. If color matrix M is understood in the DNG sense, i.e. it transforms a column XYZ with D65 reference white to camera RGB, i.e. {Rcam Gcam Bcam}T = M * {X Y Z}T, where T stands for transpose, then camera WP (white point), proportional (equivalent) to AsShotNeutral value, is simply {RWP GWP BWP}T = M * WPD65, where WPD65 = {0.950456 1 1.088754}T is the D65 illuminant reference white. Then, "WB multipliers" (i.e. what you multiply camera RGB with to get {1 1 1} for pure white) are simply 1/RWP, 1/GWP, 1/BWP, and thus they follow  from the colormatrix. Otherwise, they are straightforward to obtain -- shoot white card in daylight and determine RWP GWP BWP from the raw image.

Now, RGGB->RGB is a part of demosaicing algorithm, so the 0.5 multiplier usually doesn't appear in M definition.


Re: Attempting to find color matrix from firmware
« Reply #15 on: 24 / January / 2009, 08:31:58 »
I made a little script to modify the values.

It's very weird; when you change the values stuff changes (you can make all red objects green), but it then also it sometimes auto-corrects ...

Also, when I set the white balance to manual, changing the numbers does absolutely nothing.

I'm starting to think this is not the complete CIEXYZ color matrix, but 'just' the white balance ..

Re: Attempting to find color matrix from firmware
« Reply #16 on: 24 / January / 2009, 08:33:09 »
oh here's the script

up/down => change which value you are editing
left/right => modify the value
set => reset first 12 values to 0
menu => exit

Re: Attempting to find color matrix from firmware
« Reply #17 on: 26 / January / 2009, 08:00:42 »
looking at some datasheets for Image DSP's for digital camera's, like this one: http://kazus.info/datasheets/587613/TMS320DM640.html, shows me that at least THIS dsp has separate 3x3 RGB->RGB matrix and white balance.

Has anyone taken apart a cam and photographed it in detail ?

Does canon use Canon chips or 3rd party DSP chips ?


*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: Attempting to find color matrix from firmware
« Reply #18 on: 26 / January / 2009, 09:53:40 »
It seems it's all inside a big black BGA chip with "Canon" and "DiG!C" on it.

Wikipedia (http://en.wikipedia.org/wiki/DIGIC) says: "DIGIC units are made by Canon Inc. for use in Canon's own digital imagery products", and you can find many variations of that phrase elsewhere.

Otherwise, it's anybody's guess.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Attempting to find color matrix from firmware
« Reply #19 on: 26 / January / 2009, 14:03:08 »
Has anyone taken apart a cam and photographed it in detail ?

Does canon use Canon chips or 3rd party DSP chips ?

Yes, there are several series of pics of cameras taken apart, try searching for links on these forums. But it really doesn't matter what it looks like... as whoever said, the DSP (among other things) is pretty much certainly inside the chip they call Digic, if it even is a generic DSP.

Like with the ARM core, its quite unlikely that Canon would have reinvented the wheel there... it's very much possible they are using a DSP IP block from someone familiar to the rest of the world, more or less customized to their needs.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal