Spektrafilm darktable module implementation discussion

spektrafilm banner
for darktable

Notes:
All development happens here now: Spektrafilm (dev branch) analog film simulation module by piratenpanda · Pull Request #21534 · darktable-org/darktable · GitHub

For a current patch file just add .patch to the URL https://github.com/darktable-org/darktable/pull/21534.patch

Instructions on how to create the spektrafilm data are in the second post

You can find a comparison tool for the original implementation here

About this module:
This module brings the spektrafilm project (GitHub - andreavolpato/spektrafilm: Spectral simulation of analog photography processes · GitHub) by Andrea Volpato (buy him a coffee will you?) to darktable. Spektrafilm simulates analog film processes and applies them to digital images.

This module has been derived from the spektrafilm code and tries to stay as close or exact to the algorithms used there.

Currently the module looks like this:
grafik

Film and print stocks can easily be selected via drop downs. Further settings are then handled inside the respective tabs (currently untranslated).

Default settings are Portra 400 and Portra Endura which transform your image from
grafik

to
grafik

Currently almost every film/paper combination from the spektrafilm dev branch is working except for Kodak 2302. Grain, Halation and Diffusion models are working as well.

Current dtdocs PR darktable-org/dtdocs#993

11 Likes

In the meantime I made myself a proper native spektrafilm module which currently looks like this:

Needs this python script to run with an official spektrafilm installation (currently dev branch only) before:
spektrafilm_export_data.py (10.8 KB)

# install dev branch in a venv 
python -m venv ~/venv-spektrafilm-dev
~/venv-spektrafilm-dev/bin/pip install git+https://github.com/andreavolpato/spektrafilm@dev

# then run the python script
~/venv-spektrafilm-dev/bin/python spektrafilm_export_data.py -o ~/.config/darktable/spektrafilm
9 Likes

Great! Can I try it in windows?

I’m using it on Arch Linux and don’t know if Windows needs something specific but it shouldnt. In my PKGFILE I do (depending on where the patch lives of course):

  git apply ../../spektrafilm-native-module-v8-full.patch

so if you are used to compiling darktable on windows just try it like that

Most likely you’ll also have to point the python script somewhere else (don’t know much about running dt on windows)

1 Like

Is there any difference between using the LUTs and the native algorithms?

I hope to have tested it enough so there shouldn’t be any obvious differences but of course I could have missed a few spots. The most obvious one is that this has per film grain as the original version does whereas the LUT module had a fixed amount of grain.

I love having this module available at the same time I feel bad for not understanding every single line of code there is. But as it’s just a play thing I guess that’s fine.

3 Likes

How is performance? This would be an awesome addition to dt!

1 Like

with the working opencl kernel it’s pretty fast

ah the gnome video recoder has too low resolution but I guess one can still see the almost instant reaction time on my RX 6700 XT

4 Likes

While I am opposed to LLMs for writing new things, particularly when the user isn’t even a programmer and understands what is being generated, for translating code from one software or language to another it’s a different thing in my opinion. This idea was well executed in the AgX module, for example, and as we can see from Kofa’s further work on darktable, a net positive overall.

Translating from one software to another also enables running tests to compare and validate that the output is the same across code bases.

1 Like

Yet in the current state I would not feel good to even think about a PR

1 Like

Thanks for providing this - really looking forward to see how this works in darktable.

I get the following error when running the export data script.

 File "/Users/myuser/GitHub/spektrafilm/spektrafilm_export_data.py", line 40, in _grain_export
    "rms_granularity": _widen3(gr.rms_granularity),
                               ^^^^^^^^^^^^^^^^^^
AttributeError: 'GrainParams' object has no attribute 'rms_granularity'

Commenting out the offending line, the scripts runs just fine and creates the data:

wrote /Users/myuser/.config/darktable/spektrafilm/pack.json (spektrafilm 0.3.4)

wrote /Users/myuser/.config/darktable/spektrafilm/spectra_lut.f32 shape (192, 192, 81)

copied 28 profiles (0 B&W widened to 3 channels)

I guess something is missing now, related to grain simulation, right? Anything else wrong (“0 B&W …”)?

For bw you need to run the Spektrafilm dev branch. I guess for all of it to work properly. Will provide more details on about what I did on my box tomorrow

This is how I did it, sorry for omitting that

# install dev branch in a venv 
python -m venv ~/venv-spektrafilm-dev
~/venv-spektrafilm-dev/bin/pip install git+https://github.com/andreavolpato/spektrafilm@dev

# then run the python script
~/venv-spektrafilm-dev/bin/python spektrafilm_export_data.py -o ~/.config/darktable/spektrafilm

Thank you for this. Both the original spektrafilm and this module seem to require jumping through too many hoops for me to be comfortable trying them (what on earth does “baking luts” mean :smiley: ) but if the spektrafilm process ever makes it into stable dakrtable that would be spektracular (sorry for the pun, could help myself).

Much appreciated once again

2 Likes

Thanks for the reply. I guess I did more or less the same, but used conda.

However I was on the main branch, not dev. Switching to dev resolved the issue.

1 Like

Thanks again for this, great work - it was straightforward to integrate on macOS and now I’m playing with it :slight_smile:

One remark: in the reference python/napari implementation from Andrea the “film exposure” is by default automatically compensated for by print exposure going in the opposite direction. Apparently same here, so “film exposure” has no brightness effect except for positive films.
In Andrea’s implementation, that “print auto compensation” can be turned off, but that flag is not exposed in the darktable gui - it might make sense to either turn it off by default or to expose it too.

1 Like

edit: superseded by the PR

Thanks - works!

If anyone knows how to get it to work in Windows, I’ll be very grateful.

Are you already building darktable yourself? That would be a precondition.