# HDRAGC

From Avisynth wiki

Abstract | |
---|---|

Author | paviko |

Version | v1.8.7 |

Download | Hdragc-1.8.7.zip |

Category | Levels and Chroma |

License | Closed source |

Discussion | Doom9 Thread |

## Contents |

## [edit] Description

**High Dynamic Range Automatic Gain Control** - this plugin increase dynamic range of video clips (enhance shadows). It's "simply" gaining (brightening) dark areas of image without causing blow of highlights and is doing it by simulating the work of our eyes. Amount of gain is calculated automatically but you can also influence on it by parameters.

## [edit] Requirements

- [x86]: AviSynth+ or AviSynth 2.5.8 or greater
- Supported color formats: YUY2, YV12

## [edit] Syntax and Parameters

- HDRAGC (clip, float "max_gain", float "min_gain", float "coef_gain", float "max_sat", float "min_sat", float "coef_sat", int "avg_window", int "response", int "debug", int "mode", int "protect", int "passes", int "shift", bool "shadows", int "shift_u", int "shift_v", float "corrector", float "reducer", int "corrector_mode", int "avg_lum", float "black_clip", int "freezer")

*clip*=

- Input clip.

*float*max_gain =*3.0*

- Maximum gain value which can't be passed by auto control.

*float*min_gain =*1.0*

- Minimum gain.

*float*coef_gain =*1.5*

- How to change auto calculation of gain. Default is 1.0, if you set 1.5 then if previously plugin was finding 2.0 gain, now it will 2.5 (1.0 + (2.0 - 1.0) * coef_gain).

*float*max_sat =*9.0*

- Maximum gain for saturation (default 9.0, 1.0 means no saturation enhancement, below 1.0 - desaturation).

*float*min_sat =*0.0*

- Minimum saturation enhancement.

*float*coef_sat =*1.0*

- How saturation control is connected with gain control, sat = (gain - 1.0) * coef_sat (default 1.0 - means that if pixel is gained by factor 2.0, saturation is also gained 2.0). When setting coef_sat below 1.0, look also at min_sat parameter

*int*avg_window =

- Number of frames for averaging gain value (default one second = 25 frames for PAL, 30 frames for NTSC, etc).

*int*response =*100*

- How much gain value can differ between frames (default 100%, there is no pumping effect, so it's needed only in special cases).

*int*debug =*0*

- Value 1 displays calculated gain value for frame (default 0).

*int*mode =*2*

- Algorithm to use:
- 0 : algorithm from 0.2 version
- 1 : new algorithm
- 2 : new algorithm with some float precision (default), 30% slower than mode = 1

- Algorithm to use:

*int*protect =*2*

- Protection mode:
- 0 : no protection for highlights
- 1 : protects highlights from blowing
- 2 : plugin automatically choose between 0 (off) and 1 (on) - (default)

- Protection mode:

*int*passes =*4*

- Number of iterations for mode 0 (values from 1 to 9, default 4).

*int*shift =*0*

- every luminance value x is shifted down by shift (x = x - shift), helpful in low-light, some camcorders brighten image by getting black more gray (default 0).

*bool*shadows =*true*

- Default true - not only gain but also enhance shadows.

*int*shift_u =*0*

*int*shift_v =*0*

- Parameters for sublte white balance correction, shift_u < 0 - removes blue tint, shift_u > 0 - removes yellow tint, shift_v < 0 - removes red tint, shift_v > 0 - removes green tint (default 0).

*float*corrector =*0.0*

- Auto correction, recommended values 0.8 - 1.0, default 0.0. The lower value then less bright parts of image are gained (help for high values of gain).

*float*reducer =*0.5*

- Default 0.5, values from 0.0 to 2.0. The higher value the more noise is removed from gained shadows.

*int*corrector_mode =

- Undocumented parameter.

*int*avg_lum =*128*

- Average luminance to which video should be gained.

*float*black_clip =*0.0*

- Value in percents, that force to treat first x% darkest pixels as black pixels (works as auto shift), recommended values 0.0 - 1.0 (default 0.0).

*int*freezer =*-1*

- Number of the frame (from 0), that will be taken to calculate all parameters, the parameters are then constant in time (default -1, which means that parameters will be calculated for every frame).

### [edit] Most Important Parameters

`coef_gain`

(default 1.0) - increase parameter to get brighter image, decrease to limit auto brightening`coef_sat`

(1.0) - increase to bring more saturation

#### [edit] Tips

1. I'd like to have brigther results.

- Try increasing coef_gain and/or min_gain

2. Image lacks colours saturation after brightening

- Try increasing coef_sat parameter

3. I would like to operate only in luma (without changing chrominance channels)

- Set max_sat to 1.0

4. When I set coef_sat lower that 1.0, bright area of image are loosing saturation

- Set min_sat to 1.0 (default value id 0.0)

5. Bright areas of image are too much gained

- Try corrector parameter - recommended values are (0.8 - 1.0), the lower value then less gain is applied to brighter part of image

6. Gained parts have too much noise

- Try increasing reducer parameter. Default value is 0.5, max is 2.0

## [edit] Examples

AviSource("blah.avi") HDRAGC()

## [edit] Changelog

Version 1.8.7 - 10.09.2006 - fixed crash when black_clip is not used Version 1.8.6 - 09.09.2006 - added 'freezer' parameter - number of frame that is chosen to calculate gain parameters Version 1.8.5 - 10.06.2006 - added auto shifting (black_clip parameter) - avg_lum parameter is back - new mode (mode = 2), which is using float precision for some calculations (best quality, now mode = 2 as default) - fixed behaviour of coef_gain (for coef_gain > 1.0 it works as in previous versions) - tweaked corrector (by default it's not a bit lower, so if you were using previously x, now try x + 0.1) Version 1.8.1 - 13.05.2006 - fixed crash for black frame (thanks to Boulder) Version 1.8 - 13.05.2006 - huge jump in version, huge jump in quality ;) - improved old algorithm from version 0.2.1 (mode = 0), new algorithm (mode = 1) that even for high gains give natural picture - added support for YV12 and YUY2, removed RGB32 - 3 times faster (but still without MMX, SSE, SSE2 optimizations) - 10 times less memory usage - better handling of saturation - new parameters for sublte color correction (shift_u, shift_v) Version 0.2.1 - alpha - 25.10.2005: - fixed sharpening/denoising (they were turned off when gain was not applied to image) - fixed protect mode Version 0.2.0 - alpha - 23.10.2005: - completely new lighting routine (sigma parameter not needed) - new mode (mode = 2) in which radius is deceptively chosen, this removes artifacts as much as I was able to do ;). Slow, but faster and much, much better than mode = 0 - mode = 1 is again 2 times faster (and will be faster later, still no MMX, SSE optimization) - new parameter - protect - for value = 1 it can help in some situation with blowing highlights (default on) - new parameters - contrast, limit - for denoising/sharpening, almost for free - no slow down (experimental) Version 0.1.5 alpha - 21.05.2005: - improvements - 4 times faster with significantly reduced halo artifacts (if you want old behaviour use parameter mode = 0) Version 0.1.2 alpha - 30.04.2005: - changed lightness distribution routine (less plastic look - midtones have higher contrast) - new value for auto control of saturation - calculated gain is independent of avg_lum parameter Version 0.1.1 alpha - 29.04.2005: - fixed bug with avg_lum (thanks to AVIL) - small c optimization (thanks to tsp) - new parameters (coef_gain, min_sat, circle) Version 0.1 alpha - 25.04.2005 - first release

## [edit] Archived Downloads

Version | Download | Mirror |
---|---|---|

v1.8.7 | Hdragc-1.8.7.zip | |

v0.1.2 alpha | hdragc_5F25_dll_20050521.zip | hdragc_25_dll_20050521.zip |

- v0.1.2 alpha includes source code.

## [edit] External Links

- hdragc.htm - official archived documentation (note: some parameters are listed out of order).

**Back to External Filters ←**