Converting plain RAW from imback to DNG

Hello, this is not exactly a darktable-only or rawtherapee-only question, if necessary please redirect me.
I have very raw (i.e. only the) sensor data from a device. 8 bit per sample, rows and column size known. I am trying to make DNG files out of the RAW data so that it can easily be processed with e.g. darktable. In the first shot, I was adding the plain minimum set of tags. Pictures looked greenish everywhere. Then I added AsShotNeutral [ 0.6 1 0.6 ]. Complaints about greenish got less. After playing around, I think that a better solution would be to multiply the green samples for green channel by 0.65 or so via color calibration (would look like [ 1 0 0 0 0.65 0 0 0 1 ](, that makes white balance a lot easier for me (less greenish sky, less purple where red). Well, I could do it in the conversion process itself… losing even more information (remember, just 8 bits currently). Can someone shed some light on what tags would need to be added and which should not be there for darktable, rawtherapee and reasonable other software to use the intended color calibration?
Thanks a lot in the name of the imback community…!

1 Like


You’ll essentially need to do some calibration using known light sources and a color chart to create an Adobe DCP (minimum tags are ColorMatrix and AsShotNeutral for at least D65 light as described in the DNG spec, section “Mapping Camera Color Space to CIE XYZ Space”).

Oh, and BlackLevel as well.


It looks like they reference or supply a tool… does it not work for you??

I am the author of that tool :wink: but it might not be as good as it could.

1 Like

Thanks! I’ll read and try

FWIW, this general scheme is trivially supported by adding

	<Camera make="?" model="?" mode="chdk">
		<CFA2 width="2" height="2">
			<ColorRow y="0">RG</ColorRow>
			<ColorRow y="1">GB</ColorRow>
		<Crop x="0" y="0" width="0" height="0"/>
		<Sensor black="0" white="?"/>
			<Hint name="filesize" value="?"/>
			<Hint name="full_width" value="?"/>
			<Hint name="full_height" value="?"/>
			<Hint name="offset" value="?"/>
			<Hint name="order" value="<? (plain|jpeg|jpeg16|jpeg32)>"/>

to RawSpeed’s cameras.xml (replace ? with appropriate values)

1 Like

Ha just noticed now…sorry for the noise…

will this specifically take into account scaling down the green channel?

Couldn’t you do that with the multipliers in het white balance tool ? Or do you really want to do it in metadata ?

Looking at normal raw files to see which tags set the white-balance multipliers may help you.

Can you contribute a sample from that device to ?

White balance multipliers for raw files correct the sensor bias vice the scene’s color temperature. Use the back to take an image of a know white reference (sheet of paper…) and load that image into a program that’ll white balance to a selected patch. Get those multipliers and load into the DNG AsShotNeutral tag.

1 Like

I did but can not find it in the Repos? Make ImBack, Type ImB35mm, 4608x3328 sensor data

Thanks, validated the sample, now it shows up.

Yes, don’t do that. Leave the raw data as-is.

No. RawSpeed is only for decoding the raw data, which is then handed over to darktable in a more useful format. DT then takes care of white balancing etc. Note that all raw files look green before being white balanced.

The RawSpeed camera definition does include the black and white points, which do affect the overall tint of the image. darktable 4.4 user manual - raw black/white point

Isn’t paper usually a terrible choice if you want accurate white balance? Typically white paper isn’t actually white, but rather “optical” white which is really a kind of blue.

Seems that for this, a proper color target is needed.

I’ve added basic support in

It loads just fine in darktable now:

Green-ness is normal and is fixed by applying spot white balance,
or a camera-neutral color balance (6502K), once there is a correct color matrix.

You need to find a physical color target somewhere,
and produce a proper color matrix for the camera,
because what you now embed is rather not proper :slight_smile:



Oh, probably, but would certainly render better than as-is…

Which also includes the grey patches one can then directly use for AsShotNeutral.

Thanks @LebedevRI ! I had the hope that I could embed as much as possible inside the DNG to make it as useful as possible for as many software processors as possible without having to add the specifics to each one. Any ideas in that direction?

There is no way around not doing the calibration w/ the colour target.