White balance offset (for IR work)

I want to migrate to RawTherapee, but it has a little problem with my infrared pics: they are extremely purple, and the white balance tint slider in RT maxes out at 5000, resulting in a color cast. I made a profile with Adobe DNG Profile Editor to compensate for it, but the maximum possible offset this software allows for is still not enough (but not far from it). Any idea how could I offset it a little more, or trick RT to accept tint values of over 5000?

Thanks in advance!

PS: I already tried to de-compile the resulting DCP with DCPTool to XML, along with a reference profile with no offset to spot what is different between them, hoping that it’s a single value that can be changed manually, but unfortunately this turned out not to be the case.

Probably doable with the channel mixer.
Could you upload a sample raw file? http://filebin.net/

Here you are:
http://filebin.net/fsy4xpevcw
It contains two RAWs, an “official” one from a Canon Powershot G9, and one from a Powershot A480, generated by CHDK. Both are affected :frowning:

The channel mixer can indeed correct it, but since it does its work after the white balance, it must be meticulously adjusted every time the WB is changed (I don’t use fixed WB for IR), and to make this workaround yet more complex to implement, I already use the channel mixer for IR pics in a creative way (not just for swapping red and blue).

A WB-biasing profile seems to be the ideal workaround, but using DNG Profile Editor I’m unable to add enough bias, the maximal -100 this software allows for on tint is just not enough (but almost). Does anyone know any SW that can maybe do more?

Which part of the picture do you want to neutralise? The foliage?

I’m asking because in RT I get a white foliage when using the CAMERA WB preset with the G9 picture…

Oops, I chose a poor sample to upload :dizzy_face:, I simply thought it’s better than the ones I experienced the problem with, without actually trying it out, as I was in a hurry. With that particular pic, the eyedropper works as well (but a little cast still remains). And it belongs to the absolute minority. Sorry :disappointed:

Try this one, this has been tested to be problematic:
http://filebin.net/v066swwqzn

No matter what you try to neutralize, the purple cast remains, and the tint slider slams loud into the stop at the green side.

Here is how a simple spot WB on the lower-right trees renders your last image in PhotoFlow:

The WB in photoflow is mainly defined and computed via direct RGB multipliers, hence the WB adjustments can be made almost arbitrarily large. The temperature/tint values are only secondary representations, which by the way have larger ranges than in RT (at least for the tint).

I meant another profile editor, capable of producing more offset :slight_smile: I’m currently pretty satisfied with RT, and it would be too bad if it could not be used with these IR pics.

I checked out Photoflow (newest Windows release, v0.2.5), but that version looks somewhat different from your screenshot and is still unusable (no way to actually measure WB after choosing “spot”). Anyway, while it might become a very potent tool in the future, it’s currently far from being ready for actual use. I’m also somewhat pessimistic about its future - projects aimed at advanced users inherently have serious difficulties nowadays, and I see many bad signs around this one :frowning: I hope I’m wrong, though. But Photivo, a similarly complex and powerful RAW processor was just one little step short of maturity when it failed :frowning:

Ooops! I definitely took your question the wrong way… sorry for that!

No doubt that the project is challenging… let’s see if I can prove you wrong on your conclusions one day or another :wink:

For the time being, I step out of the RT discussion as I’m no expert in DNG profiles…

Are you participating in that project? If so, I have a few ideas.

Well, I’m more than participating… I’m THE project :wink: (at least for the coding part).

Why don’t you open a topic in the PhotoFlow section here on pixls.us? Unless the discussion is also RT-related, in which case I’m fine to continue it here as well…

I didn’t know there’s such a section :wink: I’ll check it out.

@szgabor: It’s not more than changing two lines of codes in RawTherapee to solve your issue. I’ll push a change tomorrow. Thanks for reporting :slight_smile:

RT’s calculation of temp/tint has no relation on the dcp profiles … only depends on the D65 color correction matrix. Since the sensor responce is terribly different under IR vs D65 the resulted temp/tint are terribly wrong …

This matrix is either hardoded in dcraw (RT’s decoding engine) or defined in camconst.json so to give you freedom regarding temp/tint manipulations I “calculated” (it’s a guess work in fact …) one. Insert the following lines in your camconst.json file. For your experiments leave it as is (well maybe we could calculate a better matrix if we had a cc24 shot under IR …) … add // to comment out the IR matrix and delete the // before the dng matrix for normal work …

{ //   Quality X, experimental infrared support
    "make_model": "Canon PowerShot G9",
  //  "dcraw_matrix": [ 7368,-2141,-598,-5621,13254,2625,-1419,1696,5743 ], // DNG_V8.7 D65
    "dcraw_matrix": [ 15613,-6767,-2468,-1924,5307,221,323,-200,2196 ], // Infrared guessed
    "ranges": { "white": 4080 }
},

Thank you very much, it has solved the problem - at least for the G9. Unfortunately it doesn’t work with the A480 (DNG v1.3 RAWs, generated by the firmware hack CHDK, as this cheap cam doesn’t natively support RAW)

The end of my camconst.json now reads:

    { //   Quality X, experimental infrared support
        "make_model": "Canon PowerShot G9",
    //  "dcraw_matrix": [ 7368,-2141,-598,-5621,13254,2625,-1419,1696,5743 ], // DNG_V8.7 D65
        "dcraw_matrix": [ 15613,-6767,-2468,-1924,5307,221,323,-200,2196 ], // Infrared guessed
        "ranges": { "white": 4080 }
    },
    
    { //   Quality X, experimental infrared support
        "make_model": "Canon PowerShot A480",
    //  "dcraw_matrix": [ 7368,-2141,-598,-5621,13254,2625,-1419,1696,5743 ], // DNG_V8.7 D65
        "dcraw_matrix": [ 15613,-6767,-2468,-1924,5307,221,323,-200,2196 ], // Infrared guessed
        "ranges": { "white": 4080 }
    }
    
]}

A RAW sample has been posted already in this topic.

I can indeed shoot it, but only the grayscale row can be hoped to behave as intended in IR - depending on the colorants used. The other fields will just look “somehow”, as they haven’t been designed to look a particular way in IR. I guess most will look pretty whitish, as most dyes are transparent in IR, while some deep green and blue colored ones will be bluish, as these absorb the upper 60nm band transmitted by the filter responsible for all the more red colors. However, if you need samples of the extremes of colors to handle, I can produce them using LEDs.

The workaround does not work with DNGs because RT gives higher priority on the matrix which exists in DNG exif than the one in camconst.json

You have to change the colormatrix2 tag in DNg’s exif to
1.5613 -0.6767 -0.2468 -0.1924 0.5307 0.0221 0.0323 -0.0200 0.2196
if you want to try the same matrix. This matrix should be close enough for our job … But ideally we have to calculate a dedicated IR-matrix for A480. I will try later today based on the A480 IR-sample but it would be better if we had a cc24 shot …

Camconst.json item for A480, Crops black borders and pushes RT to calculate black level from optically black area.
The Daylight and IR matrix is inactive for DNG files, we need to edit DNG’s exif with exiftool

{ //   Quality X, experimental infrared support
    "make_model": "Canon PowerShot A480",
  //  "dcraw_matrix": [ 8275,-2905,-1261,-128,5305,505,52,482,2450 ], // DNG_CHDK_V1.3.0 Daylight
    "dcraw_matrix": [ 15906,-7425,-2014,-2010,5554,264,404,-265,2706 ], // Infrared guessed
    "raw_crop": [ 6, 12, 3684, 2760 ], // full size 3720X2772, official Canon crop 3648x2736 
    "masked_areas": [ 12, 3694, 2760, 3716 ], // only left side optically black area is considered
    "ranges": { "white": 4080 }
},

Edited sample (change matrix to IR) https://drive.google.com/file/d/0B0NqktTgc54sQjRaSnkwSDUySUk/view?usp=sharing

I think an acceptable approach for IR files would be a new option in Color management i.e. besides “no profile” (where no color correction nor color managenet is active). The new option should use unitary matrix (like “no profile” does) but activate the color management like “camera” option :slight_smile:

I have shot the CC with both cameras: http://filebin.net/7q0yhn6n0l
They look in IR exactly like I expected :slight_smile:

Which tools do you use to calculate the matrices?

Is this change already implemented?

I have found that someone has the opposite problem, the range of the tint slider being too large. I think the optimal win-win solution for the future is a “windowed” slider: the text box should have a bigger range (0-7000), but the slider should have a smaller (0-4000). The latter should be automatically shifted to 3000-7000 when the slider gets released above 3500, and back to 0-4000 if released below 3500.

After Ilias posted a good solution for this Issue via camconst.json, I didn’t make changes to the slider.

Good solution? As he pointed out, the camconst.json alone won’t solve the problem for the DNGs. The EXIF data must still be manually edited for each file. It’s better described as a workaround.
It’s also no perfect solution even for the CR2 files from the G9, as I shoot both IR and visible light pics to achieve special effects, necessitating repeated editing of that file.

Where should I look for those 2 lines you mentioned? I plan to create a personal version anyway in the middle future (after dusting my programming skills a little :slight_smile: ), with some special filters for scientific use.

Also, could someone tell me how to calculate the matrices, as ilias_giarimis did on a suboptimal shot before I posted the pic of the CC?