A number of low level ChartDirector graphics primitives using the
DrawArea
object involve moving some or all pixels by a fractional offset. For example,
rotating an image by 45 degress (using
DrawArea.rotate) will cause some
pixels to rotate to non-integer coordinates.
Consider the simpliest operation - shifting the image leftwards using
DrawArea.move. If the image is shifted by an integer number of pixels,
it is easy to determine the new image.
How about if the image is shifted by a non-integer number of pixels, such as 1.5
pixels? In this case, the pixel (10, 10) in the new image corresponds to pixel
(8.5, 10) in the original image.
In graphics theory, the proper way to estimate non-integer-coordinate pixel is
by re-sampling. In simple terms, the non-integer-coordinate pixel is computed
using "two dimensional interpolation" from nearby integer-coordinate pixels.
The interpolation method is called a "filter".
ChartDirector supports a number of filters denoted by the following pre-defined constants:
Constant | Value | Description |
BoxFilter | 0 | Box filter. This is equivalent to setting the color of a non-integer-coordinate pixel to the nearest integer-coordinate pixel.
|
LinearFilter | 1 | Linear filter. This is equivalent to setting the color of a non-integer-coordinate pixel as the linear weighted average of nearby integer-coordinate pixels.
|
QuadraticFilter | 2 | Quadratic Filter.
|
BSplineFilter | 3 | B-spline Filter.
|
HermiteFilter | 4 | Hermite Filter.
|
CatromFilter | 5 | Catrom Filter.
|
MitchellFilter | 6 | Mitchell Filter.
|
SincFilter | 7 | Sinc Filter.
|
LanczosFilter | 8 | Lanczos Filter.
|
GaussianFilter | 9 | Gaussian Filter.
|
HanningFilter | 10 | Hanning Filter.
|
HammingFilter | 11 | Hamming Filter.
|
BlackmanFilter | 12 | Blackman Filter.
|
BesselFilter | 13 | Bessel Filter.
|
Filtering computes a pixel as the weighted average of nearby pixels. What is
meant by "nearby"?
In a linear filter, "nearby" means both the horizontal and vertical distances are
less than 1 pixel length from the target pixel. This defines the filtering region
of the linear filter. Each pixel can have up to 4 integer-coordinate neighbours.
So in a linear filter, each pixel is computed by interpolating from up to 4
neighbouring pixels.
The filtering region of different filters are different. For example, the B-spline
filter has a filtering region dimension of 2 pixel distance. Each pixel is computed
by interpolating from up to 16 nearby pixels. This is because B-spline, being a
cubic polynomial algorithm, requires more points for interpolation.
The filtering region will automatically be extended if the graphics operation
involves reducing the image size. It is because the each pixel in the reduced
image should corresponding to a larger area in the original image. For example,
if an image is resized to 30% of the original in width and height, the filtering
region dimension will be increased by a factor of 1 / 0.3 = 3.333.
All ChartDirector API that supports re-sampling also supports an additional blur
factor parameter. This parameter can be used to extend or reduce the filtering
region. For example, a blur factor of 2.5 will increase the filtering region
dimension to 250% of the original.
The effect of increasing the blur factor is to blur the image, making it smoother
but less sharp. Reducing the blur factor makes the image shaper but less smooth.
© 2004 Advanced Software Engineering Limited. All rights reserved.