Pages: [1]   Go Down

Author Topic: RGB curves reverse engineering. Application: B&W toning and Instagram filters  (Read 904 times)

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1651
    • http://www.guillermoluijk.com

As an exercise to practise image processing with R (a statistical data processing language), I have written some code to calculate the RGB curves that were applied to a pair of input + output images:

INPUT


OUTPUT


CALCULATED RGB CURVES



The process can be applied to any B&W toned image to hack the toning, and then apply it to a B&W image of our own:

TONED IMAGE


CALCULATED RGB CURVES


APPLICATION TO OUR B&W IMAGE



I have finally analysed two Instagram filters to find out how well they can be represented through curves. Looking at the nearly undistinguishable result, they actually seem to be nothing more than curves:

CALCULATED RGB CURVES


INSTAGRAM vs CALCULATED RGB CURVES



Hope you find it interesting. The English translation is available through Google:

RGB curves reverse engineering with R

Regards
« Last Edit: September 27, 2017, 04:17:21 PM by Guillermo Luijk »
Logged

rdonson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2562

Very interesting, Guillermo. 

I wonder if some variation of this could be used to create curves for creating better platinum presets for Lr or PS by photographing a classic platinum print???
Logged
Regards,
Ron

kers

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1625
    • Pieter Kers

Well done Guillermo...

i always use curves for all my color changes...
with BW toning i always wonder if the begin and endpoints ( 0, 255) has to stay in place or not.


Logged
Pieter Kers
www.beeld.nu

BartvanderWolf

  • Sr. Member
  • ****
  • Online Online
  • Posts: 6674

As an exercise to practise image processing with R (a statistical data processing language), I have written some code to calculate the RGB curves that were applied to a pair of input + output images:

Guillermo, Well done.

It's a fine demonstration of what can be done with only using Curves.

It's one of the ways that color grading can be done, and using curves makes it relatively easy to implement in existing photo-editors. It just takes some before and after comparisons to build the curves that can be reused, and some software to do it.

Another way color grading is often done is by using color look-up tables (CLUTs), either per channel LUTs or (e.g. Hald) 3D LUTs and by using interpolation of in-between colors. 3D LUTs allow even more complex color grading than with per channel LUTs, e.g. rotation of colors.

ImageMagick has a lot of built-in Look-up Table functionality:
https://www.imagemagick.org/Usage/color_mods/#color_lut

RawTherapee also supports Hald 3D LUTs:
http://rawpedia.rawtherapee.com/Film_Simulation

Topaz Studio (besides curves) also has a plugin that allows color grading based on the 5 most dominant colors of an image.
Here's some more detail about that specific plugin:
https://web.topazlabs.com/color-theme#overview

Photoshop (starting with CS6) also has some LUT capabilities:
https://blogs.adobe.com/richardcurtis/2012/09/14/adding-a-3d-lut-or-colour-lookup-table-for-toning-to-your-image-no-2/

Cheers,
Bart
« Last Edit: September 28, 2017, 08:14:42 AM by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

scyth

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 585

Photoshop (starting with CS6) also has some LUT capabilities:
icc/icm profiles were possible to apply in PS even before that, so it is not exactly starting with CS6 ...
Logged

BartvanderWolf

  • Sr. Member
  • ****
  • Online Online
  • Posts: 6674

icc/icm profiles were possible to apply in PS even before that, so it is not exactly starting with CS6 ...

What I mentioned is not about ICC/ICM profiles, but about (3D) LUTs (Adjustment layers) which is a different kind of animal. It's very commonly used for Color grading in video editing, but equally useful for applying a 'uniform look' in series of stills, even Black & White ones).

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 527

As an exercise to practise image processing with R (a statistical data processing language),

R??? Why make your life miserable with that terrible 'language'. Use Python.
Logged
Joofa
http://www.djjoofa.com
Download Photoshop and After Effects plugins

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1651
    • http://www.guillermoluijk.com

RawTherapee also supports Hald 3D LUTs:
http://rawpedia.rawtherapee.com/Film_Simulation

In fact reverse engineering 3D LUTs is exactly the same principle. The problem is that it is much less likely to be able to define all 3D colour combinations with a single input/output pair than with 1D LUTs. Not only because there is a vast larger number of possible combinations in 3D LUTs, but because real world images never have all colours at a time. I recall a synthetic imagen provided by Raw Therapee that allows to create the 3D LUT if the user is allowed to apply the processing, and this is the way they created their film simulations.

I found them: http://gmic.eu/film_emulation/various/clut/

To define a 1D LUT with 8-bit resolution, this tiny square is enough :)



Regards
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1651
    • http://www.guillermoluijk.com

R??? Why make your life miserable with that terrible 'language'. Use Python.

I use both, and none makes my life miserable :P
Logged

scyth

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 585

What I mentioned is not about ICC/ICM profiles, but about (3D) LUTs (Adjustment layers) which is a different kind of animal.

yes, but using profiles you can do the same

Logged

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 527
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #10 on: September 28, 2017, 05:00:54 PM »

I use both, and none makes my life miserable :P

Python >>>>>> R. Technically, R is not even a valid 'programming language'. Just a (very bad) mixture of some commands.
Logged
Joofa
http://www.djjoofa.com
Download Photoshop and After Effects plugins

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1651
    • http://www.guillermoluijk.com
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #11 on: September 28, 2017, 05:05:23 PM »

Python >>>>>> R. Technically, R is not even a valid 'programming language'. Just a (very bad) mixture of some commands.
Never intended to write a program, that is why I used R for this exercise. Treating your R-fobia will make your life less miserable lol
Logged

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 527
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #12 on: September 28, 2017, 05:12:10 PM »

Never intended to write a program, that is why I used R for this exercise. Treating your R-fobia will make your life less miserable lol

It is not R-phobia. I have worked in R extensively to know that it doesn't even qualify for a modern language, IMHO, for e.g. something like Python, or even Java. Or even C/C++. It is just rubbish. There is no reason to use it. Python is all one needs in place of it. And, at other places, Java and/or Scala. And, C/C++ where none of the afore-mentioned can be used.

I'm quite serious. Despite what you might hear from supposed 'data scientists' about R, it is just a flagrant distortion of the notion of a 'programming language'. Enough said.
Logged
Joofa
http://www.djjoofa.com
Download Photoshop and After Effects plugins

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1651
    • http://www.guillermoluijk.com
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #13 on: September 28, 2017, 05:19:24 PM »

It is not R-phobia.
You have already devoted three posts in a thread about RGB curves to hate R, which most people in this forum probably don't know what is nor are interested in. It seems R-fobia is not your only trauma here.
Logged

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 527
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #14 on: September 28, 2017, 05:20:57 PM »

You have already devoted three posts in a thread about RGB curves to hate R, which most people in this forum probably don't know what is nor are interested in. It seems R-fobia is not your only trauma here.

Phobia, Trauma??? What is wrong with you? Listen, I just gave my advice regarding R, which I believe is a bad 'language'. You can take it or leave it. But no need to get rude. What is with personal attacks???. Ok.
Logged
Joofa
http://www.djjoofa.com
Download Photoshop and After Effects plugins

scyth

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 585
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #15 on: September 28, 2017, 05:51:52 PM »

Python >>>>>> R. Technically, R is not even a valid 'programming language'. Just a (very bad) mixture of some commands.

like matlab ?
Logged

scyth

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 585
Re: RGB curves reverse engineering. Application: B&W toning and Instagram filters
« Reply #16 on: September 28, 2017, 05:53:02 PM »

Phobia, Trauma??? What is wrong with you? Listen, I just gave my advice regarding R, which I believe is a bad 'language'. You can take it or leave it. But no need to get rude. What is with personal attacks???. Ok.

G basically asks not to hijack the thread  ;)
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 628
    • Hikes -more than strolls- with my dog

Good stuff Guillermo.
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 12203
    • http://digitaldog.net/

Good stuff Guillermo.
+1 now that we are getting back OT away from HOW the process (which is quite interesting) was produced; it works.
Logged
Andrew Rodney
Author “Color Management for Photographers”
http://digitaldog.net/
Pages: [1]   Go Up