RGBAdjust
From Avisynth wiki
(Difference between revisions)
Raffriff42 (Talk | contribs) m (one more touch-up) |
(RGBAdjust generally supports 32 bit float) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | <div style="max-width:62em" > | ||
'''RGBAdjust''' has many different methods of changing the color and luminance of your [[RGB]] clips. Gain, bias (offset) and gamma can be set independently on each channel. Also included are an analysis function and a dither option. | '''RGBAdjust''' has many different methods of changing the color and luminance of your [[RGB]] clips. Gain, bias (offset) and gamma can be set independently on each channel. Also included are an analysis function and a dither option. | ||
All settings for this filter are optional. [[ColorYUV]] works in a similar manner for [[YUV]] clips. | All settings for this filter are optional. [[ColorYUV]] works in a similar manner for [[YUV]] clips. | ||
+ | |||
+ | * {{AvsPluscon}} all [[RGB]] and [[RGBA]] color formats are supported. | ||
+ | |||
+ | |||
__TOC__ | __TOC__ | ||
+ | </div> | ||
+ | |||
== Syntax and Parameters == | == Syntax and Parameters == | ||
− | {{ | + | <div style="max-width:62em" > |
+ | {{FuncDef|RGBAdjust(clip ''clip'' [, <br> | ||
float ''r'', float ''g'', float ''b'', float ''a'', <br> | float ''r'', float ''g'', float ''b'', float ''a'', <br> | ||
float ''rb'', float ''gb'', float ''bb'', float ''ab'', <br> | float ''rb'', float ''gb'', float ''bb'', float ''ab'', <br> | ||
float ''rg'', float ''gg'', float ''bg'', float ''ag'', <br> | float ''rg'', float ''gg'', float ''bg'', float ''ag'', <br> | ||
− | bool ''analyze'', bool ''dither'' ] ) | + | bool ''analyze'', bool ''dither'', {{AvsPluscon}} bool ''conditional'', {{AvsPluscon}} bool ''condvarsuffix'' ] ) |
}} | }} | ||
Line 16: | Line 24: | ||
::Red, green and blue scaling factor. Range 0.0 to 255.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. | ::For example, {{FuncArg|r}}=3.0 multiplies the red channel pixel values by 3. | ||
+ | ::{{AvsPluscon}} [[Autoscale_parameter|autoscaled]] – works without changes at all bit depths, gain is bit depth independent. | ||
:{{Par2|a|float|1.0}} | :{{Par2|a|float|1.0}} | ||
Line 28: | Line 37: | ||
::{{FuncArg|rb}}=16 will add 16 to all red pixel values and | ::{{FuncArg|rb}}=16 will add 16 to all red pixel values and | ||
::{{FuncArg|rb}}=-32 will subtract 32 from all red pixel values. | ::{{FuncArg|rb}}=-32 will subtract 32 from all red pixel values. | ||
+ | ::{{AvsPluscon}} not [[Autoscale_parameter|autoscaled]] – caller must scale arguments by 4 for 10-bit, etc. | ||
:{{Par2|rg|float|1.0}} | :{{Par2|rg|float|1.0}} | ||
Line 42: | Line 52: | ||
::*There is an '''Average''' and a '''Standard Deviation''' 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. | ::*There is '''Loose Minimum''' and '''Loose Maximum''' which ignore the brightest and darkest 0.4% (1/256) pixels. | ||
+ | ::{{AvsPluscon}} parameter is supported for 32 bit float color spaces as well, but loose min/max is based on a 16bit quantized data (loose min/max is based on an internal histogram) | ||
:{{Par2|dither|bool|false}} | :{{Par2|dither|bool|false}} | ||
::If true, [[ordered dithering]] is applied when doing the adjustment. | ::If true, [[ordered dithering]] is applied when doing the adjustment. | ||
+ | ::{{AvsPluscon}} parameter is ignored for 32 bit float color spaces | ||
+ | |||
+ | :{{Par2|conditional|bool|false}} | ||
+ | ::{{AvsPluscon}} If true, the global variables "rgbadjust_xxx" with xxx = r, g, b, a, rb, gb, bb, ab, rg, gg, bg, ag are read each frame, and applied. | ||
+ | ::It is possible to modify these variables using FrameEvaluate or ConditionalReader. (functionality similar to ColorYUV) | ||
+ | |||
+ | :{{Par2|condvarsuffix|string|""}} | ||
+ | :: {{AvsPluscon}} this parameter works similarly in ColorYUV, RGBAdjust, Overlay, ConditionalReader. | ||
+ | :: Allows multiple filter instances to use differently named conditional parameters, thus preventing collision and overwrite of variables which are used by different ConditionalReader instances. | ||
+ | :: See Conditional Variables section of http://avisynth.nl/index.php/ColorYUV. | ||
+ | :: How does it work: when reading the global variables, the "condvarsuffix" parameter is appended to the variable name. | ||
+ | :: E.g. ColorYUV will read "coloryuv_gain_y_a" instead of "coloryuv_gain_y" when condvarsuffix = "_a" is provided for ColorYUV. | ||
+ | :: In the matching ConditionalReader one have to use the modified name as well: | ||
+ | |||
+ | <div {{BoxWidthIndent|80|2}} > | ||
+ | ConditionalReader("coloryuvoffset.txt", "coloryuv_gain_y", false, CondVarSuffix = "_a") # "_a" is added here by parameter | ||
+ | ConditionalReader("rgbfix.txt", "rgbadjust_r", false, CondVarSuffix = "_1") # "_1" is added here by parameter | ||
+ | ConditionalReader("rgbfix2.txt", "rgbadjust_r", false, CondVarSuffix = "_2") # "_2" is added here by parameter | ||
+ | </div> | ||
+ | |||
+ | :: or specify the suffixed name directly: | ||
+ | |||
+ | <div {{BoxWidthIndent|76|2}} > | ||
+ | ConditionalReader("coloryuvoffset.txt", "coloryuv_gain_y_a", false) # "_a" is added here manually | ||
+ | </div> | ||
== Notes == | == Notes == | ||
Line 72: | Line 108: | ||
</div> | </div> | ||
:Thus alpha pixels values become a=(255-a). | :Thus alpha pixels values become a=(255-a). | ||
+ | </div> | ||
== Examples == | == Examples == | ||
+ | <div style="max-width:62em" > | ||
<div id="analyze" style="display:inline;font-size:50%;height:0;line-height:0;overflow:hidden;"></div> | <div id="analyze" style="display:inline;font-size:50%;height:0;line-height:0;overflow:hidden;"></div> | ||
*Demonstrating {{FuncArg|analyze}} output | *Demonstrating {{FuncArg|analyze}} output | ||
<div {{BoxWidthIndent|24|2}} > | <div {{BoxWidthIndent|24|2}} > | ||
[[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4") | [[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4") | ||
+ | [[ConvertToRGB32]] | ||
[[BicubicResize]](546, 272) | [[BicubicResize]](546, 272) | ||
RGBAdjust(analyze=true) | RGBAdjust(analyze=true) | ||
[[File:RGBAdjust_Ex1.jpg]] | [[File:RGBAdjust_Ex1.jpg]] | ||
+ | </div> | ||
</div> | </div> | ||
Line 87: | Line 127: | ||
== Changes == | == Changes == | ||
{| border="1" | {| border="1" | ||
+ | | {{AvsPluscon}} 3.7.1 | ||
+ | | ''analyze'' for 32bit float color spaces | ||
+ | |- | ||
+ | | {{AvsPluscon}} r2915 | ||
+ | | Added ''condvarsuffix'' | ||
+ | |- | ||
+ | | {{AvsPluscon}} r2724 | ||
+ | | Added 32 bit float. | ||
+ | Added ''conditional'' | ||
+ | |- | ||
| v2.60 | | v2.60 | ||
| Added dither. | | Added dither. |
Latest revision as of 10:54, 9 December 2021
RGBAdjust has many different methods of changing the color and luminance of your RGB clips. Gain, bias (offset) and gamma can be set independently on each channel. Also included are an analysis function and a dither option.
All settings for this filter are optional. ColorYUV works in a similar manner for YUV clips.
Contents |
[edit] 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, AVS+ bool conditional, AVS+ bool condvarsuffix ] )
- 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.
- AVS+ autoscaled – works without changes at all bit depths, gain is bit depth independent.
- 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.
- AVS+ not autoscaled – caller must scale arguments by 4 for 10-bit, etc.
- 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.
- AVS+ parameter is supported for 32 bit float color spaces as well, but loose min/max is based on a 16bit quantized data (loose min/max is based on an internal histogram)
- If true, RGBAdjust will print color channel statistics on the screen (see example below)
- bool dither = false
- If true, ordered dithering is applied when doing the adjustment.
- AVS+ parameter is ignored for 32 bit float color spaces
- bool conditional = false
- AVS+ If true, the global variables "rgbadjust_xxx" with xxx = r, g, b, a, rb, gb, bb, ab, rg, gg, bg, ag are read each frame, and applied.
- It is possible to modify these variables using FrameEvaluate or ConditionalReader. (functionality similar to ColorYUV)
- string condvarsuffix = ""
- AVS+ this parameter works similarly in ColorYUV, RGBAdjust, Overlay, ConditionalReader.
- Allows multiple filter instances to use differently named conditional parameters, thus preventing collision and overwrite of variables which are used by different ConditionalReader instances.
- See Conditional Variables section of http://avisynth.nl/index.php/ColorYUV.
- How does it work: when reading the global variables, the "condvarsuffix" parameter is appended to the variable name.
- E.g. ColorYUV will read "coloryuv_gain_y_a" instead of "coloryuv_gain_y" when condvarsuffix = "_a" is provided for ColorYUV.
- In the matching ConditionalReader one have to use the modified name as well:
ConditionalReader("coloryuvoffset.txt", "coloryuv_gain_y", false, CondVarSuffix = "_a") # "_a" is added here by parameter ConditionalReader("rgbfix.txt", "rgbadjust_r", false, CondVarSuffix = "_1") # "_1" is added here by parameter ConditionalReader("rgbfix2.txt", "rgbadjust_r", false, CondVarSuffix = "_2") # "_2" is added here by parameter
- or specify the suffixed name directly:
ConditionalReader("coloryuvoffset.txt", "coloryuv_gain_y_a", false) # "_a" is added here manually
[edit] 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).
[edit] Examples
- Demonstrating analyze output
FFmpegSource2("sintel.mp4") ConvertToRGB32 BicubicResize(546, 272) RGBAdjust(analyze=true)
[edit] Changes
AVS+ 3.7.1 | analyze for 32bit float color spaces |
AVS+ r2915 | Added condvarsuffix |
AVS+ r2724 | Added 32 bit float.
Added conditional |
v2.60 | Added dither. |
v2.56 | Added offsets, gamma, analyze. |