Pages: [1]   Go Down

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

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • 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: 3263

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: 4388
    • 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/la

Bart_van_der_Wolf

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

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: 584

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

Bart_van_der_Wolf

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

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: 544

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: 2005
    • 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

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • 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

scyth

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

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: 544
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: 2005
    • 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

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 544
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: 2005
    • 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.

joofa

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 544
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: 584
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: 584
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: 798
    • Hikes -more than strolls- with my dog

Good stuff Guillermo.
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20630
  • Andrew Rodney
    • http://www.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
http://www.digitaldog.net/
Author "Color Management for Photographers".
Pages: [1]   Go Up