RGBAdjust

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:FuncDef|RGBAdjust(clip ''clip'' [, float ''r''] [, float ''g''] [, float ''b''] [, float ''a''] [, float ''rb''] [, float ''gb''] [, float ''bb''] [, float ''ab''] [, float ''rg''] [, float ''gg''] [, float ''bg''] [, float ''ag''] [, bool ''analyze''] [, bool ''dither''])}}  
+
Multiplies each color channel with the given value, clipping the result at 0—255.
 +
__TOC__
 +
== Syntax and Parameters ==
 +
{{Template:FuncDef|RGBAdjust(clip ''clip'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''r'', float ''g'', float ''b'', float ''a'', <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''rb'', float ''gb'', float ''bb'', float ''ab'', <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''rg'', float ''gg'', float ''bg'', float ''ag'', <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool ''analyze'', bool ''dither'' ] )
 +
}}  
  
This filter multiplies each color channel with the given value, clipping the result at 255. Note that RGBAdjust(1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1) leaves the clip untouched.
+
:{{Par2|r|float|1.0}}
 +
:{{Par2|g|float|1.0}}
 +
:{{Par2|b|float|1.0}}
 +
::Red, green and blue scaling factor. Range 0.0 to 255.0
 +
::For example, {{FuncArg|r}}=3.0 multiplies the red channel pixel values by 3.  
  
''r'' (0.0-255.0; default 1.0): This option determines how much red is to be scaled. For example, a scale of 3 multiplies the red channel of each pixel by 3. ''green'' and ''blue'' work similar.
+
:{{Par2|a|float|1.0}}
''a'' (0.0-255.0; default 1.0) specifies the alpha channel, that is it represents the transparency information on a per-pixel basis. An alpha value of zero represents full transparency, and a value of 1 represents a fully opaque pixel.
+
::Alpha adjustment&mdash;the transparency information on a per-pixel basis.  
 +
::An alpha value of zero represents full transparency, and a value of 1 represents a full opacity.  
  
In v2.56 the offsets ''rb'', ''gb'', ''bb'', ''ab'' (default 0.0) add a value to the red, green, blue or alpha channels. For example, ''rb'' = 16 will add 16 to the red pixel values and -32 will subtract 32 from all red pixel values.
+
:{{Par2|rb|float|0.0}}
 +
:{{Par2|gb|float|0.0}}
 +
:{{Par2|bb|float|0.0}}
 +
:{{Par2|ab|float|0.0}}
 +
::Bias adjustment&mdash;add a fixed positive or negative value to a channel's pixel values. For example,  
 +
::{{FuncArg|rb}}=16 will add 16 to all red pixel values and
 +
::{{FuncArg|rb}}=-32 will subtract 32 from all red pixel values.
  
Also in v2.56 the exponents ''rg'', ''gg'', ''bg'', ''ag'' (default 1.0) adjust the gamma of the red, green, blue or alpha channels. For example, ''rg'' = 1.2 will brighten the red pixel values and ''gg'' = 0.8 will darken the green pixel values.
+
:{{Par2|rg|float|1.0}}
 +
:{{Par2|gg|float|1.0}}
 +
:{{Par2|bg|float|1.0}}
 +
:{{Par2|ag|float|1.0}}
 +
::Gamma adjustment&mdash;an [[Wikipedia:Gamma_correction|exponential gain factor]]. For example,  
 +
::{{FuncArg|rg}}=1.2 will brighten the red pixel values and  
 +
::{{FuncArg|gg}}=0.8 will darken the green pixel values.
  
In v2.56 ''analyze'' (can be true or false) will print out color statistics on the screen. There are maximum and minimum values for all channels. There is an average and a standard deviation for all channels. There is a "loose minimum" and "loose maximum". The "loose" values are made to filter out very bright or very dark noise creating an artificially low or high minimum / maximum (it just means that the amount of red/green/blue of 255/256 of all pixels is above (under) the loose minimum (maximum)).
+
:{{Par2|analyze|bool|false}}
 +
::If true, '''RGBAdjust''' will print color channel statistics on the screen (see [[#analyze|example below]])
 +
::*There are '''Maximum''' and '''Minimum''' values for all channels.  
 +
::*There is an '''Average''' and a '''Standard Deviation''' for all channels.  
 +
::*There is '''Loose Minimum''' and '''Loose Maximum''' which ignore the brightest and darkest 0.4% (1/256) pixels.
  
In v2.60 ''dither'' = true/false (false by default): When set to true, [[ordered dithering]] is applied when doing the adjustment.
+
:{{Par2|dither|bool|false}}
 +
::If true, [[ordered dithering]] is applied when doing the adjustment.
  
Keep in mind ALL the values are not scaled to accommodate changes to one (for that you should use levels) so doing something like:
+
== Notes ==
 +
*All arguments default&mdash;leaves the clip untouched:
 +
<div {{BoxWidthIndent|36|2}} >
 +
RGBAdjust'''(1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1)  
 +
</div>
  
 +
*Keep in mind ALL the channels are not scaled to accommodate changes to one&mdash;for that you should use [[Levels]].
 +
:So doing something like:
 +
<div {{BoxWidthIndent|24|2}} >
 
  RGBAdjust(2, 1, 1, 1)  
 
  RGBAdjust(2, 1, 1, 1)  
 
+
</div>
will get you a whole lot of clipped red. If you WANT a whole lot of clipped red, there ya go - but if you want MORE red without clipping you'd do  
+
:will get you a whole lot of clipped red. If you WANT a whole lot of clipped red, there ya go - but if you want MORE red without clipping you'd do  
 
+
<div {{BoxWidthIndent|36|2}} >
 
  [[Levels]](0, 1, 255, 0, 128).RGBAdjust(2, 1, 1, 1)  
 
  [[Levels]](0, 1, 255, 0, 128).RGBAdjust(2, 1, 1, 1)  
 
+
</div>
This would scale all the levels (and average lum) by half, then double the red. Or more compact
+
:This would scale all the levels (and average luminance) by half, then double the red. Or more compact
 
+
<div {{BoxWidthIndent|24|2}} >
 
  RGBAdjust(1.0, 0.5, 0.5, 1.0)
 
  RGBAdjust(1.0, 0.5, 0.5, 1.0)
 +
</div>
 +
:This leaves the red and halves the green and blue.
  
This leaves the red and halves the green and blue.
+
*To invert the alpha channel
 +
<div {{BoxWidthIndent|24|2}} >
 +
RGBAdjust(a=-1.0, ab=255)
 +
</div>
 +
:Thus alpha pixels values become a=(255-a).
  
To invert the alpha channel
 
  
  RGBAdjust(a=-1.0, ab=255)
+
== Examples ==
 +
<div id="analyze" style="display:inline;font-size:50%;height:0;line-height:0;overflow:hidden;"></div>
 +
*Demonstrating {{FuncArg|analyze}} output
 +
<div {{BoxWidthIndent|24|2}} >
 +
[[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4")
 +
  RGBAdjust(analyze=true)
 +
[[File:RGBAdjust_Ex1.jpg]]
 +
</div>
  
Thus alpha pixels values become a=(255-a).
 
  
'''Changes'''
+
== Changes ==
 
{| border="1"
 
{| border="1"
 +
| v2.60
 +
| Added dither.
 
|-  
 
|-  
 
| v2.56
 
| v2.56
 
| Added offsets, gamma, analyze.
 
| Added offsets, gamma, analyze.
|-
 
| v2.60
 
| Added dither.
 
 
|}
 
|}
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 
[[Category:Levels and Chroma filters]]
 
[[Category:Levels and Chroma filters]]

Revision as of 03:18, 27 January 2016

Multiplies each color channel with the given value, clipping the result at 0—255.

Contents

Syntax and Parameters

RGBAdjust(clip clip [,
     float r, float g, float b, float a,
     float rb, float gb, float bb, float ab,
     float rg, float gg, float bg, float ag,
     bool analyze, bool dither ] )

float  r = 1.0
float  g = 1.0
float  b = 1.0
Red, green and blue scaling factor. Range 0.0 to 255.0
For example, r=3.0 multiplies the red channel pixel values by 3.
float  a = 1.0
Alpha adjustment—the transparency information on a per-pixel basis.
An alpha value of zero represents full transparency, and a value of 1 represents a full opacity.
float  rb = 0.0
float  gb = 0.0
float  bb = 0.0
float  ab = 0.0
Bias adjustment—add a fixed positive or negative value to a channel's pixel values. For example,
rb=16 will add 16 to all red pixel values and
rb=-32 will subtract 32 from all red pixel values.
float  rg = 1.0
float  gg = 1.0
float  bg = 1.0
float  ag = 1.0
Gamma adjustment—an exponential gain factor. For example,
rg=1.2 will brighten the red pixel values and
gg=0.8 will darken the green pixel values.
bool  analyze = false
If true, RGBAdjust will print color channel statistics on the screen (see example below)
  • There are Maximum and Minimum values for all channels.
  • There is an Average and a Standard Deviation for all channels.
  • There is Loose Minimum and Loose Maximum which ignore the brightest and darkest 0.4% (1/256) pixels.
bool  dither = false
If true, ordered dithering is applied when doing the adjustment.

Notes

  • All arguments default—leaves the clip untouched:
RGBAdjust(1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1) 
  • Keep in mind ALL the channels are not scaled to accommodate changes to one—for that you should use Levels.
So doing something like:
RGBAdjust(2, 1, 1, 1) 
will get you a whole lot of clipped red. If you WANT a whole lot of clipped red, there ya go - but if you want MORE red without clipping you'd do
Levels(0, 1, 255, 0, 128).RGBAdjust(2, 1, 1, 1) 
This would scale all the levels (and average luminance) by half, then double the red. Or more compact
RGBAdjust(1.0, 0.5, 0.5, 1.0)
This leaves the red and halves the green and blue.
  • To invert the alpha channel
RGBAdjust(a=-1.0, ab=255)
Thus alpha pixels values become a=(255-a).


Examples

  • Demonstrating analyze output
FFmpegSource2("sintel.mp4")
RGBAdjust(analyze=true)

RGBAdjust Ex1.jpg


Changes

v2.60 Added dither.
v2.56 Added offsets, gamma, analyze.
Personal tools