How do dt/rt edit raw photos?

Hello all,

I’m new here and just have a general question. I know how to program and I also really like taking pictures. But what I am very interested in is how Raw developer process/develop photos.

I understand that the steps are captured in XMP files. But then? What happens if I change the exposure for example? Is a copy of the photo made and the bytes are processed or is the photo converted to a TIFF and processed?

I would very much like to learn something about this!

Thanks!

Greetings
Jan

Neither change your raw file. When you export the editing result, you get a new (tiff, jpg etc.) file. Is that what you meant?

The input is your raw file.
The processing steps you request (and those applied automatically) are recorded in the sidecar (pp3 or xmp or some other) file, or in a database. When you export, a new file is created.

Raw file: raw ingredients
Sidecar: recipe
Export: cooking

:slight_smile:

The main difference is that you may ‘cook’ the same ‘ingredients’ several times, to produce several, differently prepared ‘dishes’.

1 Like

Hi @yeahitsjan and welcome! If you’re curious about this stuff, then this is the right place to be! We have a bunch of very smart and friendly people. Buckle up, as @ggbutcher will certainly attest, this is a deep rabbit hole :slight_smile:

For starters, do you understand how your camera collects data into a raw file? Do the terms Bayer and Color Filter Array mean something to you?

2 Likes

Developing raw photos takes many steps, including: transforming colours from the camera primaries to some standard colorspace (eg REC2020 or sRGB), demosaicing, and a transfer function. Those are essential processes, the “guts” of development. There are many optional processes: denoising, increasing local contrast, sharpening and so on.

If you know how to program, then you might get the source code of the programs you are interested in. If you are mostly interested in the “guts”, I suggest you obtain libraw. Read the libraw programs and play with them, and write your own simple programs that call libraw functions.

The “optional” processes might be more understandable with non-interactive software such as G’MIC or ImageMagick. These programs are low-level, totally different to the high-level GUI packages. But they may be more helpful when trying to understand the basics of image processing, and how they are implemented in code.

2 Likes

First of all, wow! Thanks for those responses and that warm welcome. Feels already like home here.

Thats what I am sure about. What I meant was that what happens exactly when I increase the exposure for example under the hood :slight_smile:

I work for a camera manufacturer, so I’m glad I’ve had the opportunity to read up on that. So yeah I know these terms and they mean something to me (atleast a bit) :smiley:

I already played a lot with libraw and have some apps running that can display Raw images and get thumbs out of it. I don’t think libraw allows me to manipulate raw images?

I also already played with both, but I don’t think they support raw images, too.

What I mean generally is what internal things do dt/rt use to edit/manipulate them, like:

Input is a raw > Imported into dt/rt > Display > user selects to increase exposure (what happens here and how they manipulate the image to let it display the changes?). I already looked up a bit code but it felt quite complex to understand what exactly happens there. The only thing I learnt from there at the moment is that every change is listed inside a sidecar file.

Many thanks!
Jan

… what happens exactly when I increase the exposure for example under the hood

Personally, I hate that expression. The exposure is determined when the camera shutter is triggered, and can’t be altered after that time. “Increasing the exposure” in software simply increases the pixel values, usually when they are still linear (ie proportional to the energy received), usually by simple multiplication (eg multiply by 4 to get two stops exposure increase), possibly with a curve at the high values like a shoulder in a film response curve, or that may come later in the pipeline.

I work for a camera manufacturer, …

Ah, excellent! Can you tell us the secret sauce used by that manufacturer for creating a JPEG from the raw image? [That’s a joke, because they would probably fire you, or worse.]

I don’t think libraw allows me to manipulate raw images?

It does. For example, we can split a RGGB Bayer image into the four channels, denoise them, and re-combine them before demosaicing. ImageMagick can’t do that. When IM reads a raw image, it calls libraw to demosaic etc. But we can use a home-written software, or libraw programs, to extract the data, then manipulate it with IM.

dt/rt are black boxes, somewhat. To appreciate what they are doing under the hood is easier if we replicate the actions in lower-level programs, in my opinion. For example, we can demosaic and “change the exposure” with G’MIC or IM, and easily see exactly what the code is doing.

2 Likes

You may want to read Developing a RAW photo file 'by hand' - Part 1 (and part 2, linked at the end of that article).

5 Likes

Okay, I haven’t really touted it yet, but you might be interested in my software…

When I re-started photography in digital, I also wanted to understand the process. I spent a lot of time experimenting with G’MIC, a command line image processor where you add tools one-by-one on the command line and are able to see their incremental effect. It doesn’t ingest raw files directly, but you can pipe the output of dcraw to it as described here:

https://github.com/dtschump/gmic-community/wiki/Developing-raw-images-with-G%27MIC

I became enamored with the “tool chain” approach to raw development, so long story short, I ended up writing my own software. It’s called rawproc, a GUI program that allows you to open a raw file and add tools one-by-one to develop it into a pleasing image. You can select any of the tools in the toolchain you built for display. You can delete, add and insert tools in any order, to your benefit or detriment. It also comes with a G’MIC-like command line tool that implements most of the same tools found in the GUI program. I’ve developed it to the point where I use it exclusively for my image processing, except for retouching tools for which I use GIMP.

It’s missing some things, like the dual-demosaics of RawTherapee and the tone and color manipulation tools of darktable, but it has all the tools I need to develop proof and final renditions of almost all of my images. Oh, it’s also a bit of a memory hog, as it maintains in-memory the product of each tool, which serves as the input to the next tool in the chain. So, if you’re using something with a large sensor like a D850, you need a LOT of RAM. Sorry, I don’t apologize for that, it’s the fundamental way rawproc is able to be an arbitrary toolchain program in an interactive way.

You’re welcome to try it, from here:

https://github.com/butcherg/rawproc

In the releases page, you’ll find a windows installer and an AppImage for 64bit Linux, tested with Ubuntu, YMMV for other distros. You can also compile it from the source using the instructions in the Readme. In the program, you have access to a pretty complete help file that should explain most of what you need to use it.

Being able start with a really-raw image and experiment with different stacking of the tools was a significant learning experience for me. Well, so was writing (and using the excellent LittleCMS, librtprocess, lensfun, and exiv2 libraries). Anyway, if you give it a go, feel free to ask questions here and I’ll answer best I can.

Oh, welcome to the forum. discuss.pixls.us is a great place to study image processing, informative and sometimes lively discourse.

3 Likes

In a very very oversimplified way it works like this:

  • Import Raw data → create NxM matrix, one value per pixel
  • Demosaic → convert the matrix above to 3 NxM matrixes, 3 values per pixel (“color”)
  • Increase exposure by 1eV → multiply the 3 matrixes above by 2
  • Display the matrixes on screen, use one for R, one for G, one for B

In particular, for darktable the initial “raw” matrix and the final 3 matrixes used for display are kept in memory, and the intermediate steps are calculated on the fly every time you change a parameter on the GUI.

1 Like

Awesome resources here! Thanks to all, have definitely something to do over the coming weekend now! :heart_eyes:

Most is already covered, but here’s some more introductory reading for future reference:

https://rcsumner.net/raw_guide/index.html

The last two provide Matlab/Octave examples if you want to play around.

2 Likes