JPG to DNG or scene-referred editing of older images

I have come to love the processing available in darktable and I have images that are JPG that I would like to manage and edit within DT. I found that converting a JPG to PNG would then be recognized by DT, but the processing is not scene-referred.

Looking for ways to convert to DNG, I find

  • Topaz labs has a pricey solution
  • online conversion which I would like to avoid for several reasons

Any other approaches that people know of?

Thanks,

Eric

You canā€™t improve the jpg just edit that ā€¦conversion wonā€™t gain you anythingā€¦No matter what you do you have 8 bits of data to work withā€¦you canā€™t scene edit a jpg the scene referred data is long goneā€¦

I agree with @priort. A JPEG is only 8 bits per channel, and probably lossy-compressed. Only limited processing is possible before the data loss becomes obvious.

JPEG is an output-only format. Great for distributing the final version of an image, and lousy for anything else.

Of course, if you really want to, you could convert a JPEG image into some other format, such as a DNG. You could undo the sRGB transfer function to make it linear (kind-of, sort of). Some software claims to undo lossy JPEG artifacts.

And some software may exist that ā€œinventsā€ data to make the pixels 16 bits per channel. I would be surprised if that software didnā€™t exist. But I donā€™t know if it would be any good.

I did not understand this eitherā€¦jpgs are recognized perfectly by DT without any conversionā€¦perhaps that is not what you meant??

I suspect he is referring to this productā€¦ JPEG to RAW AI ā€“ Topaz Labs

I like how they are trying to portray a raw as being confined to Adobe RGB and the jpg can magically be better than the raw in Prophoto because it can make up all these colorsā€¦bit dishonest there

Agree completely with @priort and @snibgo, but the question got me to thinking, what would it take to back a sRGB JPEG out to a ā€œlargerā€ profile? I can see a path with tone, as the operations are reversible (ICC TRCs go from source to linear XYZ, etcā€¦), but I think color is not - gamut transformation is a bit of an approximation, and thereā€™s no specific way to determine the original (camera) point on hue lineā€¦

So, my surmise is that itā€™s probably possible to go back to some approximation of scene linear as that is a tone transform, but with color youā€™re screwedā€¦

Bear-of-little-brain thinking going on here, YMMV.

The Topaz product looks interesting. Thanks for the link.

They ask: Can you tell the difference vs. the original RAW? (https://topazlabs.com/static/jpeg-to-raw-ai/img/compression-bna.png )

Answer: Yes, very easily. The right-hand image has detail around the edge of the mushroom that is absent in the middle image. I assume those are the raw image (converted to sRGB) and the ā€œimproved jpegā€ respectively.

Some of that detail has been removed in the jpeg image, and some detail is swamped by jpeg artifacts. Fixing the artifacts has also removed some detail.

Expanding a small gamut to a larger gamut, eg sRGB to ProPhotoRGB, is trivial. But doing it accurately is difficult. It assumes we know what process shrunk the gamut, and that it is reversible. I doubt that either assumption is true. For example, the jpeg may have had local adjustment of saturation (like local adjustment of tones), and reversing that accurately is difficult.

I can certainly believe we can start with a horrible jpeg that canā€™t be edited, and process that image to remove artifacts and invent tones, colours and detail so that we can then edit the image. The result may be pretty, and may be credible.

But will it be as accurate as a process that starts from raw instead of a jpeg? No, because data has been lost.

Out of curiosity I downloaded the 30 day trial. It was late last night I tried it on 3 old jpg file and a new one from my pixel phoneā€¦it really didnā€™t do a very good jobā€¦it was late and I just used the auto settings so maybe I will try it one more timeā€¦but it wouldnā€™t be worth the effort in my estimation from what I could get out of itā€¦

Well, there are tonnes of old B&W movies that were converted to color by ā€˜paintingā€™ the original negatives, so it can be done. Of course the result is just an imaginative representation of the originalā€¦

Thanks for the feedback. I understand its not worth it from an image quality perspective. Whatā€™s gone is gone. DT does open the jpg, and Iā€™ll live with the result.

I too tried the Topaz labs software, and could not successfully process an image, possibly a lack of memory in my machine.

The simpler thing to think about is that a jpg is (in this case) always a file that has edits done to it.tk get back to good proper linear data for scene referree to even have a chance, you would need to undo the edits done to the picture. You canā€™t without knowing what has been done to itā€¦

ā€¦ And then not every edit is reversible (far from it), and then you get jpeg compression factorsā€¦ Etcā€¦

Then again, if you convert the color space from the jpeg from (assumed) sRGB to linear rec2020 and save it as a 16bit tif file, load it in darktable and see what happens.

The quality will not be magically better or course, but the data is in a somewhat linear way.
Good chance there still will be some base curves active in the jpeg data, but you canā€™t easily undo those without knowing how the jpg was created.

Then again, maybe darktable is smart enough to open the jpg directly and convert the sRGB to its working space directly (linear rec2020) so maybe you can just open the jpg and try how it works?

Converting to different file formats will not gain anything in the end.

You can still use scene-referred tools with JPGs. Unfortunately, since the JPG will have some tone curves applied (e.g. by the camera), the numbers in the image file no longer correspond to the physical reality. Still, you can boost exposure, use the tone equalizer and filmic for tone mapping, like here:


I used filmic without contrast boost, but with a wide latitude:
image

This is just a quick demo, Iā€™m not saying this is how Iā€™d normally edit this shot. Here is the out-of-camera JPG:

Note that this is using the ā€˜v3.0 JPEGā€™ module order; the important part is having exposure and the other tools after input color profile in the pipeline, so it can undo the sRGB encoding (ā€˜gammaā€™ - which it is not, and AP will kill me for using the g-word if he finds out).

This is what pipeline order looks like:
image

1 Like

Istvan - thanks so much! Definitely got Exposure working better with this.