Histogram Equalization Filter for VirtualDub

This filter applies a global color histogram equalization on a per-frame basis. It can be used to correct video that has a compressed range of pixel intensities. The filter redistributes the pixel intensities to equalize their distribution across the intensity range. It may be viewed as an "automatically adjusting contrast filter". This filter is useful only for correcting degraded or poorly captured source video. It should not be applied willy-nilly, as it leads to a modification of image content.

Following are before and after images and histograms for a typical input frame, using strength 132 and maximum intensity 200, no antibanding (see note below on the histograms):

It can be seen that the output histogram is strongly banded due to the mapping of a small range of intensity values to a larger range. If the banded pixels are distributed spatially (as they are in our example), this may not be noticeable or objectionable in the output video. However, if the banded pixels are arrayed spatially, as you might get in a brightness gradient, you may see overt banding, or posterization. To combat this, an antibanding capability is provided. Following are the after image and histogram for the above example with strong antibanding enabled. The banding is greatly reduced but at the expense of the addition of some random intensity noise.

The following configuration options are supported:

Strength: This option determines the amount of equalization to be applied. As the strength is reduced, the distribution of pixel intensities more-and-more approaches that of the input frame.

Maximum Intensity: With some source material, and especially color source material, there can be a washing out at high strengths. This option sets the maximum intensity that can generated and scales the output values appropriately. The strength should be set as desired and then the intensity can be limited if needed to avoid washing-out.

Enable weak antibanding: Randomly varies the luminance of output pixels by a small amount to avoid banding of the histogram.

Enable strong antibanding: Randomly varies the luminance of output pixels by a large amount to avoid banding of the histogram.

This filter displays the input and output histograms using its own code, and not VirtualDub's. By placing the VirtualDub internal levels filter after this filter, and then selecting Preview followed by Sample frame, VirtualDub's idea of the output histogram can be inspected. Unfortunately, the levels filter histogram display in versions of VirtualDub prior to 1.4.5 are bug-ridden. The histograms shown here were obtained from this filter's displays. The levels filter's histogram display operates correctly in VirtualDub version 1.4.5.

Version 1.1 [Source code]

This is the first release version. This version is recompiled as a multithreaded DLL to reduce its size by half, a problem with painting the histograms is fixed (when loading a new file after the histograms have been displayed, subsequent display of the histograms wrote all over the dialog box in some cases), and the help file is revised to add a general statement about equalizing color images.

Version 1.1 beta 3 fixed two bugs: 1) The zero luma bin of the output histogram was not accumulated. 2) If you selected preview but did not sample, and then you moved a slider, the histogram boxes disappeared.

Version 1.1 beta 2 corrected a bug: when a different frame was previewed and the Sample button clicked, the input histogram was not updated.

Version 1.1 Beta 1 added integrated histogram displays.

Version 1.0 beta 5 used a more accurate luminance calculation and provided antibanding capability.

Version 1.0 beta 4 was the first available version.

[up to home page]