Old 12-03-2018, 08:40 AM   #1
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default Color correction WIP thread

Here's an RGB script that allows you to tweak RGB values for blacks/shadows/midtones/hilight/whites:
Code:
// Shadow/midtone/highlight RGB adjust
//@param 1:fade 'alpha' 1

//@param 2:black.r 'black R' 0 -256 256 0 1
//@param 3:black.g 'black G' 0 -256 256 0 1
//@param 4:black.b 'black B' 0 -256 256 0 1

//@param 5:shadow.r 'shadow R' 0 -256 256 0 1
//@param 6:shadow.g 'shadow G' 0 -256 256 0 1
//@param 7:shadow.b 'shadow B' 0 -256 256 0 1

//@param 8:midtone.r 'midtone R' 0 -256 256 0 1
//@param 9:midtone.g 'midtone G' 0 -256 256 0 1
//@param 10:midtone.b 'midtone B' 0 -256 256 0 1

//@param 11:highlight.r 'highlight R' 0 -256 256 0 1
//@param 12:highlight.g 'highlight G' 0 -256 256 0 1
//@param 13:highlight.b 'highlight B' 0 -256 256 0 1

//@param 14:white.r 'white R' 0 -256 256 0 1
//@param 15:white.g 'white G' 0 -256 256 0 1
//@param 16:white.b 'white B' 0 -256 256 0 1

black.pos = 0;
shadow.pos = 64;
midtone.pos = 128;
highlight.pos = 192;
white.pos = 256;

function mk(i, low*, hi*) local (idx) (
  idx=i*3;
  i = (i - low.pos) / (hi.pos - low.pos);
  idx[0] = (i * hi.r + (1-i)*low.r)*fade;
  idx[1] = (i * hi.g + (1-i)*low.g)*fade;
  idx[2] = (i * hi.b + (1-i)*low.b)*fade;
);

fade > 0 ? (
  i = 0;
  loop(256,
    i <= shadow.pos ? mk(i,black,shadow) :
     i <= midtone.pos ? mk(i,shadow,midtone) :
       i <= highlight.pos ? mk(i,midtone,highlight) :
         mk(i,highlight,white);
    i+=1;
  );

  input_info(0,project_w,project_h);
  gfx_blit(0);
  colorspace='RGBA';
  gfx_evalrect(0,0,project_w,project_h,"
    _1 = floor(0.299*r + 0.587*g + 0.114*b+0.5)*3;
    r = min(max(r+_1[0],0),255);
    g = min(max(g+_1[1],0),255);
    b = min(max(b+_1[2],0),255);
  ");
);
(OK maybe it's time to increase the maximum parameter count from 16...)

Last edited by Justin; 12-03-2018 at 08:51 AM. Reason: Cleanup style slightly
Justin is offline   Reply With Quote
Old 12-03-2018, 08:48 AM   #2
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Holy ...!

AWESOME!

No time for the kids. Must test new preset!

Many thanks
Eliseat is offline   Reply With Quote
Old 12-03-2018, 09:26 AM   #3
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 7,570
Default

(OK maybe it's time to increase the maximum parameter count from 16...)

yes, or a real UI by v6.0
maybe allow typing parameter values in the meantime?

Only quickly tested but I'd say this works quite nicely!
Pretty choppy on my iphone video I tested with but I kinda expect that.

I think it could be split into a couple simpler tools as well.

One could just be to desaturate black with controls for threshold and strength (rgb on one knob).

another could be Black, shadow, midtone, highlight, white balance. just 5 knobs.

I don't think you can give us too many presets
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is online now   Reply With Quote
Old 12-03-2018, 11:20 AM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Hmm desaturate black would be easy to do in YUV space, mmm...
Justin is offline   Reply With Quote
Old 12-03-2018, 03:44 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Very nice to have these features !



It's a bit intensive on the CPU for videos from my camera (50 Mb/s), so there is drop frames but it is smooth on video from my smartphone.


Though, this doesn't behave like a usual RGB slider


Here is a demo on the influence area:




As you can see, there is clearly defined area (which can be when the point is shift, sometimes there isn't even gradient anymore between non colored and colored on the screenshot)

A usual RGB slider would behaves more like this



(slider is for dark tones, mid tones and then high tones)

As you can see, every slider affects the whole specturm of the image.

Here is an exemple of influence curve in Filmlight Baselight (one of the only representation I found)


(in this exemple, shadows and highlights curve have some easing but it could simply be linear)

As you can see, adjusting shadows or highlights will influence the whole specturm (but more shadows/highlight obviously). This prevent having banding effects or artefacts, it is smoother on live footage.


EDIT: exemple from Magic bullet

See the influence curve at the bottom. Each "bands" affects the whole color spectrum.

Last edited by X-Raym; 12-03-2018 at 04:10 PM.
X-Raym is offline   Reply With Quote
Old 12-03-2018, 04:15 PM   #6
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 7,570
Default

Justin I think this needs some overlap between bands. Don't know how much but there should be a slight transition between shadow and midtones etc.
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.