Gradation Curves Plugin for VirtualDub
(Version 1.45)
by Alexander Nagiller
What the filter can do / what the filter can be used
for:
If dark areas of a video are too dark, the filter can be used
to brighten them up, without changing light and mid tones. The
filter can invert the color space like the internal invert filter
and can apply coring, like the coring filter plugin that exists
for VirtualDub. If the tone of a video is, for example too blue,
the filter can be used to compensate this. The overall brightness
can be changed also. Perhaps the filter can also be used for some
scientific use, if there is a need to mask a certain color. And
the good thing is that it can all be done at the same time with
one filter instance only. The filter also gives the possibility
to apply curves in other color spaces. Using the HSV space,
individual colors can be exchanged by other ones or/and the
saturation can be changed for example. But note that one filter
instance can always only process one color space. If a
manipulation in RGB and HSV space is needed, the filter has to be
put into the filter chain two times: once for RGB processing and
once for HSV processing. Other possible applications of the
filter include:
• Use of the filter as prefilter of the deshaker filter for
difficult (dark) DV Cam captures in the first pass of deshaker.
Some colors can be masked, so the motion analysis works better in
the first pass of deshaker.
• Use of the filter in the area of "film look for DV
material". See posts in the doom9 forum or the VirtualDub
forum.
The x axis of the curve represents the input color value, the
y axis represents the output color value. Initially the filter
will show a 45° left down to right up curve. This signifies
that the output color will be the same as the input color for all
color values. Raising the output value, results in a lightning up
of the selected input color value. The filter always stores the
settings of five gradation curves, even if only the RGB curve is
used. This way the settings of the R/G/B curves are not lost if,
for example temporarily RGB only mode is used and the processing
settings are saved at that time. The fifth curve is only used for
the K channel of the CMYK color space.
Info about gradation curves: Curve (tonality) - Wikipedia
The filter window on the left side is link senitve. You can
either click on the areas of the filter windows or select a topic
below:
Color Space
Channel
Filter Curve Editor
Smooth
Processing Mode
Reset
Invert
Import
Export
Space:
Selects the color space. If another than RGB color space is
selected, two color space conversions are necessary: From RGB to
the target color space. Then the curve is applied in the target
color space and finally there is a color space transformation
back to RGB. The color space conversions will slow down the
filtering.
Note that not all the color space conversions are lossless.
Conversions to HSV, YUV or Lab and back are not lossless. For YUV
the average error is about 0,98. For a color sample e.g. R:23
G:43 B:12 transformed to YUV and back resulting in a sample of
R:23 G:42 B:12 the error is 1 because the value of green differs
in one (43 vs. 42). The average error is calculated by processing
all the ~16 million colors (24 Bit). The average error of the HSV
conversion is about 0,87 and for Lab 1,51.
A note to the YUV conversion: The YUV space in this case uses
4:4:4. That means Y, Cr and Cb all use the full resolution.
A note to the Lab color space: The filter uses two big lookup
tables that contain the conversion values of all the 16 Million
colors. When the Lab space is selected for the first time, the
tables are built up and 128 MByte of memory will be used to do
the conversion from RGB to Lab and back. The memory will be freed
only when either the filter is removed from the filter chain or
VirtualDub is closed. Also note that when Lab is selected for the
first time, the filter dialogue will stall for a moment until the
tables are built up. The time it takes, depends on the speed of
the PC.
The RGB/Lab conversion uses D65 as reference white and sRGB as
RGB model.
General info about color spaces: Color
space - Wikipedia
Top
Channel:
Selects the color channel. RGB shows the curve for the channel
that edits all the colors at the same time while Red / Green /
Blue shows the curve for each color channel.
Note that for other color spaces, a joint channel curve (RGB
curve) does not make sense and is for that reason not available
in other color spaces.
Top
Filter Curve
Editor:
Different drawing modes allow different ways to design the filter
curve. The drawing mode can be selected on the right side.
selects the Pen(cil) or Freehand mode.
By pressing the left mouse button and drawing over the filter
window, the curve can be edited. Pressing the right mouse button
sets the input value to the current position of the cursor,
displaying the corresponding output value below the curve.
The output
buttons below the curve window can be used to fine tune the
output value for a selected input value. The output value shows
the transformation that is applied for the corresponding input
value. With the input buttons the input value position can be selected. If
the input value equals the output value, no processing is applied
for the selected input value.
The other three modes use coordinates/points to design the
filter curve:
selects
the line mode.
Straight lines will be drawn between the points. This can be
useful eg. for drawing a stair type curve.
selects the spline mode.
A spline interpolation will be applied for the given coordinates.
This is the default mode.
selects the gamma mode.
This mode can be used to apply a gamma correction. The gamma
value is displayed below the curve.
Points can be set with the left mouse button and deleted with
the right mouse button except in gamma mode that has got a fixed
number of three points. When holding the left mouse button
pressed on a point and moving the mouse, the point can be moved.
Releasing the left mouse button sets the point on the current
position.
The first and last point are two special points. They cannot be
deleted nor can a point be set before the first or after the last
point.
With the Point
buttons a point can be selected for fine tuning. The selected
point is outlined in red. The input and output buttons can move a point
in the x (input) and y (output) axis. Currently the number of
points is limited to 16.
Switching from any coordinates drawing mode to pen mode keeps the
raw curve but the coordinates are lost. Switching from pen mode
to any coordinates drawing mode will reset the curve to a
straight line with two coordinates (0/0) (255/255) respectively
three coordinates for the gamma mode. Switching to gamma mode
will reset the curve to a straight curve with three coordinates,
except the case when the curve already contains exactly three
coordinates.
Editing the curve with preview open and some (slow) filters
active in the filter chain is not recommended because
responsiveness is lost. Either edit the curve with preview closed
in such a case or edit the curve with preview active only with
this filter active.
Top
Smooth:
Smoothes the filer curve. The smoothing algorithm is not perfect,
but it helps to remove some jagginess of the curve. It is only
available in pen drawing mode.
Top
Processing
mode:
"RGB only" will only process the image by the common RGB channel.
Any edited color channel will be ignored. "RGB + R/G/B" processes
the individual color settings first and then applies the RGB
settings. These two modes behave similar to the curves function
of painting programs.
The weighted modes are just like the first two modes differing
only in way RGB is processed. First a Y (gray) value of each
pixel is calculated. Then the output value of the RGB curve of
this Y (RGB input) value is taken and applied to all three colors
of the pixel the same way. An example to demonstrate the
difference of the two modes: Let's assume that the output setting
for the input value of 30 in the RGB curve is 50. In the mode
"RGB only" all pixels that have got a R or G or B value of 30
will be changed to 50, while the other colors of the pixel stay
the same (if they are not 30 as well). A pixel with the color R30
G10 B15 will be changed to R50 G10 B15 (if the values for 10 and
15 are unchanged in the curve). While in the weighted mode a
pixel that has got a Y value of 30 ex. R10 G38 B50 will be
changed to R30 G58 B70. 50-30 = 20 and 20 is summed up to the
individual R G B values.
The mode "no processing" applies no change and can be used to
spot the difference between the activated filter and no
processing in the preview window.
Other color spaces than RGB only offer the individual channel
processing (e.g. Y/U/V) and the no processing option.
Top
Reset:
Changes back the currently selected curve to the initial
settings, where no processing is applied at all.
Top
Invert:
Inverts the currently selected curve. Inverting an unmodified
(45°) RGB curve results in the same effect as applying the
internal invert filter.
Top
Import:
Imports external gradation curves. In the dialog box the file
containing the curves can be selected and imported.
The standard file type is .amp which is used by Adobe Photoshop.
But in general any file containing a curve that is structured
like .amp files can be imported into the filter. If the import
function detects one curve in the file, the data is loaded into
the RGB curve. If there are three curves in the import file, they
get loaded into the R / G / B curves or the other individual
curves of the other color spaces (e.g. Y / U / V). With four or
more curves within the import file, the first curve gets loaded
into the RGB curve then followed by R / G / B. If the file
contains more than five curves all curves above the fifth are
ignored. The fifth curve is only used for the K channel of the
CMYK space. Importing an .amp file sets the drawing mode to pen
mode. Map files (.amp) can be saved using the curves function of
Adobe Photoshop by selecting pen mode.
Another file type is .acv also used by Adobe Photoshop. Only the
coordinates are stored in this format. Importing an .acv file
sets the drawing mode of all curves to spline mode.
Other import formats are: Comma Separated Values (*.csv) - see
under export, Tone Curve File (*.crv), Tone Map File (*.map) and
Smartcurve HSV (*.amp).
The crv and map formats are used by Corel Draw. These formats
contain the drawing mode, the coordinates and the raw curve data
of each curve.
The SmartCurve HSV import allows a correct import of *.amp HSV
color space files generated by the Photoshop Smartcurve plugin.
The plugin stores the curve data similar to the Photoshop *.amp
files, but uses a different order for the curves.
Top
Export:
The default format exports a file with the structure of a map
file. The export function always stores five gradation curves.
The exported file can be loaded within the curves function of
Adobe Photoshop. The file structure is very similar to the way
the filter data gets stored in the processing files of
VirtualDub. The data in the processing file is stored with hex
values FF=255 straight forward. The input value 0 of the RGB
curve is in first position, were as only the output value is
stored. So it goes from the first output value to the last (255)
and then followed by the data of the R / G / B curves. For other
color spaces than RGB the first curve is stored as an empty curve
(0-255 or 45° filter curve), then followed by the curves of
the individual channels (e.g. Y / U / V). The channels are stored
in the order of their appearance (e.g. HSV 1:empty 2:H 3:S 4:V
5:empty). If you look at a map file with a hex editor you will
see the same thing as in the .vcf processing file of VirtualDub.
Exporting curves that use the coordinates drawing modes will
store only the raw curve data but not the coordinates.
The second export format is .acv that only stores the
coordinates. The drawing mode is not stored. If pen mode for a
curve is active, the raw data will not get stored, but two
coordinates (0/0) (255/255). That results in a straight line when
importing the curves later.
As a third export format Comma Separated Values (*.csv) can be
selected. Each line in the file contains one decimal value of the
curves. In 1280 lines the data of the five curves is stored. The
file can e.g. be imported in Excel or opened and edited in
Notepad. This format currently only stores the raw curve data and
does not store the coordinates if a non pen mode is selected.
Alternatively all the filter data (drawing modes / coordinates
/ raw curve data / space & processing mode) can be stored in
a .vcf VirtualDub processing file.
Top
Copyright © 2003-2008, Alexander Nagiller, All Rights Reserved. |
|
|