Recent comments

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

Oh, so this won't work for a photo of the sea and sky, or a forest canopy with little sky, etc.
I will take a look at that code after I finish some other things, thanks!

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

sorry for geshifilter-c in previous message, sometimes code formatter on our site works strange :)

this is just [ c ]

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

There is no exposed function.

You may steal code from internal\dcraw_common.cpp:scale_colors() function;

Starting with

  if (use_auto_wb || (use_camera_wb && cam_mul[0] == -1))
  {

And up to final calculation of pre_mul:

 pre_mul[geshifilter-c] = dsum[c + 4] / dsum[c];


This code cycle through image[] 8x8 blocks, skip blocks with data near sensor saturation and calculates pixel sum/count for other (non-saturated) blocks to get mean per-channel values. This code assumes entire image is (average) gray. If not, auto-WB will not work well.[/geshifilter-c]

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

Sorry, I meant if there was a way to get the auto WB. I know I can get the "as shot" WB.

Right now, I do things like this:
Init, open, unpack, raw2image, black subtraction, apply WB, debayer, sRGB, gamma curve then I do things like contrast and saturation.

Is there a function I can call after black subtraction to make LibRaw return an auto calculated WB, preferably accessible from C, without doing further data processing?

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

as-shot balance (cam_mul) is avaliable just after LibRaw::open_file()

To calculate auto-wb you may use raw data with black subtracted (Libraw does this at LibRaw::scale_colors() call, before interpolation step)

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

I meant, if there was a way to only get the WB, without fully process the image (so that I can do my own processing).

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

params.use_camera_wb will force to use As-shot balance
params.use_auto_wb will switch to auto-balance
params.user_mul[4] allows to use user-specified WB

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

Any idea how RawTherapee gets it right?
Is there a way to force LibRaw to manually calculate the WB and put it in cam_mul or something like that? Or is it too orthogonal to it's purpose? :)

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

Also, with as-shot balance sky is 'too cyan' in FastRawViewer, that also points to not-so-correct embedded color profile.

Reply to: Oneplus 5 DNGs don't look right   6 years 12 months ago

From _01.DNG sample, using raw-identify -v:
Makernotes 'As shot' WB multipliers: 2.031746 1.000000 1.729730 0.000000
and
Derived D65 multipliers: 6.630021 0.866640 0.901968

This file is shot under daylight, so D65 mutipliers looks incorrect: too weak for blue and too strong for red.
D65 (daylight) multipliers are calculated from DNG ColorMatrix* tag(s). So, embedded profile for this file looks incorrect.

Use as-shot, or auto WB for this camera (I do not see any way to do this automatically in LibRaw because pre_mul is within 'more or less correct values' (6.63/0.86 = 7.7 does not 'high enough' to throw it out automatically)

Reply to: RGB color transformation   6 years 12 months ago

On a side note, there is no such thing as cross-sensitivity because red, green, and blue are what CFA says they are. For a serious work, sRGB is a sub-optimal choice, because a lot of colour clipping happens when converting CFA RGB to sRGB (all the negative values from such a conversion are clipping). For better colour, try computing a colour matrix for your particular camera.

Reply to: RGB color transformation   6 years 12 months ago

My understanding is that vendors keep those values secret, so probably the best results are form the raw editor from the manufacturer (Canon). I've also noticed that compared to my program (which uses LibRaw) RawTherapee has slightly different colors, but I haven't investigated if it's the WB, the sRGB matrix, or the tone curve.

Once I finish with everything for my program, I might take a look at their source code and see if I can understand it, and see what's different.

Reply to: Getting crazy cam_mul values   6 years 12 months ago

That makes sense, thanks for answering :)

Reply to: Getting crazy cam_mul values   6 years 12 months ago

LibRaw's goal is to provide access to raw image data either in source form (LibRaw::open_file/unpack) or in processed (LibRaw::dcraw_process())

There is no intention to expose internal sub-functions, this is orthogonal to library purpose.

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Well, it is my understanding that LibRaw can export fully debayered TIFFs, and that there are various debayering algorithms built in (and some that can be added separately).
I am not sure how the internals work, but it would be very useful if either image[] array was fully populated or there was some other array with the proper RGB values.

I tried implementing a few debayering algorithms in my project, but then eventually gave up (I wasn't getting the results I wanted) and just used the quarter of the resolution debayering method, since that should be enough for my project (a program used for making timelapse videos, where any photo 12MP or bigger can yield enough information for a 1920x1080 movie frame).

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Could not understand what part of debayer code you want to export (to C-API?).

LibRaw's debayer code uses lot of internals (image[] array, CFA pattern, etc) and not intended to be used alone.

Reply to: Getting crazy cam_mul values   6 years 12 months ago

I am glad it helped :)
While I am at it, to not open a new thread, would it be possible to expose to C the debayering functions? Maybe I missed something, but I don't think they are exported in C.

Reply to: RGB color transformation   6 years 12 months ago

So far, things are clear. But what's about the sRGB stuff?
I've compared DCRAW (with and without use of rgb_cam matrix filled in by the adobe_coeff()) to FastRawViewer and also to the Canon software and got 4 different results! DCRAW with use of rgb_cam looks worst (warm & greenish look).

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Got it, thanks

Yes, AsShot white balance is broken in DNG tags:
| 25) AsShotNeutral = inf 8.872800664e-007 200 (1000/0 1000/1127039858 1000/5)

LibRaw by default uses daylight WB (calculated from ColorMatrix* DNG tags), so it works ok. If camera WB is specified explicitly (params.use_camera_wb = 1), than image becomes wrong (as expected).

Looks like we need additional check for camera WB range and fallback to Auto if camera wb looks corrupted.

Thank you for the sample.

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Ok, I sent it :) I hope you got it, since it's a large-ish file :)
Let me know if you find anything wrong with it :)

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Yes, we collect any 'strange' DNG/RAW files to make sure LibRaw works fine even in corner cases :)

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Sure, I will send it. But actually, I know what the problem is, I just remembered. The camera is a Canon SD980 running CHDK, and I helped porting that CHDK version (at the time this camera was using a newer API set, so CHDK didn't work on it, it needed quite a bit of reverse engineering). And the port might have had some stuff missing.
The interesting thing is that all programs I tried worked fine with it, so I guess they had some detection for invalid Wb settings, and calculated their own.

So probably the DNG is not too useful for you, as only my camera is affected by it (all my other RAWs from other CHDK cameras are OK). But if you still want it, I can send it to you.

Reply to: Getting crazy cam_mul values   6 years 12 months ago

Use daylight or auto multipliers if camera WB looks wrong (as in this case). As a general rule, red/blue multipliers should be in 0.05..20.0 (or may be less) range after normalization (green one set to 1.0)

BTW, could you please share this DNG (e.g. send link to info@libraw.org if you do not want to share it public) for detailed examination?

Reply to: RGB color transformation   6 years 12 months ago

I use the cam_mul for WB, and then do the debayering (manually) and after that I do the sRGB stuff.
You also have to do channel clipping before the sRGB conversion (and optionally highlight recovery).

Reply to: Variable Contrast   7 years 4 days ago

Fantastic! Thanks for the recommendations!

Pages