Nikon HE* decoder

I spent the last month having a fun little science project. Even though not owning a Nikon camera at all, I tried if it’s possible to get a working decoder for the HE* bitstream with the help of Claude. When using samples from:
https://photographylife.com/nikon-z9-sample-images-raws (all copyright belongs to the author) the decoder produces this:

So you can see the colors are still off even when using WB coeffs from the EXIF and Color Matrix from Adobe. So the inverse MCT is still wrong. A few wavelet errors here and there also say the bitstream is not properly decoded yet. But actually I’m quite happy about my science project.

I guess it was illegal Claude activity and would involve IntoPix copyrights/patents if I publish the findings?

edit: Clarify

Interesting project, good going. This is known so far: JPEG XS - Wikipedia (see also link to IEEE paper).

I guess you should only take legal advice from lawyers…

P.S. This is not about copyright, but patent.

1 Like

Yes we started with the reference decoder and worked from there. Several design decisions had to be made underway. All four components look almost fine but not perfect. But I guess I lack the knowledge to go on as it’s, I guess, a few mathematical decisions away from being correct and I have zero knowledge, ok I learned a bit on the way, about decoding file formats

Not a lawyer, but my understanding is that reverse engineering and publishing the results, including code, is not illegal. However, actually shipping the code in a program could get you in trouble. There’s precedence with the LAME MP3 encoder and some video codecs.

There are organisations such as the EFF that it might be worthwhile asking.

1 Like

Thanks for the paper. Implementing the star tetrix inverse contrast looks much closer to the original yet of course a purple layer on top. But this is definitely the right direction to pursue further

Let’s see what we come up with once the session limit resets :wink:

Image credit: https://photographylife.com/nikon-z9-sample-images-raws

1 Like

Vaguely looks like missing/insufficient black level subtraction…?

Black and white levels are included in the decode process. Let’s see what happens next, I still have a few ideas

Good idea. I wrote to the EFF. Let’s wait and see. I’m also stuck. I guess people who know more about file formats would immediately see what’s still wrong, so hoping I can publish it soon.

Let me collect some ideas here maybe. I’m still having problems with the “R” channel which is noticeable more smeared (looks like another layer on top) it also suffers from some banding at some precinct borders. So far nothing worked. I looked up some papers and with a guided filter and neighbor smoothing this goes away but this is much too expensive to be used by Nikon. Also the Adobe converted DNG looks much more detailed.

And preiMCT:

Also I’m seeing lots of energy pulsing still, hope this is the right name.


I don’t know whether those are just compression artifacts that need to be smoothed out as well or if I’m seeing decode errors here. Those are spread over all components. Also in “G1” you can see some stray lines. But it might also be that those components are something else completely.

Original image credit: https://photographylife.com/nikon-z9-sample-images-raws

1 Like

But I guess the iMCT might even be simpler as this give much more detail but wrong colors


Original image credit: https://photographylife.com/nikon-z9-sample-images-raws

Still broken but at least I can create DNGs now that open in darktable:


Original image credit: https://photographylife.com/nikon-z9-sample-images-raws

4 Likes

I believe comp2 and 3 are not yet properly decoded giving us crap data in the final image.

A bit of progress. The G1/G2 difference should not get wavelet transformed and looks like proper data now:

Comp3 is still wrong

some metrics for the inclined


1 Like

Wow! Nice work! I have been in contact with Nikon about the ability for them to provide an open source decoder but they couldn’t.

I have access to a Z8. If you needed more / specific images please let me know!

I guess there’s still something not quite right with the R channel?

The large differences in R/B might also mean there is some pre-WB (and subsequent removal of the same) going on at some point…?

getting better

and yes, I haven’t found a way to get rid of the crappy banding (yet)

It’s IntoPix you should be asking, since that’s where Nikon licensed the format from.

IntoPix, and they call TicoRaw, isn’t?

shapes are almost identical now

1 Like