Old 12-02-2018, 10:10 PM   #1
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,116
Default RGBL histogram

Here's a little something I made tonight after working on a bunch of other video stuff:
Code:
// Histogram (RGB)
//@param 1:xpos "x position" .95
//@param 2:ypos "y position" .95
//@param 3:bga "bg alpha" 0.6
//@param 4:bordera "border alpha" 0.5
//@param 6:logsc "log scale" 0 0 1 .5 1

project_wh_valid===0 ? input_info(0,project_w,project_h);
project_w < 1280 ? ( project_h = 1280*project_h/project_w; project_w=1280; );
gfx_blit(0);

colorspace='RGBA';
memset(0,0,1024);
gfx_evalrect(0,0,project_w,project_h,"
   r[0]+=1; g[256]+=1; b[512]+=1;
   (0.299*r + 0.587*g + 0.114*b)[768] += 1;
   ",2);

i=0;
logsc ? loop(1024,i[0] = log($e+i[0]) - 1; i+=1; );
function hist(x,y,w) local(i, m, tv, offs) global(bordera ysz bga)
(
  offs=w*256;
  m=i=0; loop(256, m=max(offs[i],m); i+=1);
  gfx_set(0,0,0,bga);
  gfx_fillrect(x,y,256,ysz);
  w<3 ? gfx_set(1,1,1,bordera) : gfx_set(0,1,0,bordera);
  gfx_fillrect(x-1,y-1,258,1);
  gfx_fillrect(x-1,y+ysz,258,1);
  gfx_fillrect(x-1,y,1,ysz);
  gfx_fillrect(x+256,y,1,ysz);
  w==3?gfx_set(.7) : gfx_set(w==0,w==1,w==2,1);
  i=0;
  loop(256,
    tv = floor((offs[i]/m)*ysz+0.5);
    gfx_fillrect(x+i,y+ysz-tv,1,tv);
    i+=1);
);

gap = 64;
xsz = 4*256 + 3*gap;
ysz = 128;
y = floor(ypos * (project_h-ysz));
x = floor(xpos * (project_w-xsz));
hist(x,y,0); x+=gap+256;
hist(x,y,1); x+=gap+256;
hist(x,y,2); x+=gap+256;
hist(x,y,3);
... should be useful for developing other things too, might take a try at some color correction.
Justin is offline   Reply With Quote
Old 12-03-2018, 03:37 AM   #2
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,153
Default

Awesome.

And again I'm amazed at how many things can be done with the video processor, while it seems so easy to write something like a histogram preset. (I wish I could understand at least a little bit.)

Now we can monitor if highs or lows are shifted by colors. But to fix them, a luma dependent color correction or desaturator would be handy. Maybe this could be done as a workaround with chromakey? Not sure. Anyway!

Many thanks.

And here are the obligatory examples:



Eliseat is offline   Reply With Quote
Old 12-03-2018, 04:48 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,812
Default

Overlayed histogram can be nice too :P

EG:


EDIT: Also, having knobs so we can adjust black/midgrey/white for all channel (R, G,B and Mixed) would be very nice :P

Last edited by X-Raym; 12-03-2018 at 05:01 AM.
X-Raym is offline   Reply With Quote
Old 12-03-2018, 07:53 AM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,116
Default

Here's one that adds a 5th box for overlapped:
Code:
// Histogram (RGB)
//@param 1:xpos "x position" .95
//@param 2:ypos "y position" .95
//@param 3:bga "bg alpha" 0.6
//@param 4:bordera "border alpha" 0.5
//@param 6:logsc "log scale" 0 0 1 .5 1

project_wh_valid===0 ? input_info(0,project_w,project_h);
project_w < 1280 ? ( project_h = 1280*project_h/project_w; project_w=1280; );
gfx_blit(0);

colorspace='RGBA';
memset(0,0,1024);
gfx_evalrect(0,0,project_w,project_h,"
   r[0]+=1; g[256]+=1; b[512]+=1;
   (0.299*r + 0.587*g + 0.114*b)[768] += 1;
   ",2|1);

i=0;
logsc ? loop(1024,i[0] = log($e+i[0]) - 1; i+=1; );
function hist(x,y,w,olm) local(i, m, tv, offs) global(bordera ysz bga)
(
  offs=w*256;
  m=i=0; loop(olm?768:256, m=max(offs[i],m); i+=1);
  gfx_set(0,0,0,bga);
  gfx_fillrect(x,y,256,ysz);
  w<3 ? gfx_set(1,1,1,bordera) : gfx_set(0,1,0,bordera);
  gfx_fillrect(x-1,y-1,258,1);
  gfx_fillrect(x-1,y+ysz,258,1);
  gfx_fillrect(x-1,y,1,ysz);
  gfx_fillrect(x+256,y,1,ysz);
  w==3?gfx_set(.7) : gfx_set(w==0,w==1,w==2);
  i=0;
  loop(olm?768:256,
    i===256?gfx_set(0,1,0,1,1):i===512?gfx_set(0,0,1,1,1);
    tv = floor((offs[i]/m)*ysz+0.5);
    gfx_fillrect(x+(i&255),y+ysz-tv,1,tv);
    i+=1);
);

gap = 64;
xsz = 5*256 + 4*gap;
ysz = 128;
y = floor(ypos * (project_h-ysz));
x = floor(xpos * (project_w-xsz));
hist(x,y,0,0); x+=gap+256;
hist(x,y,1,0); x+=gap+256;
hist(x,y,2,0); x+=gap+256;
hist(x,y,3,0); x+=gap+256;
hist(x,y,0,1);
Justin is offline   Reply With Quote
Old 12-03-2018, 09:32 AM   #5
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,457
Default

OMG never thought this would happen!

I bet a skintone guide will never happen
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 12-03-2018, 03:15 PM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,812
Smile

Looks very good thx !! :P Could be packed as default as well.
X-Raym is offline   Reply With Quote
Old 02-27-2019, 10:32 AM   #7
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,457
Default

any chance of a Vector scope?
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds 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 03:10 AM.


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