void CLASS cam_xyz_coeff(float _rgb_cam[3][4], double cam_xyz[4][3])
{
double cam_rgb[4][3], inverse[4][3], num;
int i, j, k;
for (i = 0; i < colors; i++) /* Multiply out XYZ colorspace */
for (j = 0; j < 3; j++)
for (cam_rgb[i][j] = k = 0; k < 3; k++)
cam_rgb[i][j] += cam_xyz[i][k] * xyz_rgb[k][j];
for (i = 0; i < colors; i++)
{ /* Normalize cam_rgb so that */
for (num = j = 0; j < 3; j++) /* cam_rgb * (1,1,1) is (1,1,1,1) */
num += cam_rgb[i][j];
if (num > 0.00001)
{
for (j = 0; j < 3; j++)
cam_rgb[i][j] /= num;
pre_mul[i] = 1 / num;
}
I'm sorry but it appears frm the output of raw-identify that the Libraw code has derived the pre_mul values from the D65 illuminant WB coefficents and other information returned in the raw file for the X-T1. I cannot see where else these
values which are the contents of the pre_mul array could have come from (unless they are hard coded into LibRaw). A pre_mul array with all values set to 1.0 by LibRaw just doesn't make any sense for processing a raw fille for Daylight WB.
So again I ask you how is pre_mul set from the WB coefficients and other data read from the raw file, so I can better understand your code and maybe make contributions in the future.
I've already answered to that (1st/2nd replies in this thread):
LibRaw::COLOR(row,col) returns color index for (row,col)
So, for bayer, 4 calls for (0,0), (0,1), (1,0), (1,1) will give you bayer pattern used.
I now have my application working. However, I have one last question.
Is it possible to find the Bayer filter pattern (CFA) from LibRaw? Basically, I need to establish if a specific camera is either:
RGGB
BGGR
GBRG
GRBG
I have looked at imgdata.idata.cdesc but this returns RGBG regardless of the camera in use. It seems that my Nikon DSLRs are using BGGR but Canon cameras are using RGGB.
Is it possible to receive this information from LibRaw?
"in none of those places does there appear to be any derivation of the pre_mul
value from the WB Coefficients, even though it is clear that such a
derivation must take place."
No, it mustn't, unless WB coeffs are user-supplied.
Yes, I totally understand its not supported in the current release, but it would nonetheless be very helpful to me if you could provide some understanding of how your code works in this area.
in none of those places does there appear to be any derivation of the pre_mul value from the WB Coefficients, even though it is clear that such a derivation must take place.[/geshifilter-c]
> Why are you not providing me with a helpful explanation of what is happening here
> a helpful explanation
The camera is not supported in the version you are using, right? So, what do you expect to be helpful? I'm at loss, since "CM2" obviously means very little to you.
> where in the LibRaw code the pre_mul value is set from the White Balance Coefficients
I have to say that I don't understand your approach to my enquiry. Why are you not providing me with a helpful explanation of what is happening here, rather than just pointing me to the source code and say "go figure it out yourself". I have to question the point of having a LibRaw support forum here if the people who know the code won't explain why something isn't working in the way that someone trying to use it expected.
I was already aware of the annotated DCRaw web-site and have been there a number of times. On this occasion however I am still completely in the dark as to quite where in the LibRaw code the pre_mul value is set from the White Balance Coefficients, and very specifically I don't understand quite why pre_mul was set to values of 1.0 for the unsupported X-T3, but was set to useful values for the X-T1.
I don't want to add support for the camera in question to libraw in the current release. I realise that it will very likely be supported in the 0.20.? release as I believe it is already supported in the snapshots.
The camera is not supported in the LibRaw version you are using, that's why the derived pre-muls for daylight are not available. If you want to support it instead of waiting for the next release, you need to spend some time familiarizing yourself with the code. The link I've provided above should be very helpful.
Iliah, please will you bear with me. I've just spent a whole day chasing this problem.
I *still* don't understand why pre_mul was set to 1.0, 1.0, 1.0 for the Fuji X-T3, but was set to relevant values based on the D65 Illimunant White Balance values for the X-T1.
I had already searched the code looking for everywhere that pre_mul[] values are set and for the life of me I couldn't find the code that converts the WB_Coeffs to the pre_mul values. OK you may think I am stupid, but please I'm looking for assistance here, not a pointer the annotated DCRaw code.
Dear Sir:
Criticism is welcome, that's how we improve.
"Uncalled for" also means "unnecessary" and "unfair". Everything was right in front of you, please pay attention.
I'm not going to continue this discussion, let's stick to questions and answers that are relevant.
What LibRaw version you use?
I dont see sample open_bayer or LibRaw::open_bayer function. was it removed?
https://www.libraw.org/comment/5233#comment-5233
Hi there,
Would you please tell me if there is a plan to support the new-release Canon 90D and Canon CR3 RAW format on Windows 10?
Thanks,
Xinyi
Sorry, I misunderstood your first answer. I have everything working correctly now.
Once again, thanks for your help.
Amanda
yes
So this code:
void CLASS cam_xyz_coeff(float _rgb_cam[3][4], double cam_xyz[4][3])
{
double cam_rgb[4][3], inverse[4][3], num;
int i, j, k;
for (i = 0; i < colors; i++) /* Multiply out XYZ colorspace */
for (j = 0; j < 3; j++)
for (cam_rgb[i][j] = k = 0; k < 3; k++)
cam_rgb[i][j] += cam_xyz[i][k] * xyz_rgb[k][j];
for (i = 0; i < colors; i++)
{ /* Normalize cam_rgb so that */
for (num = j = 0; j < 3; j++) /* cam_rgb * (1,1,1) is (1,1,1,1) */
num += cam_rgb[i][j];
if (num > 0.00001)
{
for (j = 0; j < 3; j++)
cam_rgb[i][j] /= num;
pre_mul[i] = 1 / num;
}
These code sections are derived from dcraw, so this question was already answered here https://www.libraw.org/comment/5427#comment-5427
I'll repeat the direct link for your comfort: https://ninedegreesbelow.com/files/dcraw-c-code-annotated-code.html
You may specify any value in user_mul
Does that mean that I could ask Libraw to use (for example) the "Fine weather" white balance coefficients from the X-T1 raw file metadata Maker-notes?
How would I do that?
Thanks again
Aha! So, are those pre-built values buried in the entries like:
{ "Fujifilm X-T1", 0, 0,
{ 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } },
or if not where to find them in the code and how do they get propogated into pre_mul?
Many thanks
David
Of course, one may use pre-set WBs if extracted from camera metadata.
D65 multipliers are pre-built, so there is no daylight WB for unsupported cameras.
I'm sorry but it appears frm the output of raw-identify that the Libraw code has derived the pre_mul values from the D65 illuminant WB coefficents and other information returned in the raw file for the X-T1. I cannot see where else these
Derived D65 multipliers: 2.147247 0.934710 1.221633
values which are the contents of the pre_mul array could have come from (unless they are hard coded into LibRaw). A pre_mul array with all values set to 1.0 by LibRaw just doesn't make any sense for processing a raw fille for Daylight WB.
So again I ask you how is pre_mul set from the WB coefficients and other data read from the raw file, so I can better understand your code and maybe make contributions in the future.
I've already answered to that (1st/2nd replies in this thread):
LibRaw::COLOR(row,col) returns color index for (row,col)
So, for bayer, 4 calls for (0,0), (0,1), (1,0), (1,1) will give you bayer pattern used.
COLOR() == 3 is 'second green'
Thanks Alex,
I now have my application working. However, I have one last question.
Is it possible to find the Bayer filter pattern (CFA) from LibRaw? Basically, I need to establish if a specific camera is either:
I have looked at imgdata.idata.cdesc but this returns RGBG regardless of the camera in use. It seems that my Nikon DSLRs are using BGGR but Canon cameras are using RGGB.
Is it possible to receive this information from LibRaw?
Many thanks for your kind help.
Amanda
Dear Sir:
"in none of those places does there appear to be any derivation of the pre_mul
value from the WB Coefficients, even though it is clear that such a
derivation must take place."
No, it mustn't, unless WB coeffs are user-supplied.
Yes, I totally understand its not supported in the current release, but it would nonetheless be very helpful to me if you could provide some understanding of how your code works in this area.
You are correct CM2 means nothing to me at all.
in none of those places does there appear to be any derivation of the pre_mul value from the WB Coefficients, even though it is clear that such a derivation must take place.[/geshifilter-c]
Dear Sir:
> Why are you not providing me with a helpful explanation of what is happening here
> a helpful explanation
The camera is not supported in the version you are using, right? So, what do you expect to be helpful? I'm at loss, since "CM2" obviously means very little to you.
> where in the LibRaw code the pre_mul value is set from the White Balance Coefficients
What does search for pre_mul return?
I have to say that I don't understand your approach to my enquiry. Why are you not providing me with a helpful explanation of what is happening here, rather than just pointing me to the source code and say "go figure it out yourself". I have to question the point of having a LibRaw support forum here if the people who know the code won't explain why something isn't working in the way that someone trying to use it expected.
I was already aware of the annotated DCRaw web-site and have been there a number of times. On this occasion however I am still completely in the dark as to quite where in the LibRaw code the pre_mul value is set from the White Balance Coefficients, and very specifically I don't understand quite why pre_mul was set to values of 1.0 for the unsupported X-T3, but was set to useful values for the X-T1.
I don't want to add support for the camera in question to libraw in the current release. I realise that it will very likely be supported in the 0.20.? release as I believe it is already supported in the snapshots.
Dear Sir:
The camera is not supported in the LibRaw version you are using, that's why the derived pre-muls for daylight are not available. If you want to support it instead of waiting for the next release, you need to spend some time familiarizing yourself with the code. The link I've provided above should be very helpful.
Iliah, please will you bear with me. I've just spent a whole day chasing this problem.
I *still* don't understand why pre_mul was set to 1.0, 1.0, 1.0 for the Fuji X-T3, but was set to relevant values based on the D65 Illimunant White Balance values for the X-T1.
I had already searched the code looking for everywhere that pre_mul[] values are set and for the life of me I couldn't find the code that converts the WB_Coeffs to the pre_mul values. OK you may think I am stupid, but please I'm looking for assistance here, not a pointer the annotated DCRaw code.
Please start here https://ninedegreesbelow.com/files/dcraw-c-code-annotated-code.html
I tried to find the code that sets pre_mull from the d65 coefficients and totally failed. Where is it please?
Dear Sir:
Criticism is welcome, that's how we improve.
"Uncalled for" also means "unnecessary" and "unfair". Everything was right in front of you, please pay attention.
I'm not going to continue this discussion, let's stick to questions and answers that are relevant.
Pages