HistogramAdjust


Author V. C. Mohan
Date 3 Oct 2015
EMail: mohanvc

This plugin function adjusts the histogram of a frame by either equalizing it or by matching with histogram of another image, or with given histogram table of values.

Windowed equalization . In this mode the window for deriving the input clip histogram, steps half window size each time. This windowed processing may not be suitable for all images.Possible blocky appearance. 3 window sizes for coarse, medium and fine output. Use of small value for limit may give better results

The function accepts RGB, YUY2 and Planar (YUY2 and YV12 only in 2.5 version) color formats. Clip to be processed and to be used for matching need not have identical color formats and dimensions. For example processing clip can be YV12 , 720 X 480 pixels while matching clip is YUY2, 256 X 16 pixels.

If matching with given table values, then matching clip need not be specified. The second parameter is a table of integer pairs.Each pair consists of Luma ( intensity)value and the second number is population (type = 4) or cummulative population (type = 5) at this value.The table is normalized by the plugin and so approximate values are OK. Due to limitation of number of parameters that can be input through Avisynth, not more than 25 pairs can be specified. It will be possible to input by table any desired histogram shape. The plugin linearly interpolates and extrapolates to construct a full normalized histogram from these values. In case of RGB input the selected color histogram is adjusted. For other formats Y value histogram is adjusted.


Details of parameters
Description Name Type Limits Default
Input clip histogram of which is to be altered clip none
The following is a table of Histogram values, to be specified only if 'table' is true
Luma value integer 0 to 255 and to inrease monotonically
population or cummulative population at this luma value integer non negative. In case of type = 5, should monotonically increase and Max value is 256.
Type of process type integer 1 for equalization 2. for windowed equalization, 3 for matching with specified frame, 4 for matcing with given table of Luma, population. 5. for luma vs cummulative population 1
Clip in which image for matching is available mclip clip valid clip to be specified only if required dummy clip
frame number on clip for matching mf integer within clip 0
limit on % of change in value allowed. limit integer 1 to 100 100
If windowed processing opted size of window. wsize integer 1(coarse), 2 (mediu) and 3 (fine) 2
color of RGB input to process. rgb integer 0: red, 1 : Green, 2: Blue 1 (green)

#Usage examples:-
HistogramAdjust() 
HistogramAdjust(c,type=3,mclip=mm,mf=26)
HistogramAdjust(c,15,2, 30,12, 50, 33, 90, 12,150,35,200,10, type=4,limit=50)
HistogramAdjust(20,1,150,100,255,110, type=5,limit = 70) 
# RGB input. Repeated for each color
HistogramAdjust(limit = 70,rgb = 0)
HistogramAdjust(limit = 70,rgb = 1)
HistogramAdjust(limit = 50, rgb = 2)
To my index page To Avisynth