If you want to play with Z 9 images in darktable...

You can insert this to adobe_coeff.c file:
{ “Nikon Z 9”, { 13389,-6049,-1441,-4544,12757,1969,229,498,7390 } },

and this to cameras.xml:

<Camera make="NIKON CORPORATION" model="NIKON Z 9" mode="14bit-compressed">
	<ID make="Nikon" model="Z 9">Nikon Z 9</ID>
	<CFA width="2" height="2">
		<Color x="0" y="0">RED</Color>
		<Color x="1" y="0">GREEN</Color>
		<Color x="0" y="1">GREEN</Color>
		<Color x="1" y="1">BLUE</Color>
	</CFA>
	<Crop x="0" y="0" width="0" height="0"/>
	<Sensor black="1008" white="15892"/>
</Camera>
<Camera make="NIKON CORPORATION" model="NIKON Z 9" mode="14bit-uncompressed">
	<ID make="Nikon" model="Z 9">Nikon Z 9</ID>
	<CFA width="2" height="2">
		<Color x="0" y="0">RED</Color>
		<Color x="1" y="0">GREEN</Color>
		<Color x="0" y="1">GREEN</Color>
		<Color x="1" y="1">BLUE</Color>
	</CFA>
	<Crop x="0" y="0" width="0" height="0"/>
	<Sensor black="1008" white="15892"/>
	<Hints>
		<Hint name="msb_override" value=""/>
	</Hints>
</Camera>

"
Enjoy

2 Likes

Will this apply to 3.8.1 or does it have to be git master?

If you build 3.8.1 from source, then you need to change both adobe_coeff.c and cameras.xml. Otherwise you cannot add support to already built 3.8.1.

For master, you can simply change your cameras.xml even after the build, but with the addition of color matrices, like this: Nikon Z 9 support (lossless only) by kmilos · Pull Request #347 · darktable-org/rawspeed · GitHub

Note that you only need the “14bit-compressed” section in any case, there is no uncompressed mode on the Z 9.

1 Like

I may have mis-understtod your reply. I have been running from master since you posted this:

" For master, you can simply change your cameras.xml even after the build,"

and I changed my cameras.xml. But I overlooked the next few words:

" , but with the addition of color matrices, like this: Nikon Z 9 support (lossless only) by kmilos · Pull Request #347 · darktable-org/rawspeed · GitHub"

Does this mean that until the PR is merged, even lossless compressed will not work?

Today I downloaded some sample images from mattgranger.com. Lighttable displayed them OK, but any attempt to read them in darkroom complained that it could not read the white balance information. I had assumed these were lossless compressed files, and exiftool shows:

File Type : NRW
File Type Extension : nrw
MIME Type : image/x-nikon-nrw
Exif Byte Order : Little-endian (Intel, II)
Make : NIKON CORPORATION
Camera Model Name : NIKON Z 9

Image Width : 8280
Image Height : 5520
Bits Per Sample : 14
Compression : Nikon NEF Compressed

I thought from that last line that this meant it was lossless compressed, but maybe the first line is showing otherwise (I have enquired of Matt Granger whether they are lossless or not - awaiting an answer). Since my own D810 files show:

File Type : NEF
File Type Extension : nef
MIME Type : image/x-nikon-nef

I guess I have downloaded HE* files. Is there a lossless compressed file available somewhere to download, so I can test my setup?

In dpreview, sample galleries, Nikon z9 production sample gallery you have jpg and raw files for download

Thanks. I tried a couple, and got messages about unsupported input profile replaced with linear REC709.
The images were sort of visisble, so I guess my setup is ok.

If you run master (and upcoming 4.0), then Nikon Z 9 support (lossless only) by kmilos · Pull Request #347 · darktable-org/rawspeed · GitHub is all one needs to be able to import “classic” lossless Z 9 NEFs.

Both classic and HE samples are available on RPU.

I tried one, and I get Unsupported profile has been replaced by linear REC709 RGB. And the image is largely magenta in hue.

This is not enough to identify whether this is “classic” lossless or HE, it just identifies a broad Nikon scheme. You have to take a look at the NEFCompression tag, which has changed location in Z 9 (but exiftool can figure it out anyway).

Works ok for me with the RPU sample:

Correct, you still need to manually add the full entry to cameras.xml for 4.0/master.

That image appears three times. With two of the downloads I get failed to read whitebalance messages. I assume they are the HE versions. With the first one I get the unsupported input profile message, and linear REC709 RGB is used, which results in a highly magenta cast.

Looking at my cameras.xml, and comparing it with your PR, I see I lack the ColourMatrices section. If I correct that, then it works fine.

Thanks.

REC709 probably shouldn’t be used as an input profile. It isn’t suitable generally.

It really is the very last fallback in dt, if everything else fails.

There’s a bit of term overloading here. Just glancing at the dt code, I think the comment is targeting profile transforms in general, whereas “input profile” in the UI is AFAIK about the specific camera profile, for which REC709 should definitely not be used…

@danny’s addition to the adobe_coeff.c file (post #1 in the thread) seems to be appropriate for a Nikon camera; I used those numbers to process a Z 6 file I had handy and the colors retain the hues originally rendered by the Z 6 matrix. With those, no need to specify a separate input profile.

But I can no longer see a file named adobe_coeff.c in master.

Just inspected my dt git clone, and yep, it disappeared from src/external. So, it looks like LibRaw is now the dt raw library (??), and the Libraw file with the adobe_coeffs is src/tables/colordata.cpp

But that file does not contain the characters “Z 9”, so perhaps that is why I needed to add the ColourMatrices element to my cameras.xml.

For the last time: there is no more adobe_coeff.c since 4.0/master. The matrices now come directly from cameras.xml, like all other rawspeed info. The original post was written in 3.8 release time. I was very clear that my PR applies to post-3.8 master, i.e. now 4.0 and later.

And yes, for the last time: the Z 9 support is not officially merged in (at the time of this writing), so you will have to add it manually to cameras.xml every time you build until it is.

Nope. This is true only for Canon CR3 raw files (ATM of course). All other raws are still parsed by rawspeed.

@ggbutcher Do you have a better suggestion on what the input profile should fall back to if absolutely nothing is available?

LibRaw’s colordata.cpp and rawspeed’s cameras.xml have nothing to do with each other (apart from mining their data from the Adobe DNG Converter output).