HDR AGC version 1.8.7  (for AviSynth)

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.

Download now!
 

Discussions thread:
http://forum.doom9.org/showthread.php?t=93571

This plugin support YV12 and YUY2 color sprace.
Usage:

AVISource(...)
SeparateFields() #if content is interlaced
HDRAGC()
Weave() #if content is interlaced


MOST IMPORTANT PARAMETERS:
coef_gain (default 1.0) - increase parameter to get brighter image, decrease to limit auto brightening
coef_sat (1.0) - incerease to bring more saturation

TODO for 2.0 version
- MMX, SSE, SSE2 optimization

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


Examples:
- original shoots taken from this site: http://www.videomax.ru/tests/

Parameters for all sample: min_gain = 3.0, coef_sat = 3.0
1. Simple gain of low-light scene with local saturation enhancement (original / HDR AGC)


2. Backlight compensation (Original / Normal gain / HDR AGC)


3. Shadow gaining (Original / Normal gain / HDR AGC)


Syntax:
HDRAGC(int avg_lum, 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, float black_clip)


Parameter description:
avg_lum [int]
average luminance to which video should be gained (default - 128 )
max_gain [float]
maximum gain value which can't be passed by auto control (default 3.0)
min_gain [float]
minimum gain (default 1.0)
coef_gain [float]
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)
max_sat [float]
maximum gain for saturation (default 9.0, 1.0 means no saturation enhancment, below 1.0 - desaturation)
min_sat [float]
minimum saturation enhancment (default 0.0)
coef_sat [float]
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< BR > mode [int]
value 0 - algorithm from 0.2 version
value 1 - new algorithm
value 2 - new algorithm with some float precision (default), 30% slower than mode = 1
protect [int]
value 0 - no protection for highlights
value 1 - protects highlights from blowing
value 2 (default) - plugin automatically choose between 0 (off) and 1 (on)
passes [int]
number of interations for mode 0 (values from 1 to 9, default 4)
black_clip [float]
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) 
shift [int]
every luminance value x is shifted down by shift (x = x - shift), helpfull in low-light, some camcorders brighten image by getin black more gray (default 0)
shift_u, shift_u [int]
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)
corrector [float]
default 0.0 - auto correction, recommended values 0.8 - 1.0. The lower value then less bright parts of image are gained (help for high values of gain)
reducer [float]
default 0.5, values from 0.0 to 2.0. The higher value the more noise is removed from gained shadows
shadows [bool]
default true - not only gain but also enhance shadows
avg_window [int]
number of frames for averaging gain value (default one second = 25 frames for PAL, 30 frames for NTSC, etc)
response [int]
how much gain value can differ between frames (default 100%, there is no pumping effect, so it's needed only in special cases)
debug [int]
value 1 displays calculated gain value for frame (default 0)
freezer [int]
number of the frame (from 0), that will be taken to calculate all parameters, the parameters are then constant in time (deafult -1, which means that parameters will be calculated for every frame)

Version changes:
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 choosen 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 routin (sigma parameter not needed)
    - new mode (mode = 2) in which radius is adaptively choosen, 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:
    - improvments - 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