Old 04-23-2021, 11:39 PM   #1
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default Sharpen video in Reaper

Hello, is it possible to add simple code to sharpen videos in Reaper?

Professionally there are three settings - one that sharpens or gives more contrast to pixels, the other sets the radius of the contrast and the third setting is the amount of treshold (in order to concentrate on the detailed foreground).
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-24-2021, 01:36 AM   #2
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

I'm sure somebody has done a sharpen preset - although I can't find one right now.

There's things you can do by mixing in a (colour) inverted blurred copy of the original.
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 04-24-2021, 10:50 AM   #3
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Thanks, I can not find any either.
Tried to invert a track copy of image colours and now how you mean I mix them together?
I did put image overlay, but they do not mix well, also if I set opacity.
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-25-2021, 06:20 AM   #4
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

attached a track template that does a kind of video sharpening
Attached Files
File Type: rtracktemplate video_sharpen.RTrackTemplate (6.6 KB, 294 views)
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 04-25-2021, 01:59 PM   #5
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Thank you. Have tried it but it does not work for me. Contrast brightness works in a similar way. Videos are heavilly unsharp ...
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-25-2021, 02:27 PM   #6
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by jrk View Post
attached a track template that does a kind of video sharpening
Hi - thanks for this - I've been looking for a video sharpening processor.

I too did not notice much with the blur low quality processor. But I swapped it for the Gaussian blur - and it worked much better for me.

So I then thought I'd try and amalgamate it all into a single processor - and came up with this:

Code:
// Sharpen
//@param1:sigma_parm 'Amount' 0 0 5 2.5 0.01
////@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param2:merge 'Merge' 0.74 0.7 0.75 0.725 0.001

////@param9:force_rgb 'force RGB' 0 0 1 .5 1

//@param4:brightness 'brightness' 0.0 -2 2
//@param5:contrast 'contrast' 1.14 0 2
////@param15:brightness2 'brightness pre' 0.0 -1 1
////@param16:contrast2 'contrast big' 1.0 -50 50
//@param6:saturation 'saturation-ish' 1.9 -10 10

function bd(flag) (
  sigma = sigma_parm * ((flag&8)?weight_mod:1/weight_mod);
  sigma > 0.5 ? (
    // thanks wwwmaze for this algorithm :)
    q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
    b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
    b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
    b2 = -1.4281*q^2 - 1.26661*q^3;
    b3 = 0.422205*q^3;
    BB = 1-(b1+b2+b3)/b0;
    b1b0=b1/b0;
    b2b0=b2/b0;
    b3b0=b3/b0;

    rowsize = ((flag&8) ? project_h : project_w);
    rowsize -= 1 + (colorspace=='YV12' ? rowsize*.5);
    gfx_evalrect(0,0,project_w,project_h,
      colorspace=='RGBA' ? "
        (_1 -= 1) < 0 ? (
          _1=rowsize;
          _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
        );
        r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
        g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
        b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
      " : "
        (_1 -= 1) < 0 ? (
           _1=rowsize;
          _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
        );
        y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
        y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
        y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
        y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
        _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
        u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
        _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
        v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
      ",flag
    );
  );
);

brightness2 = 0;
contrast2 = 1;
force_rgb = 0;
weight_mod = 1;

in=input_info(input=0,project_w,project_h);

bimg1 = gfx_img_alloc(project_w,project_h,1);
bimg2 = gfx_img_alloc(project_w,project_h,1);

(cv=abs(contrast*contrast2)) > 1 ? cv = (cv-1)*4 + 1;
cv=((2^cv)-1) * sign(contrast*contrast2);
i=tab=0;
loop(256,
  v = i/256;
  tab[i]=(v-0.5+brightness2)*cv+0.5+brightness;
  tab[i+256]=tab[i+512]=0.5 + (v-0.5)*saturation;
  i+=1;
);

gfx_dest = bimg1;
gfx_set(1);
gfx_fillrect(0,0,project_w,project_h);
gfx_set(0,0,0,-1,1); // negative alpha, additive
in ? (
  
  // INVERT

  gfx_blit(input, 0);
  //pa && colorspace=='RGBA' ? ( gfx_mode=0xf0+3+3*4;  gfx_blit(input,0); );
  
  gfx_set(0,0,0,1,0,-1);

  //BLUR

  gfx_dest = bimg2;
  
  colorspace!='RGBA' ? colorspace='YV12';
  gfx_blit(bimg1);
  /*want_l ?*/ bd(4);
  /*want_d ?*/ bd(8);
  /*want_u ?*/ bd(4|8);
  /*want_r ?*/ bd(0);

  gfx_a = merge;
  gfx_blit(input);

);

gfx_dest = -1;
gfx_a = 1;

  gfx_blit(bimg2);
  //tab[0] > 0 ? (
    colorspace!='YUY2' ? colorspace='YV12';
    gfx_procrect(0,0,project_w,project_h,tab);
  //);
  
//gfx_blit(bimg2, 1);

gfx_img_free(bimg1);
gfx_img_free(bimg2);
It does mess with the colours a bit - so you have to play with the brightness/contrast and saturation controls a bit to get close to the original.

And I reduced the range of the Amount control (originally named Sigma in the gaussian blur processor) - to something more useful (the range where for me it gets better as you increase it - and then starts to degrade again).

Anyway - I've really not much of an idea of what I'm doing with video processor stuff - but it seems to work pretty well - and you can stack them for even more sharpness - with obvious further colour degradation...

Hope it might be useful
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website

Last edited by lb0; 04-25-2021 at 02:54 PM.
lb0 is offline   Reply With Quote
Old 04-25-2021, 03:05 PM   #7
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Great, this indeed works. How about combining RGB values, since it breaks also white balance in the same code? I am not sure how to do that.
Here is some simple RGB code:

//RGB White Balance Colour Grading
src=0;
//@param2:red 'red' 0 -0.1 0.1
//@param4:green 'green' 0 -0.1 0.1
//@param6:blue 'blue' 0 -0.1 0.1
//@param8:intensity 'intensity' 1 -10 10
input_info(src,w,h) ? ( project_w=w; project_h=h; ); // preserve input dimensions
w>0 ? gfx_blit(src);
gfx_mode=w>0 ? 1 : 0;
gfx_gradrect(0,0,project_w,project_h, red, green, blue, intensity);
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-25-2021, 03:19 PM   #8
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by urednik View Post
Great, this indeed works. How about combining RGB values, since it breaks also white balance in the same code? I am not sure how to do that.
Here is some simple RGB code:

//RGB White Balance Colour Grading
src=0;
//@param2:red 'red' 0 -0.1 0.1
//@param4:green 'green' 0 -0.1 0.1
//@param6:blue 'blue' 0 -0.1 0.1
//@param8:intensity 'intensity' 1 -10 10
input_info(src,w,h) ? ( project_w=w; project_h=h; ); // preserve input dimensions
w>0 ? gfx_blit(src);
gfx_mode=w>0 ? 1 : 0;
gfx_gradrect(0,0,project_w,project_h, red, green, blue, intensity);
Yes - I can probably tag that on somewhere - where would you put it - after all the other processing? - my main worry is that it is already incredibly CPU intensive! I only just looked but wow - ~20% CPU on my machine...

I'm not sure if the CPU for what I've done can be reduced at all - I basically copied the processors involved in jrk's track template example but swapped in the gaussian blur. It seems to be the gaussian blur causing the big jump in CPU - as if you lower the amount to 0 - it reduces massively...
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 04-25-2021, 03:23 PM   #9
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Well, it can be separate if you think that it is to heavy (does not look to bad on rendering now - ussual load for Gaussian blur). I did put it second, behind your sharpen code.
But I also noticed it only needs to lift Blue and Red in the same amount. So perhaps that helps if the code can get improved to do this automatically.
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.

Last edited by urednik; 04-25-2021 at 03:36 PM.
urednik is offline   Reply With Quote
Old 04-25-2021, 03:38 PM   #10
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by urednik View Post
Well, it can be separate if you think that it is to heavy (does not look to bad on rendering now - ussual load for Gaussian blur). I did put it second, behind your sharpen code.
But I also noticed it only needs to lift Blue and Red in the same amount. So perhaps that helps if the code can get improved to do this automatically.
Ok - try this:

Code:
// Sharpen
//@param1:sigma_parm 'Amount' 0 0 5 2.5 0.01
////@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param2:merge 'Merge' 0.715 0.7 0.75 0.725 0.001

////@param9:force_rgb 'force RGB' 0 0 1 .5 1

//@param4:brightness 'brightness' 0.0 -2 2
//@param5:contrast 'contrast' 1.14 0 2
////@param15:brightness2 'brightness pre' 0.0 -1 1
////@param16:contrast2 'contrast big' 1.0 -50 50
//@param6:saturation 'saturation-ish' 1.9 -10 10

//@param8:red 'balance' 0 -0.1 0.1
////@param9:green 'green' 0 -0.1 0.1
////@param10:blue 'blue' 0 -0.1 0.1
//@param9:intensity 'intensity' 1 -10 10

function bd(flag) (
  sigma = sigma_parm * ((flag&8)?weight_mod:1/weight_mod);
  sigma > 0.5 ? (
    // thanks wwwmaze for this algorithm :)
    q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
    b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
    b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
    b2 = -1.4281*q^2 - 1.26661*q^3;
    b3 = 0.422205*q^3;
    BB = 1-(b1+b2+b3)/b0;
    b1b0=b1/b0;
    b2b0=b2/b0;
    b3b0=b3/b0;

    rowsize = ((flag&8) ? project_h : project_w);
    rowsize -= 1 + (colorspace=='YV12' ? rowsize*.5);
    gfx_evalrect(0,0,project_w,project_h,
      colorspace=='RGBA' ? "
        (_1 -= 1) < 0 ? (
          _1=rowsize;
          _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
        );
        r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
        g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
        b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
      " : "
        (_1 -= 1) < 0 ? (
           _1=rowsize;
          _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
        );
        y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
        y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
        y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
        y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
        _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
        u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
        _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
        v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
      ",flag
    );
  );
);

brightness2 = 0;
contrast2 = 1;
force_rgb = 0;
weight_mod = 1;

in=input_info(input=0,project_w,project_h);

bimg1 = gfx_img_alloc(project_w,project_h,1);
bimg2 = gfx_img_alloc(project_w,project_h,1);

(cv=abs(contrast*contrast2)) > 1 ? cv = (cv-1)*4 + 1;
cv=((2^cv)-1) * sign(contrast*contrast2);
i=tab=0;
loop(256,
  v = i/256;
  tab[i]=(v-0.5+brightness2)*cv+0.5+brightness;
  tab[i+256]=tab[i+512]=0.5 + (v-0.5)*saturation;
  i+=1;
);

gfx_dest = bimg1;
gfx_set(1);
gfx_fillrect(0,0,project_w,project_h);
gfx_set(0,0,0,-1,1); // negative alpha, additive
in ? (
  
  // INVERT

  gfx_blit(input, 0);
  //pa && colorspace=='RGBA' ? ( gfx_mode=0xf0+3+3*4;  gfx_blit(input,0); );
  
  gfx_set(0,0,0,1,0,-1);

  //BLUR

  gfx_dest = bimg2;
  
  colorspace!='RGBA' ? colorspace='YV12';
  gfx_blit(bimg1);
  /*want_l ?*/ bd(4);
  /*want_d ?*/ bd(8);
  /*want_u ?*/ bd(4|8);
  /*want_r ?*/ bd(0);

  gfx_a = merge;
  gfx_blit(input);

);

gfx_dest = -1;
gfx_a = 1;

  gfx_blit(bimg2);
  //tab[0] > 0 ? (
    colorspace!='YUY2' ? colorspace='YV12';
    gfx_procrect(0,0,project_w,project_h,tab);
  //);

  //colorspace='RGBA';
  gfx_mode=1;
  gfx_gradrect(0,0,project_w,project_h, red, 0, red, intensity);
  
  
//gfx_blit(bimg2, 1);

gfx_img_free(bimg1);
gfx_img_free(bimg2);
EDIT: I omitted the green - because you only mentioned blue and red - but do you still want control over green separately?

EDIT2: There are probably some parameters that only require fixed values - but not being an expert here I've made them adjustable - so if you think anything needs fixed values - let me know...
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website

Last edited by lb0; 04-25-2021 at 03:45 PM.
lb0 is offline   Reply With Quote
Old 04-25-2021, 04:12 PM   #11
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Wow, yes that is even better now, though do not know why, but with those separate RGB settings I could replicate WB better. But your idea is brilliant!
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-25-2021, 04:15 PM   #12
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by urednik View Post
Wow, yes that is even better now, though do not know why, but with those separate RGB settings I could replicate WB better. But your idea is brilliant!
So you would prefer separate RGB? With the red/blue unlinked (ie. r/g/b all independent)?

EDIT: Separate RGB version for WB.

Code:
// Sharpen
//@param1:sigma_parm 'Amount' 0 0 5 2.5 0.01
////@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param2:merge 'Merge' 0.715 0.7 0.75 0.725 0.001

////@param9:force_rgb 'force RGB' 0 0 1 .5 1

//@param4:brightness 'brightness' 0.0 -2 2
//@param5:contrast 'contrast' 1.14 0 2
////@param15:brightness2 'brightness pre' 0.0 -1 1
////@param16:contrast2 'contrast big' 1.0 -50 50
//@param6:saturation 'saturation-ish' 1.9 -10 10

//@param8:red 'red' 0 -0.1 0.1
//@param9:green 'green' 0 -0.1 0.1
//@param10:blue 'blue' 0 -0.1 0.1
//@param11:intensity 'intensity' 1 -10 10

function bd(flag) (
  sigma = sigma_parm * ((flag&8)?weight_mod:1/weight_mod);
  sigma > 0.5 ? (
    // thanks wwwmaze for this algorithm :)
    q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
    b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
    b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
    b2 = -1.4281*q^2 - 1.26661*q^3;
    b3 = 0.422205*q^3;
    BB = 1-(b1+b2+b3)/b0;
    b1b0=b1/b0;
    b2b0=b2/b0;
    b3b0=b3/b0;

    rowsize = ((flag&8) ? project_h : project_w);
    rowsize -= 1 + (colorspace=='YV12' ? rowsize*.5);
    gfx_evalrect(0,0,project_w,project_h,
      colorspace=='RGBA' ? "
        (_1 -= 1) < 0 ? (
          _1=rowsize;
          _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
        );
        r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
        g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
        b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
      " : "
        (_1 -= 1) < 0 ? (
           _1=rowsize;
          _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
        );
        y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
        y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
        y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
        y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
        _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
        u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
        _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
        v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
      ",flag
    );
  );
);

brightness2 = 0;
contrast2 = 1;
force_rgb = 0;
weight_mod = 1;

in=input_info(input=0,project_w,project_h);

bimg1 = gfx_img_alloc(project_w,project_h,1);
bimg2 = gfx_img_alloc(project_w,project_h,1);

(cv=abs(contrast*contrast2)) > 1 ? cv = (cv-1)*4 + 1;
cv=((2^cv)-1) * sign(contrast*contrast2);
i=tab=0;
loop(256,
  v = i/256;
  tab[i]=(v-0.5+brightness2)*cv+0.5+brightness;
  tab[i+256]=tab[i+512]=0.5 + (v-0.5)*saturation;
  i+=1;
);

gfx_dest = bimg1;
gfx_set(1);
gfx_fillrect(0,0,project_w,project_h);
gfx_set(0,0,0,-1,1); // negative alpha, additive
in ? (
  
  // INVERT

  gfx_blit(input, 0);
  //pa && colorspace=='RGBA' ? ( gfx_mode=0xf0+3+3*4;  gfx_blit(input,0); );
  
  gfx_set(0,0,0,1,0,-1);

  //BLUR

  gfx_dest = bimg2;
  
  colorspace!='RGBA' ? colorspace='YV12';
  gfx_blit(bimg1);
  /*want_l ?*/ bd(4);
  /*want_d ?*/ bd(8);
  /*want_u ?*/ bd(4|8);
  /*want_r ?*/ bd(0);

  gfx_a = merge;
  gfx_blit(input);

);

gfx_dest = -1;
gfx_a = 1;

  gfx_blit(bimg2);
  //tab[0] > 0 ? (
    colorspace!='YUY2' ? colorspace='YV12';
    gfx_procrect(0,0,project_w,project_h,tab);
  //);

  //colorspace='RGBA';
  gfx_mode=1;
  gfx_gradrect(0,0,project_w,project_h, red, green, blue, intensity);
  
  
//gfx_blit(bimg2, 1);

gfx_img_free(bimg1);
gfx_img_free(bimg2);
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website

Last edited by lb0; 04-25-2021 at 04:24 PM.
lb0 is offline   Reply With Quote
Old 04-25-2021, 11:44 PM   #13
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

well, you certainly ran with that. Excellent.

(Yeah there's something funny with the low quality blur - it works when I instantiate it fresh, but doesn't when loaded from a track template).
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 04-26-2021, 01:18 AM   #14
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by jrk View Post
well, you certainly ran with that. Excellent.

(Yeah there's something funny with the low quality blur - it works when I instantiate it fresh, but doesn't when loaded from a track template).


Ok - tried adding the low quality blur - and it works too. Have added it as an option (default - because it uses less CPU).

blur type 0 = gaussian
blur type 1 = low quality

The amount is not calibrated between the two blur types - so switching blur types is not going to provide the same strength sharpening - so currently it's not easy to compare quality between the two...

Code:
// Sharpen
////@param1:sigma_parm 'Amount' 0 0 5 2.5 0.01
//@param1:amount 'Amount' 0 0 1 0.5 0.001
////@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param2:merge 'Merge' 0.715 0.7 0.75 0.725 0.001

////@param9:force_rgb 'force RGB' 0 0 1 .5 1

//@param4:brightness 'brightness' 0.0 -2 2
//@param5:contrast 'contrast' 1.14 0 2
////@param15:brightness2 'brightness pre' 0.0 -1 1
////@param16:contrast2 'contrast big' 1.0 -50 50
//@param6:saturation 'saturation-ish' 1.9 -10 10

//@param8:red 'red' 0 -0.1 0.1
//@param9:green 'green' 0 -0.1 0.1
//@param10:blue 'blue' 0 -0.1 0.1
//@param11:intensity 'intensity' 1 -10 10

//@param13:blurtype 'blur type' 1 0 1 0.5 1

function bd2(flag) (
  weight= min(weight_parm*((flag&8) ? weight_mod : 1/weight_mod),1) ^.25;
  weight2 = sqr(weight);
  rowsize = ((flag&8) ? project_h : project_w);
  rowsize -= 1 + (colorspace=='YV12' ? rowsize*.5);
  gfx_evalrect(0,0,project_w,project_h,colorspace=='RGBA' ? "
    (_1 -= 1) < 0 ? ( _1=rowsize; _2=r; _3=g; _4=b; );
    r+=weight*(_2-r); _2=r; g+=weight*(_3-g); _3=g; b+=weight*(_4-b); _4=b;
  " : "
    (_1 -= 1) < 0 ? ( _1=rowsize; _2=y1; _3=y3; _4=u; _5=v; );
    y1+=weight*(_2-y1); _2=(y2+=weight*(y1-y2));
    y3+=weight*(_3-y3); _3=(y4+=weight*(y3-y4));
    _4=(u+=weight2*(_4-u));
    _5=(v+=weight2*(_5-v));
  ",flag);
);

function bd(flag) (
  sigma = weight_parm * ((flag&8)?weight_mod:1/weight_mod);
  sigma > 0.5 ? (
    // thanks wwwmaze for this algorithm :)
    q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
    b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
    b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
    b2 = -1.4281*q^2 - 1.26661*q^3;
    b3 = 0.422205*q^3;
    BB = 1-(b1+b2+b3)/b0;
    b1b0=b1/b0;
    b2b0=b2/b0;
    b3b0=b3/b0;

    rowsize = ((flag&8) ? project_h : project_w);
    rowsize -= 1 + (colorspace=='YV12' ? rowsize*.5);
    gfx_evalrect(0,0,project_w,project_h,
      colorspace=='RGBA' ? "
        (_1 -= 1) < 0 ? (
          _1=rowsize;
          _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
        );
        r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
        g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
        b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
      " : "
        (_1 -= 1) < 0 ? (
           _1=rowsize;
          _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
        );
        y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
        y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
        y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
        y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
        _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
        u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
        _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
        v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
      ",flag
    );
  );
);

brightness2 = 0;
contrast2 = 1;
force_rgb = 0;
weight_mod = 1;

in=input_info(input=0,project_w,project_h);

bimg1 = gfx_img_alloc(project_w,project_h,1);
bimg2 = gfx_img_alloc(project_w,project_h,1);

(cv=abs(contrast*contrast2)) > 1 ? cv = (cv-1)*4 + 1;
cv=((2^cv)-1) * sign(contrast*contrast2);
i=tab=0;
loop(256,
  v = i/256;
  tab[i]=(v-0.5+brightness2)*cv+0.5+brightness;
  tab[i+256]=tab[i+512]=0.5 + (v-0.5)*saturation;
  i+=1;
);

gfx_dest = bimg1;
gfx_set(1);
gfx_fillrect(0,0,project_w,project_h);
gfx_set(0,0,0,-1,1); // negative alpha, additive
in ? (
  
  // INVERT

  gfx_blit(input, 0);
  //pa && colorspace=='RGBA' ? ( gfx_mode=0xf0+3+3*4;  gfx_blit(input,0); );
  
  gfx_set(0,0,0,1,0,-1);

  //BLUR

  gfx_dest = bimg2;
  
  blurtype == 0 ? (
    weight_parm = amount * 5;
    colorspace!='RGBA' ? colorspace='YV12';
    gfx_blit(bimg1);
    bd(4);
    bd(8);
    bd(4|8);
    bd(0);
  ) : (
    weight_parm = amount * 0.65;
    colorspace!='RGBA' ? colorspace='YV12';
    gfx_blit(bimg1);
    bd2(4);
    bd2(8);
    bd2(4|8);
    bd2(0);
  );
  gfx_a = merge;
  gfx_blit(input);

);

gfx_dest = -1;
gfx_a = 1;

  gfx_blit(bimg2);
  //tab[0] > 0 ? (
    colorspace!='YUY2' ? colorspace='YV12';
    gfx_procrect(0,0,project_w,project_h,tab);
  //);

  //colorspace='RGBA';
  gfx_mode=1;
  gfx_gradrect(0,0,project_w,project_h, red, green, blue, intensity);

gfx_img_free(bimg1);
gfx_img_free(bimg2);
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 04-27-2021, 12:58 AM   #15
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,247
Default

Great! Thanks, I really appreciate this!
Should it be posted somewhere else or in some kind of stash?
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.
urednik is offline   Reply With Quote
Old 04-29-2021, 03:06 AM   #16
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by urednik View Post
Great! Thanks, I really appreciate this!
Should it be posted somewhere else or in some kind of stash?
Well it could be - but probably needs the code tidying up a bit, and being better calibrated... I would like it to sharpen and retain colours/white balance without having to always tweak the additional controls - but haven't time at the moment to look further into it (I'm wondering and assuming there might be some standard values you can use for the additional controls which will retain the original colours/WB - as other sharpening tools I've used that work in a similar way seem to just work with a single - sharpen control).

It works though as it is - and pretty well with a little bit of tweaking - which I'm pretty happy about
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 01-23-2023, 08:22 PM   #17
profquad
Human being with feelings
 
Join Date: Feb 2017
Posts: 185
Default

Hi I just tried this and ended up with something like this, which is cool! but not what I expected... https://youtu.be/4yBs-9EdZe4
profquad is offline   Reply With Quote
Old 01-24-2023, 02:08 AM   #18
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by profquad View Post
Hi I just tried this and ended up with something like this, which is cool! but not what I expected... https://youtu.be/4yBs-9EdZe4
Looks and sounds great! lol!

Hmmm. So was the sharpen tool responsible for the sound being like that too?? Weird - although - it is heavy on processing - so maybe that's responsible... But if it's just responsible for the blue video effect at the start - that's definitely unexpected and interesting!

I personally wouldn't really use this sharpen technique on anything I do (as a video sharpen fx) - as I've had better results with practically every other sharpening tool I have (non-reaper). It was really just trying to package up this particular sharpening technique in a single plugin (by borrowing code from other video fx). I mean - it kind of works when you dial in the right parameters - but the result doesn't make me go wow.

I've never had any results like that though - but I like it!!
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   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 08:36 AM.


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