HistogramAdjust

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(Syntax and Parameters)
(Update page to match HistogramAdjust)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{{FilterCat4|External_filters|Plugins|Adjustment_filters|Levels_and_Chroma_filters}}
{{FilterCat4|External_filters|Plugins|<!-- category -->TODO|<!-- category -->TODO}}
+
 
+
 
{{Filter3
 
{{Filter3
|[http://www.avisynth.nl/users/vcmohan/ V.C.Mohan]
+
|{{Author/vcmohan}}
|25 Aug 2017
+
|18 oct 2015
|[http://www.avisynth.nl/users/vcmohan/modPlus/modPlus.7z modPlus.7z]
+
|[http://www.avisynth.nl/users/vcmohan/HistogramAdjust/HistogramAdjust_2_6.zip HistogramAdjust_2_6.zip]
 
|4=<!-- category -->External filters
 
|4=<!-- category -->External filters
 
|5=<!-- license -->[https://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
 
|5=<!-- license -->[https://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
|6=<!-- discussion URL -->[https://forum.doom9.org/showthread.php?p=719889#post719889 HistogramAdjust  plugin]}}
+
|6=<!-- discussion URL -->[https://forum.doom9.org/showthread.php?p=719889#post719889 Doom9 Forum]}}
  
 
<br>
 
<br>
 
== Description ==
 
== Description ==
<!---->
+
[[HistogramAdjust]], 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
  
This 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.
+
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 cumulative 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.  
  
The function accepts RGB, YUY2 and Planar 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. However their bit depths must be same.
 
  
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 = 3) or %cummulative population (type = 4) at this value.The table is normalized by the function and so approximate values are OK. 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 tweaked ( in case all 3 color components of RGB input are to be tweaked the function may be invoked in the script 3 times). For other formats only Y value histogram is tweaked.
+
*Official documentation: http://www.avisynth.nl/users/vcmohan/HistogramAdjust/HistogramAdjust.html
 +
 
 +
*For AviSynth+ see [[modPlus]], includes high bit depth colorspace support and 64-bit.
 
<br>
 
<br>
 
== Requirements ==
 
== Requirements ==
* AviSynth+ r2347 or greater
+
* [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6]
* source video: progressive
+
* Supported color formats: [[RGB24]], [[RGB32]], [[YUY2]], [[Y8]], [[YV12]], [[YV16]], [[YV24]]
* color formats -->Supported color formats: [[YUY2]], [[YV12]],[[YV16]], [[YV24]], [[YV411]], [[Y8]]
+
<br>
 
+
 
== [[Script variables|Syntax and Parameters]] ==
 
== [[Script variables|Syntax and Parameters]] ==
:{{Template:FuncDef|<!-- function name -->HistogramAdjust(''clip'', ''<!-- par 1 type -->int type, clip mclip, int mf, int w, int limit, int rgb <!-- par 1 name -->)}}
+
:{{Template:FuncDef|TweakHist (clip, int*, int "type", clip "mclip", int "mf", int "limit", int "wsize", int "rgb")}}
 
<br>
 
<br>
 
::{{Par2| |clip| }}
 
::{{Par2| |clip| }}
:::Input clip.      
+
:::Input clip.
 
<br>
 
<br>
::{{Par2|<!-- par 2 type -->string|<!-- par 2 name -->type|<!-- par 2 default value -->"equal"}}
+
::{{Par2| |clip| }}
:::The following is a table of Histogram values in %ages, to be specified only if 'table' is true
+
:::The following is a table of Histogram values, to be specified only if <code>table</code> is true.
 +
:::* Luma value: integer, 0 to 255 and to increase monotonically.
 +
:::* Population or cummulative population at this luma value: integer, non negative. In case of <code>type=5</code>, should monotonically increase and Max value is 256.
 
<br>
 
<br>
::{{Par2|<!-- par 3 type -->int|<!-- par 3 name -->|<!-- par 3 default value -->}}
+
::{{Par2|type|int|1}}
:::Luma value % of maximum.
+
::: Type of process:
 +
:::* 1 : full frame equalization
 +
:::* 2 : windowed equalization
 +
:::* 3 : matching with specified frame
 +
:::* 4 : matching with given table of Luma, population
 +
:::* 5 : luma vs cummulative population
 
<br>
 
<br>
::{{Par2|<!-- par 4 type -->clip|<!-- par 4 name -->|<!-- par 4 default value -->}}
+
::{{Par2|mclip|clip|}}
:::% age of population or cumulative population at this luma value
+
::: Clip in which image for matching is available. Valid clip to be specified only if required.
 +
::: Input clip to be processed and clip to be used for matching do not need to have identical color formats and dimensions.
 +
::: For example processing clip can be YV12, 720 X 480 pixels while matching clip is YV16, 256 X 16 pixels.
 
<br>
 
<br>
::{{Par2|<!-- par 5 type -->int|<!-- par 5 name -->type|<!-- par 5 default value -->1}}
+
::{{Par2|mf|int|0}}
:::Type of process
+
:::Frame number on clip for matching
 
<br>
 
<br>
::{{Par2|<!-- par 6 type -->clip|<!-- par 6 name -->mclip|<!-- par 6 default value -->dummy clip}}
+
::{{Par2|limit|int|100}}
:::Clip in which image for matching is available.
+
::: Limit on % of change in value allowed.
 +
:::* Range: 1 to 100
 
<br>
 
<br>
::{{Par2|<!-- par 7 type -->integer, may be specified for type = 2 option|<!-- par 7 name -->w|<!-- par 7 default value -->0}}
+
::{{Par2|wsize|int|2}}
:::<!-- frame number on clip for matching.
+
:::If windowed processing opted size of window.
 
+
:::*1 : coarse
<br>
+
:::*2 : medium
::{{Par2|<!-- par 8 type -->int|<!-- par 8 name -->limit|<!-- par 8 default value -->100}}
+
:::*3 : fine
:::limit on % of change in value from original for tweaking allowed.
+
<br>
+
::{{Par2|<!-- par 9 type -->int|<!-- par 9 name -->rgb|<!-- par 9 default value -->1}}
+
:::percentage of deviation from original value of luma to be allowed.
+
<br>
+
 
+
 
<br>
 
<br>
 +
::{{Par2|rgb|int|1}}
 +
:::Color of RGB input to process:
 +
:::*0 : Red
 +
:::*1 : Green
 +
:::*2 : Blue
 
<br>
 
<br>
  
 
== Examples ==
 
== Examples ==
  
: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)
  
::TweakHist()
+
*RGB input. Repeated for each color
::TweakHist(c, type=2, mclip=mm, mf=26)
+
::TweakHist(c, 15, 2, 30, 12, 50, 33, 90, 12, 150, 35, 200, 10, type=3, limit=50)
+
::TweakHist(20, 1, 150, 100, 255, 110, type=4, limit=70)
+
:RGB input. Repeated for each color
+
::TweakHist(limit = 70, rgb = 0)
+
::TweakHist(limit = 70, rgb = 1)
+
::TweakHist(limit = 50, rgb = 2)
+
  
 +
HistogramAdjust(limit = 70,rgb = 0)
 +
HistogramAdjust(limit = 70,rgb = 1)
 +
HistogramAdjust(limit = 50, rgb = 2)
 
<br>
 
<br>
 +
<br>
 +
-----------------------------------------------
 +
'''Back to [[External_filters#Levels_and_Chroma|External Filters]] &larr;'''
 
-----------------------------------------------
 
-----------------------------------------------
'''Back to [[External_filters|External Filters]] &larr;'''
 

Latest revision as of 03:30, 8 June 2020

Abstract
Author V. C. Mohan
Version 18 oct 2015
Download HistogramAdjust_2_6.zip
Category External filters
License GPLv2
Discussion Doom9 Forum


Contents

[edit] Description

HistogramAdjust, 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

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 cumulative 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.


  • For AviSynth+ see modPlus, includes high bit depth colorspace support and 64-bit.


[edit] Requirements


[edit] Syntax and Parameters

TweakHist (clip, int*, int "type", clip "mclip", int "mf", int "limit", int "wsize", int "rgb")


clip   =
Input clip.


clip   =
The following is a table of Histogram values, to be specified only if table is true.
  • Luma value: integer, 0 to 255 and to increase 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.


int  type = 1
Type of process:
  • 1 : full frame equalization
  • 2 : windowed equalization
  • 3 : matching with specified frame
  • 4 : matching with given table of Luma, population
  • 5 : luma vs cummulative population


clip  mclip =
Clip in which image for matching is available. Valid clip to be specified only if required.
Input clip to be processed and clip to be used for matching do not need to have identical color formats and dimensions.
For example processing clip can be YV12, 720 X 480 pixels while matching clip is YV16, 256 X 16 pixels.


int  mf = 0
Frame number on clip for matching


int  limit = 100
Limit on % of change in value allowed.
  • Range: 1 to 100


int  wsize = 2
If windowed processing opted size of window.
  • 1 : coarse
  • 2 : medium
  • 3 : fine


int  rgb = 1
Color of RGB input to process:
  • 0 : Red
  • 1 : Green
  • 2 : Blue


[edit] 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)




Back to External Filters


Personal tools