Questions About Custom Pixel Based Temperature/Tint Calculation

Hey guys, I'm a complete newbie to raw image processing.

I'm trying to mimic how Adobe Camera Raw calculates Temperature and Tint with custom whitebalance spot selection. You choose a pixel and it changes the temperature and tint based on the chosen pixel such that the pixel chosen becomes a gray pixel. I'm trying to calculate the exact values as ACR.

I have a DCP file for the camera and I'm able to read data from it.

My idea was that I would need to convert the image to the XYZ space. Then I'd just need to apply the temperature/tint formulae on lindbloom's website to get the temperature/tint based on the XYZ values of the chosen pixel. I believe I need to multiply the colormatrix from the DCP with some data from the raw image to get the XYZ colors for a pixel.

But I'm not sure which data from the raw image do I need to multiply this with. Any clues?

Also, is this also the right way of calculating the values?

I also noticed that the raw image size was larger when processed through libraw than ACR by a few pixels. Not sure why that is the case.

Any help/direction on how to achieve the ACR values will be appreciated.

Forums: