This article desribes how to postprocess and install denoise profiles that have been manually created for darktable. By “installing”, I mean to make the denoise profile available in the productive darktable library, which is usually located at ~/.config/darktable/library.db .

Obtaining a denoise profile

There is already a very good tutorial and excellent tool support for determining a camera’s noise profile. The profiling produces two major artefacts:

  • presets.txt contains one or more array items that can used while compiling darktable
  • library.db an SQLite library that may be used to evaluate the new denoise profiles on the fly by running darktable as follows:
    darktable --library library.db

     

I will now describe how to optimize and export the denoise profiles from the SQLite library.

For visual inspection, I recommend the Firefox addin SQLite Manager. For batch processing, I use the command line tool sqlite3, which can be installed as follows:

sudo apt-get install sqlite3

The generated denoise profiles can be found with the following SQL query:

SELECT * FROM presets WHERE operation="denoiseprofile"

You recognize the camera that you just built the denoise profiles for in the name column. In this article, I use the Canon EOS 100D as a running example:

SELECT * FROM presets WHERE operation="denoiseprofile" AND name like "Canon EOS 100D %"

Postprocessing (optional)

Looking  at the further columns, you will notice filter criteria such as model, maker, lens, exposure_{min,max}, aperture_{min,max},focal_length_{min,max}. The column filter determines whether (=1) or not (=0) each row is only displayed in darktable only if the current image matches the filter criteria.

The following SQL code adjusts the filter criteria for each denoise profile for the Canon EOS 100D separately. The values for model and maker have been extracted from the image information as shown in darktable.

UPDATE presets SET 
  model="Canon EOS 100D", /* same as the model recognized by darktable/exiv */
  maker="Canon",          /* same as the maker recognized by darktable/exiv */
  lens="%",               /* apply to any lens */
  exposure_max=3.4e+38,   /* maximum possible value -> always applicable */
  aperture_max=3.4e+38,   /* maximum possible value -> always applicable */
  focal_length_max=1000,  /* maximum possible value -> always applicable */
  filter=1                /* enable filtering, only show if applicable*/
  WHERE operation="denoiseprofile" 
  AND name LIKE "Canon EOS 100D iso %";
UPDATE presets SET iso_min=100,iso_max=100  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 100";
UPDATE presets SET iso_min=200,iso_max=200  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 200";
UPDATE presets SET iso_min=400,iso_max=400  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 400";
UPDATE presets SET iso_min=800,iso_max=800  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 800";
UPDATE presets SET iso_min=1600,iso_max=1600  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 1600";
UPDATE presets SET iso_min=3200,iso_max=3200  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 3200";
UPDATE presets SET iso_min=6400,iso_max=6400  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 6400";
UPDATE presets SET iso_min=12800,iso_max=12800  
  WHERE operation="denoiseprofile" 
  AND name = "Canon EOS 100D iso 12800";x

If this SQL code is stored in the file postprocessing.sql, the following Bash code can be used to perform the postprocessing:

cp library.db library_before_postprocessing.db
cat postprocessing.sql | sqlite3 library.db

Afterwards, you may re-check that the columns have been filled out approrpiately:

SELECT * FROM presets WHERE operation="denoiseprofile" AND name like "Canon EOS 100D %"

Installing denoise profiles

To make the (optimized) denoise profiles available in your production database, execute the following line of Bash code inside the folder where the generated library.db is located:

echo ".mode insert presets
.out exported_presets.sql
SELECT * FROM presets 
    WHERE operation = 'denoiseprofile' 
    AND name LIKE 'Canon EOS 100D %';
.quit" | sqlite3 library.db

Afterwards, the SQL file exported_presets.sql contains INSERT statements that can be imported into the production database, which is normally located at ~/.config/darktable/library.db. The following Bash code (to be executed in the same folder where exported_presets.sql is located) performs this step and additionally creates a backup of the previous state of the database.

cp ~/.config/darktable/library.db ~/.config/darktable/library_$(date +%Y-%m-%d_%H-%M-%S).db
cat exported_presets.sql | sqlite3 ~/.config/darktable/library.db

Uninstalling denoise profiles

If you are unhappy with the denoise profiles, the following command may be used to uninstall a preset from the production database:

echo "DELETE FROM presets 
    WHERE operation='denoiseprofile' 
    AND name LIKE 'Canon EOS 100D %';
.quit" | sqlite3 ~/.config/darktable/library.db

 Downloads

I provie all scripts and the generated library/presets.txt for the Canon EOS 100D and the Nikon COOLPIX P7700: