KentuckY Raw Error Modeler

KREMY (KentuckY Raw Error Modeler, pronounced "creamy") is a free software tool created to improve the quality of raw image captures -- potentially simultaneously improving SNR and resolution. The interesting thing is how KREMY works: it isn't using deep learning nor any of the traditional image denoising nor sharpening methods. Instead, it begins by creating a model bounding pixel value errors. It then uses the captured pixel values as initial estimates of the true scene values while applying texture synthesis to refine pixel values to be more contextually-consistent -- without violating any of the computed pixel error bounds. Put simply, iteratively refining pixel values to be consistent with more constraints tends to converge toward the true pixel values.

There is now a "Beta Test" version running on one of our servers that you can use via a WWW browser:

Some History

KREMY was first developed in 2016, motivated by the fact that the algorithms originally created for the repair of a specific type of encoding defect in compressed Sony ARW files (credible repair implemented in KARWY) also tended to improve the image quality where there were not obvious defects. The method originally used in KREMY is detailed in the paper Refining raw pixel values using a value error model to drive texture synthesis (slides, full paper), which was published at Electronic Imaging 2017. The new 2021 version uses a very similar approach, but modeling pixel errors as a probability denisty function, which makes it much better at handling very noisy images.

The catch is that the C code originally implementing KREMY used a combination of dcraw and Adobe DNG Converter (ADC) to read-in a camera raw file and output a hopefully-improved raw DNG. Unfortunately, dcraw stopped being maintained in 2018, and ADC mutated and also is no longer easily run in a Linux environment. That combo meant that within a year, KREMY's code wasn't immediately useful... and so it stayed... until September 2021.

In September 2021, we realized that there are some potentially less-kludgey ways to implement KREMY. It's a very long story, but we started by building a version using the open source tool raw2dng, which uses LibRaw to read raw files and then outputs a DNG. I had hoped to run that entirely within a user's local browser using Emscripten, which I had used before for KARWY-SR. However, Emscripten has changed (now generating WASM code rather than JavaScript) and getting raw2dng and all libraries to work inside a browser proved problematic. So, I revisted other options and, after several not-ready-for-others-to-use reimplementations, I was able to upgrade the original version to use the new model. The WWW form test framework is a terrible kludge, again running Adobe DNG Converter under wine to make an uncompressed DNG out of whatever raw file is submitted, but it does work well enough to let people try it and give feedback....

Current Status

The current version only works with camera raw files that Adobe DNG Converter can convert into uncompressed DNG files with 16-bit pixel values and a CFA (color filter array) that can be effectively modeled as a 2x2 repeating 4-color pattern. For example, it will not work with raws from Fuji cameras that have more interesting CFA patterns. The result is a hopefully improved raw, returned as a losslessly-compressed DNG. However, KREMY's transformations are not reversible, so you should probably keep the original raw file around as well.

To evaluate and tune the new KREMY, we have been using many test images from a wide range of cameras, and DPReview's studio test scene serves well, especially for cameras that we do not have direct access to. We have posted an overview of what we're trying to do in the Photographic Science and Technology forum at DPReview, including before/after JPEG renderings of DSC00315.ARW, the DPReview ISO 25600 test scene shot by a Sony a7C, as processed by standard and KREMY-modified raw2dng, with "neutral" JPEGs produced using rawtherapee. Although we're still tweaking the new KREMY, here are two DNGs showing what (internal version "k") can do:

The current KREMY version, linked above, is more than a few generations beyond that. You can try it out using the WWW form to apply the processing to images using one of our servers. In this way, people can try it without having to install any software. Once the tweaks are settled, we will distribute KREMY's C code as full open source.

If you have any comments or suggestions, you can send them to Professor Hank Dietz or, better still, post in the DPReview forum thread about this.


The Aggregate The only thing set in stone is our name.