Histogram

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(Undo revision 3697 by Admin (talk))
(remove references to pre-2.58; formatting; new images)
Line 1: Line 1:
 
{{Template:FuncDef|Histogram(clip ''clip'' [, string ''mode''] [, float ''factor''])}}
 
{{Template:FuncDef|Histogram(clip ''clip'' [, string ''mode''] [, float ''factor''])}}
  
Adds a luminance histogram to the right side of the clip.
+
Adds either histogram to the right side of the clip, or an audio monitor overlay, or a standalone audio graph, depending in ''mode''.
  
Starting from AviSynth '''v2.50''' this filter will also show valid and invalid colors in [[YUV]] mode. Invalid values (below 16 and above 235) will be colored brown/yellow-ish.
+
''mode'' can be:
 
+
* [[#Classic_mode|Classic]] (default) and [[#Levels_mode|Levels]] histograms;
Starting in '''v2.53''' an optional mode parameter has been added to show additional information of a clip. Mode can be "classic" (default old mode), "levels", "color", "luma" ('''v2.54'''), "stereo" ('''v2.54'''), "stereooverlay" ('''v2.54'''), "audiolevels" ('''v2.58'''), "color2" ('''v2.58''') and "stereoY8" ('''v2.60'''). Since '''v2.60''' an optional "factor" parameter is added for [[#Levels_mode|levels mode]].
+
* [[#Color_mode|Color]] and [[#Color2_mode|Color2]] vectorscopes;
 +
* [[#Luma_mode|Luma]] special viewing mode;
 +
* [[#Audiolevels_mode|Audiolevels]] audio level meter; and  
 +
* [[#Stereo.2C_StereoY8_and_StereoOverlay_mode|Stereo, StereoOverlay, and StereoY8]] audio graphs.
  
 +
__NOTOC__
  
 +
----
 
=== Classic mode ===
 
=== Classic mode ===
  
 
[[Image:histogram_classic.jpg]]
 
[[Image:histogram_classic.jpg]]
 +
<!-- [[File:Histogram-tournesol-classic.png]] -->
 +
 +
This will add a per-line luminance graph (which is actually called a Waveform Monitor) on the right side of the video.
  
This will add a per-line luminance graph (which is actually called a Waveform Monitor) on the right side of the video. the left side of the graph represents luma = 0 and the right side represents luma = 255. The non-valid CCIR-601 ranges are shown in a brown/yellow-ish color, and a greenish line represents Y = 128.
+
The left side of the graph represents luma=0 and the right side represents luma=255. The non-valid CCIR-601 ranges are shown in a brown/yellowish color, and a greenish line represents Y=128.
  
 
Available in YUV mode.
 
Available in YUV mode.
  
 +
 +
----
 
=== Levels mode ===
 
=== Levels mode ===
  
[[Image:histogram_modelevels.jpg]]
+
<!-- [[Image:histogram_modelevels.jpg]] -->
 +
<!-- [[File:Histogram-tournesol-levels.png]] -->
 +
[[File:Histogram-vortex-levels.png]]
  
This mode will display three [[Levels|level]]-graphs on the right side of the video frame (which are called Histograms). This will show the distribution of the Y, U and V components in the current frame.
+
This mode will display three histograms on the right side of the video frame. This will show the distribution of the Y, U and V components in the current frame.
  
The top graph displays the luma (Y) distribution of the frame, where the left side represents Y = 0 and the right side represents Y = 255. The valid CCIR601 range has been indicated by a slightly different color and Y = 128 has been marked with a dotted line. The vertical axis shows the number of pixels for a given luma (Y) value. The middle graph displays the U component, and the bottom graph displays the V component.
+
The top graph displays the luma (Y) distribution of the frame, where the left side represents Y=0 and the right side represents Y=255. The valid CCIR601 range has been indicated by a slightly different color and Y=128 has been marked with a dotted line. The vertical axis shows the number of pixels for a given luma (Y) value. The middle graph displays the U component, and the bottom graph displays the V component.
  
The "factor" option (100.0 by default) specifies the way how the graphs are displayed. It is specified as percentage of the total population (that is number of luma or chroma pixels in a frame). For example, Histogram("Levels", 1.5625) will achieve a 1/64th cap.
+
The ''factor'' option (100.0 by default) specifies the way how the graphs are displayed. It is specified as percentage of the total population (that is number of luma or chroma pixels in a frame). For example, Histogram("Levels", 1.5625) will achieve a 1/64th cap.
  
'''NOTE''', "factor" is an ''unnamed ''optional argument;<br style="line-height:60%" />
+
'''NOTE''', "factor" is an ''unnamed ''optional argument; <br style="line-height:60%" />
<tt>Histogram(mode="levels", '''factor='''2.5)</tt> will not work, but<br style="line-height:60%" />
+
<code>Histogram(mode="levels", '''factor='''2.5)</code> will not work, but <code>Histogram("levels", 2.5)</code> works fine.
<tt>Histogram("levels", 2.5)</tt> works fine.
+
  
 
Available in all planar modes, except [[Y8]].
 
Available in all planar modes, except [[Y8]].
  
 +
 +
----
 
=== Color mode ===
 
=== Color mode ===
  
[[Image:histogram_modecolor.jpg]]
+
<!-- [[File:Histogram-tournesol-color.png]] -->
 +
[[File:Histogram-vortex-color.png]]
  
 
This mode will display the chroma values (U/V color placement) in a two dimensional graph (which is called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip. At the same time it is a histogram. The whiter a pixel in the vectorscope, the more pixels of the input clip correspond to that pixel (that is the more pixels have this chroma value).
 
This mode will display the chroma values (U/V color placement) in a two dimensional graph (which is called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip. At the same time it is a histogram. The whiter a pixel in the vectorscope, the more pixels of the input clip correspond to that pixel (that is the more pixels have this chroma value).
  
The U component is displayed on the horizontal (X) axis, with the leftmost side being U = 0 and the rightmost side being U = 255. The V component is displayed on the vertical (Y) axis, with the top representing V = 0 and the bottom representing V = 255.
+
<div>
 +
{| border="0"
 +
|
 +
[[File:Labeled-vector6b.png|left|Histogram(mode="color") output with added labels]]
 +
|style="vertical-align:top; margin-right:10%"|
 +
The U component is displayed on the horizontal (X) axis, with the leftmost side being U=0 and the rightmost side being U=255. The V component is displayed on the vertical (Y) axis, with the top representing V=0 and the bottom representing V=255.
  
 
The position of a white pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the square. At the center of the square, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the square.
 
The position of a white pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the square. At the center of the square, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the square.
 
+
|}</div>
 +
<div style="clear:none">
 
Available in all planar modes except Y8.
 
Available in all planar modes except Y8.
 +
</div>
 +
  
 +
----
 
=== Color2 mode ===
 
=== Color2 mode ===
  
[[Image:histogram_modecolor2.jpg]]
+
<!-- [[File:Histogram-tournesol-color2.png]] -->
 +
[[File:Histogram-vortex-color2.png]]
  
This mode will display the pixels in a two dimensional graph (which is called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip.
+
This mode will display the pixels in a two dimensional graph (called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip.
  
The U component is displayed on the horizontal (X) axis, with the leftmost side being U = 0 and the rightmost side being U = 255. The V component is displayed on the vertical (Y) axis, with the top representing V = 0 and the bottom representing V = 255. The grey square denotes the valid CCIR-601 range.  
+
The U component is displayed on the horizontal (X) axis, with the leftmost side being U=0 and the rightmost side being U=255. The V component is displayed on the vertical (Y) axis, with the top representing V=0 and the bottom representing V=255. The grey square denotes the valid CCIR-601 range.  
  
 
The position of a pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the circle. At the center of the circle, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the circle. A color wheel is plotted and divided into six hues (red, yellow, green, cyan, blue and magenta) to help you reading of the hue values. Also every 15 degrees a white dot is plotted.
 
The position of a pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the circle. At the center of the circle, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the circle. A color wheel is plotted and divided into six hues (red, yellow, green, cyan, blue and magenta) to help you reading of the hue values. Also every 15 degrees a white dot is plotted.
  
At U=255, V=128 the hue is zero (which corresponds to blue) and the saturation is maximal, that is, sqrt( (U-128)^2 + (V-128)^2 ) = 127. When turning clock-wise, say 90 degrees, the chroma is given by U=128, V=255 (which corresponds to red). Keeping the hue constant and decreasing the saturation, means that we move from the circle to the center of the vectorscope. Thus the color flavor remains the same (namely red), only it changes slowly to [[GreyScale|greyscale]].  Etc ...
+
At U=255, V=128 the hue is zero (which corresponds to blue) and the saturation is maximal, that is, <code>sqrt( (U-128)^2 + (V-128)^2 ) = 127</code>. When turning clock-wise, say 90 degrees, the chroma is given by U=128, V=255 (which corresponds to red). Keeping the hue constant and decreasing the saturation, means that we move from the circle to the center of the vectorscope. Thus the color flavor remains the same (namely red), only it changes slowly to [[GreyScale|greyscale]].  Etc ...
  
 
Available in all planar modes except Y8.  
 
Available in all planar modes except Y8.  
  
 +
 +
----
 
=== Luma mode ===
 
=== Luma mode ===
  
 
[[Image:histogram_modeluma.jpg]]
 
[[Image:histogram_modeluma.jpg]]
  
This mode will [[Amplify|amplify]] luminance, and display very small luminance variations. This is good for detecting blocking and noise, and can be helpful at adjusting [[Internal_filters|filter]] parameters. In this mode a 1 pixel luminance difference will show as a 16 pixel luminance pixel, thus seriously enhancing small flaws.  
+
This mode will amplify luminance, and display very small luminance variations. This is good for detecting blocking and noise, and can be helpful at adjusting filter parameters. In this mode a 1 pixel luminance difference will show as a 16 pixel luminance pixel, thus seriously enhancing small flaws.  
  
 
Available in planar and YUY2 modes.
 
Available in planar and YUY2 modes.
  
=== Stereo, StereoY8 and StereoOverlay mode ===
 
 
[[Image:histogram_modestereo.gif]]
 
 
This mode shows a classic stereo graph, from the audio in the clip. Some may know these from recording studios. This can be used to see the left-right and phase distribution of the input signal. StereoOverlay will overlay the graph on top of the original. Each frame will contain only information from the current frame to the beginning of the next frame. The signal is linearly upsampled 8x, to provide clearer visuals. Stereo and StereoY8 won't overlay the graph on the video, but will just return the graph (in YV12 respectively Y8 format).
 
 
This mode requires a stereo signal input and StereoOverlay input is planar only.
 
  
 +
----
 
=== Audiolevels mode ===
 
=== Audiolevels mode ===
  
 
[[Image:histogram_audiolevels.jpg]]
 
[[Image:histogram_audiolevels.jpg]]
  
This mode shows the audiolevels for each channel in decibels (multichannel is supported). More accurately it determines:
+
This mode shows the audio levels for each channel in decibels; multichannel is supported. More accurately it determines:
  
* the root mean square value of the samples belonging to each frame (let's say n samples) and converts this value to decibels using the following formula:
+
* the root mean square value of the samples belonging to each frame (let's say n samples) and converts this value to decibels using the following formula for each channel:
  
<math> RMS = 20 \cdot log_{10}( 1/32768 \cdot \sqrt{ 1/n \cdot \sum_{j=1}^{n} sample(j)^{2}} ) </math> # for each channel
+
::[[File:Histogram-eq-1.png|<math> RMS = 20 \cdot log_{10}( 1/32768 \cdot \sqrt{ 1/n \cdot \sum_{j=1}^{n} sample(j)^{2}} ) </math>]]
  
* the maximum volume of the samples belonging to each frame and converts this value to decibels using the following formula:
+
* the maximum volume of the samples belonging to each frame and converts this value to decibels using the following formula for each channel:
  
<math> max = 20 \cdot log_{10}(max_{j} (sample(j)) / 32768) </math> # for each channel
+
::[[File:Histogram-eq-2.png|<math> max = 20 \cdot log_{10}(max_{j} (sample(j)) / 32768) </math>]]
  
 
The bars corresponding to the root mean square value are green, and to the maximum are blue. The filter is available in planar mode and the audio is converted to 16 bit. Note that for 16 bit audio, the maximal volume could be
 
The bars corresponding to the root mean square value are green, and to the maximum are blue. The filter is available in planar mode and the audio is converted to 16 bit. Note that for 16 bit audio, the maximal volume could be
  
<math> 20 \cdot log_{10}(32768/32768) = 0 \ dB </math> (since 2^16/2 = 32768)
+
::[[File:Histogram-eq-3.png|<math> 20 \cdot log_{10}(32768/32768) = 0 \ dB </math>]]
  
and the minimal volume
+
(since 2^16/2 = 32768), and the minimal volume is
 +
 
 +
::[[File:Histogram-eq-4.png|<math> 20 \cdot log_{10}(1/32768) = - 90.31 \ dB </math>]]
 +
 
 +
 
 +
----
 +
=== Stereo, StereoY8 and StereoOverlay mode ===
 +
 
 +
[[Image:histogram_modestereo.gif]]
 +
 +
This mode shows a classic stereo graph, from the audio in the clip. Some may know these from recording studios. This can be used to see the left-right and phase distribution of the input signal. '''StereoOverlay''' will overlay the graph on top of the original. Each frame will contain only information from the current frame to the beginning of the next frame. The signal is linearly upsampled 8x, to provide clearer visuals. '''Stereo''' and '''StereoY8''' won't overlay the graph on the video, but will just return the graph (in YV12 respectively Y8 format).
  
<math> 20 \cdot log_{10}(1/32768) = - 90.31 \ dB </math>
+
This mode requires a source clip with stereo audio; StereoOverlay requires a source clip with a [[Planar|planar]] color format.
  
  
 +
----
 
=== Changes ===
 
=== Changes ===
  
Line 119: Line 150:
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Audio_filters]]
 +
[[Category:Levels_and_Chroma_filters]]

Revision as of 01:56, 8 October 2014

Histogram(clip clip [, string mode] [, float factor])

Adds either histogram to the right side of the clip, or an audio monitor overlay, or a standalone audio graph, depending in mode.

mode can be:



Classic mode

Histogram classic.jpg

This will add a per-line luminance graph (which is actually called a Waveform Monitor) on the right side of the video.

The left side of the graph represents luma=0 and the right side represents luma=255. The non-valid CCIR-601 ranges are shown in a brown/yellowish color, and a greenish line represents Y=128.

Available in YUV mode.



Levels mode

Histogram-vortex-levels.png

This mode will display three histograms on the right side of the video frame. This will show the distribution of the Y, U and V components in the current frame.

The top graph displays the luma (Y) distribution of the frame, where the left side represents Y=0 and the right side represents Y=255. The valid CCIR601 range has been indicated by a slightly different color and Y=128 has been marked with a dotted line. The vertical axis shows the number of pixels for a given luma (Y) value. The middle graph displays the U component, and the bottom graph displays the V component.

The factor option (100.0 by default) specifies the way how the graphs are displayed. It is specified as percentage of the total population (that is number of luma or chroma pixels in a frame). For example, Histogram("Levels", 1.5625) will achieve a 1/64th cap.

NOTE, "factor" is an unnamed optional argument;
Histogram(mode="levels", factor=2.5) will not work, but Histogram("levels", 2.5) works fine.

Available in all planar modes, except Y8.



Color mode

Histogram-vortex-color.png

This mode will display the chroma values (U/V color placement) in a two dimensional graph (which is called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip. At the same time it is a histogram. The whiter a pixel in the vectorscope, the more pixels of the input clip correspond to that pixel (that is the more pixels have this chroma value).

Histogram(mode="color") output with added labels

The U component is displayed on the horizontal (X) axis, with the leftmost side being U=0 and the rightmost side being U=255. The V component is displayed on the vertical (Y) axis, with the top representing V=0 and the bottom representing V=255.

The position of a white pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the square. At the center of the square, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the square.

Available in all planar modes except Y8.



Color2 mode

Histogram-vortex-color2.png

This mode will display the pixels in a two dimensional graph (called a vectorscope) on the right side of the video frame. It can be used to read of the hue and saturation of a clip.

The U component is displayed on the horizontal (X) axis, with the leftmost side being U=0 and the rightmost side being U=255. The V component is displayed on the vertical (Y) axis, with the top representing V=0 and the bottom representing V=255. The grey square denotes the valid CCIR-601 range.

The position of a pixel in the graph corresponds to the chroma value of a pixel of the input clip. So the graph can be used to read of the hue (color flavor) and the saturation (the dominance of the hue in the color). As the hue of a color changes, it moves around the circle. At the center of the circle, the saturation is zero, which means that the corresponding pixel has no color. If you increase the amount of a specific color, while leaving the other colors unchanged, the saturation increases, and you move towards the edge of the circle. A color wheel is plotted and divided into six hues (red, yellow, green, cyan, blue and magenta) to help you reading of the hue values. Also every 15 degrees a white dot is plotted.

At U=255, V=128 the hue is zero (which corresponds to blue) and the saturation is maximal, that is, sqrt( (U-128)^2 + (V-128)^2 ) = 127. When turning clock-wise, say 90 degrees, the chroma is given by U=128, V=255 (which corresponds to red). Keeping the hue constant and decreasing the saturation, means that we move from the circle to the center of the vectorscope. Thus the color flavor remains the same (namely red), only it changes slowly to greyscale. Etc ...

Available in all planar modes except Y8.



Luma mode

Histogram modeluma.jpg

This mode will amplify luminance, and display very small luminance variations. This is good for detecting blocking and noise, and can be helpful at adjusting filter parameters. In this mode a 1 pixel luminance difference will show as a 16 pixel luminance pixel, thus seriously enhancing small flaws.

Available in planar and YUY2 modes.



Audiolevels mode

Histogram audiolevels.jpg

This mode shows the audio levels for each channel in decibels; multichannel is supported. More accurately it determines:

  • the root mean square value of the samples belonging to each frame (let's say n samples) and converts this value to decibels using the following formula for each channel:
<math> RMS = 20 \cdot log_{10}( 1/32768 \cdot \sqrt{ 1/n \cdot \sum_{j=1}^{n} sample(j)^{2}} ) </math>
  • the maximum volume of the samples belonging to each frame and converts this value to decibels using the following formula for each channel:
<math> max = 20 \cdot log_{10}(max_{j} (sample(j)) / 32768) </math>

The bars corresponding to the root mean square value are green, and to the maximum are blue. The filter is available in planar mode and the audio is converted to 16 bit. Note that for 16 bit audio, the maximal volume could be

<math> 20 \cdot log_{10}(32768/32768) = 0 \ dB </math>

(since 2^16/2 = 32768), and the minimal volume is

<math> 20 \cdot log_{10}(1/32768) = - 90.31 \ dB </math>



Stereo, StereoY8 and StereoOverlay mode

Histogram modestereo.gif

This mode shows a classic stereo graph, from the audio in the clip. Some may know these from recording studios. This can be used to see the left-right and phase distribution of the input signal. StereoOverlay will overlay the graph on top of the original. Each frame will contain only information from the current frame to the beginning of the next frame. The signal is linearly upsampled 8x, to provide clearer visuals. Stereo and StereoY8 won't overlay the graph on the video, but will just return the graph (in YV12 respectively Y8 format).

This mode requires a source clip with stereo audio; StereoOverlay requires a source clip with a planar color format.



Changes

v2.60 Added StereoY8 mode. Added factor option.
v2.58 Added planar support. Color2 and Audiolevels modes added.
v2.56 Added invalid colors in YUY2 mode.
v2.56 Added dots to mode = "stereo" to show bias/offsets.
v2.53 Added different modes.
Personal tools