[0001] The present invention relates generally to the display of raster images, and more
specifically to an anti-aliasing algorithm for use with such displays.
[0002] Computer text and graphics are typically displayed using a raster image. The raster
image is a rectangular array of rectangular picture elements known as pixels. Raster
images can be displayed on CRT monitors in monochrome or various colors. Raster images
are also used to display text and graphics on printers, plotters, and other display
devices.
[0003] One problem encountered when displaying a raster image is that of aliasing. Aliasing
is the jagged, stair-step appearance when lines and edges are displayed which are
neither vertical nor horizontal. This problem is more noticeable when a small number
of large pixels are used for a given area. Increasing the resolution of the display
device, thereby increasing the number of pixels per unit area, improves the appearance
of the raster image.
[0004] One of the more successful anti-aliasing algorithms involves edge blur. Along the
edge of the diagonal or curved line, where stair-steps occur, there is ordinarily
a sharp transition between the pixels that are drawn in the different colors of the
two regions. The staircase appearance occurs because pixels of one color lay immediately
adjacent to those of another color, making the jagged transition between them noticeable.
[0005] With an edge blur algorithm, however, it is possible to average the color values
of the two regions along the edge and then display missing pixels in the staircase
using this in-between color. The result is a blurring or softening of the edge, smoothing
over the transition between the colors of the different regions. One disadvantage
of this approach is that the display device must be able to display colors which are
intermediate between the colors of the two different regions.
[0006] It is sometimes desirable to enlarge a raster image to create a large graphic printout
or display. The larger display or printout usually has more pixels for displaying
the image than the original image. A simple method to enlarge the original raster
image is to simply enlarge the original pixels, mapping them to the pixels of the
enlarged image. If, for example, the zoom factor is 8, each pixel of the original
image becomes an 8x8 square of pixels in the resulting image. If the pixels are simply
enlarged in this manner, each of the 64 pixels in a square corresponding to an original
pixel is simply given the same color value as the original pixel. This gives the same
appearance as simply using very large pixels in the resulting image, and the stair-step
phenomena is generally more noticeable than in the original image. Use of intermediate
colors for these large pixels does not completely solve the problem.
[0007] It would be desirable to provide a method for anti-aliasing which is suitable for
use when a raster image is enlarged, or otherwise translated to a resulting image
having more pixels than the original. It would also be desirable to provide such a
method which uses only the original image colors in order to retain sharpness of the
image. It would further be desirable for such a method to be relatively simple to
implement and fast in operation.
[0008] It is therefore an object of the present invention to provide an anti-aliasing method
suitable for use when an original raster image is translated to a resulting image
containing more pixels than the original, such as an enlarged image.
[0009] It is another object of the present invention to provide such a method which utilizes
only the colors present in the original image, without requiring the generation of
intermediate colors.
[0010] It is another object of the present invention to provide such a method which is easily
implemented and fast in operation.
[0011] Therefore, according to the present invention, a method for determining the values
of pixels in a resulting image having a greater number of pixels than an original
image describes a technique for calculating the values of the new pixels in the resulting
image. A rectangular region centered on a junction of four pixels in the original
image is used as the basis for calculation. This rectangular region contains one-fourth
of the adjacent original pixels, and is divided into 8 triangular regions. All of
the pixels of the resulting image within a triangular region are given the same color,
and the color assigned to the pixels in each such triangular region is a function
of the colors of the four adjacent pixels in the original image.
[0012] The novel features believed characteristic of the invention are set forth in the
appended claims. The invention itself however, as well as a preferred mode of use,
further objects and advantages thereof, will best be understood by reference to the
following detailed description of an illustrative embodiment when read in conjunction
with the accompanying drawings, wherein:
Figure 1 illustrates a small portion of a raster image;
Figure 2 is a diagram illustrating the location of a rectangular region used in the
calculation of pixel colors for a resulting raster image;
Figure 3 illustrates the rectangular region of Figure 2 divided into 8 triangular
regions;
Figure 4 is a flowchart illustrating the steps of a preferred implementation of the
present invention; and
Figure 5 illustrates the results of applying the method of Figure 4 to a portion of
the raster image of Figure 1.
[0013] Figure 1 shows a portion of a raster image 10 formed from a plurality of pixels.
The pixels of Figure 1 are divided into four rows R1, R2, R3 and R4, and four columns
C1, C2, C3 and C4. Pixels can be referred to by their coordinates, so that pixel 12
is identified by the location (R2, C4) and pixel 14 is identified by the location
(R4, C2).
[0014] The pixels of Figure 1 are shown in two colors: shaded and not shaded. The invention
will be illustrated below in conjunction with pixels having only two colors, but,
as will be appreciated by those skilled in the art, also applies to multi-color images.
[0015] Figure 2 shows the four adjacent pixels in the upper left hand corner of Figure 1.
Shading of the pixels is omitted in Figure 2 for clarity. When raster image 10 is
to be enlarged, a method for calculating the pixel colors in the resulting image utilizes
rectangular region 16. Rectangular region 16 has the same shape as each of the pixels,
which is square as shown in Figures 1 and 2. Rectangular region 16 is centered on
the intersection point 18 of the four pixels. In Figure 2, the four pixels illustrated
are shown as being slightly spaced apart both for clarity and because adjacent pixels
are actually separated by a small space in some types of displays. Rectangular region
16 is considered to include the nearest one-fourth of each adjacent pixel.
[0016] Figure 3 illustrates logical regions 1-8 into which rectangular region 16 is divided.
Regions 1 and 5 correspond to the lower right hand corner of pixel (R1, C1) of Figure
2. Regions 2 and 6 correspond to the lower left hand corner of pixel (R1, C2). The
remaining regions likewise correspond to the remaining pixels adjacent to intersection
point 18. The numbered regions will be used in connection with the detailed description
of the preferred method for assigning pixel colors as described in connection with
Figure 4.
[0017] Figure 4 is a flowchart of the calculations necessary to assign colors to all of
the pixels within one rectangular region 16. In order to determine the colors of all
of the pixels in the resulting array, the calculation outlined in Figure 4 is performed
for a rectangular region 16 for the intersection point 18 between every set of four
adjacent pixels in the array. The calculation of Figure 4 is therefore performed a
number of times equal to (N-1)*(M-1) for an N X M array of pixels.
[0018] Referring to Figure 4 considered in conjunction with Figure 3, the first step 30
is to assign colors to the pixels located in regions 1, 2, 3, 4. The pixels in these
regions are assigned the same color as the color of the original pixel of which each
region is a part. Therefore, for example, considering rectangular region 16 of Figure
2, regions 1, 3, and 4 are assigned the shaded color, while region 2 is assigned the
unshaded color.
[0019] The next step is to perform the conjunctive logical comparisons of step 32. If the
color of region 1 is equal to the color of region 2, region 3, and region 4, the YES
branch is taken. When this condition occurs, all four of the original pixels have
the same color, and the entire area of rectangular region 16 is assigned this color.
Therefore, regions 5, 6, 7, and 8 are assigned the same color as region 1 is step
34.
[0020] If the NO branch is taken from step 32, the test shown in step 36 is performed. This
is a comparison to see whether the color of region 1 is the same as the color of 4,
and the color or region 2 is the same as that of region 3. If this is the case, the
four original pixels formed a checkerboard pattern using two colors, and no changes
will be made within the area encompassed by rectangular region 16. Thus, if the result
of test 36 is true, control skips ahead to step 38 which assigns interior triangular
regions 5, 6, 7, and 8 to have the same color as their adjacent exterior triangular
regions 1, 2, 3, 4. After step 38, processing is complete.
[0021] If the result of step 36 is NO, control passes to step 40. In step 40, the color
of region 1 is compared to the color of region 4. If they are the same color, control
passes to step 42. If this point is reached in the flowchart, it is known that the
upper left and lower right pixels have the same color, while the lower left and upper
right pixels are of differing colors. This means that a line is formed by the upper
left and lower right pixels, and all of the interior regions 5, 6, 7, 8 are given
the same color as region 1.
[0022] If the result of step 40 is NO, the test of step 42 is performed. This test is analogous
to that performed in step 40, except that a check is made to see whether the same
colors are found in regions 2 and 3. If so, control passes to step 46. If this point
in the flowchart is reached, it is known that regions 2 and 3 have the same color,
while regions 1 and 4 have dissimilar colors. Therefore, all of the interior triangular
regions 5, 6, 7, 8 are assigned the same color as region 2.
[0023] If the result of step 44 is NO, control passes to step 38. As described above, step
38 assigns each of the interior triangular regions the same color as their adjacent
exterior triangular region. If step 38 is reached, it is known that one of three situations
has occurred with respect to the four adjacent pixels. If control passes from step
44 to step 38, either each of the adjacent pixels is a different color from all of
the others, or any adjacent pixels of the same color are vertically or horizontally
adjacent. If control has reached step 38 from step 36, the two color checkerboard
pattern described above occurs. In either event, the four corners of the rectangular
region 16 are given the same value as the original pixels from which they are derived.
[0024] The precise conditions tested, and the order in which the tests are made, need not
be exactly as shown in Figure 4. Any set of tests which colors regions 1-8 in the
same manner as described above can be used. The general rule is to color all of the
interior triangles 5-8 the same color as two diagonally opposite exterior triangular
regions 1 and 4, or 2 and 3, unless the checkerboard pattern occurs.
[0025] Figure 5 illustrates the effect of the method of Figure 4 on a portion of the raster
image of Figure 1. The four original pixels (R2, C2), (R2, C3), (R3, C2), and (R3,
C3) are shown. In this example, the zoom, or magnification, factor is 8, meaning that
each original pixel is translated to an 8x8 region of pixels in the resulting image.
If the pixels of Figure 1 were translated unchanged into Figure 5, a large stair-step
would be evident. Applying the method of Figure 4 to the various intersection points
of Figure 1 gives the result of Figure 5, wherein the upper right hand corners of
the (R2, C2) and (R3, C3) regions are set to the non-shaded color, and the lower left
triangular region of (R2, C3) is shaded.
[0026] Since the edges of the triangles of Figure 3 pass through pixels of the zoomed image,
it is necessary to determine whether pixels lying on both sides of a diagonal line
are to be assigned the same color as the outside triangular region or interior triangular
region. In the example of Figure 5, the assumption is made that pixels lying along
a diagonal line of Figure 3 are assigned the same color as the outside triangular
region. This causes the slight bump in the line found in the (R2, C3) quadrant of
Figure 5.
[0027] It will be appreciated by those skilled in the art that the comparisons and assignments
shown in Figure 4 can be performed very quickly, even when the original raster image
has a large number of pixels. The quality of the zoomed, resulting image is improved
quite dramatically. No intermediate colors need to be generated, so that the sharpness
of the transitions between differently colored regions is maintained in the enlarged
image.
[0028] The method described above can be used when a raster image is converted to be shown
on a CRT display having a greater number of pixels than that of the original display.
It is also suitable for use when a raster image is to be greatly enlarged so that
it can be printed on a printer or plotter. This allows, for example, an image suitable
for viewing on a CRT display to be enlarged and printed on a large chart suitable
for showing to an auditorium.
[0029] The detailed embodiment described above can be generalized to include more than eight
triangular regions if desired. For example, if diagonal lines are drawn between the
corners of rectangular region 16 in Figure 3, 16 triangular regions would result.
These can be assigned colors as a function of the four adjacent pixels. It is also
possible to center such a 16-piece region on a pixel instead of an intersection, and
color the triangular regions as a function of the eight surrounding pixels. Dividing
the rectangular region 16 into a large number of triangular regions is not preferred
because it is computationally expensive. Also, the information content of the original
pixels is much lower than that of the resulting image, and performing complex interpolations
usually does not improve the resulting image to a degree which justifies the extra
computation. It is usually more fruitful to simply recreate the original image at
a higher resolution if possible.
[0030] While the invention has been particularly shown and described with reference to a
preferred embodiment, it will be understood by those skilled in the art that various
changes in form and detail may be made therein without departing from the spirit and
scope of the invention.
1. A method for performing anti-aliasing when an original raster image is translated
to a resulting raster image having a greater number of pixels comprising the steps
of:
defining a rectangular region at each intersection of four pixels of the original
image, wherein the rectangular region is divided into eight equally sized triangular
regions, with four such triangular regions forming an inner rectangular region centered
within the defined rectangular region;
assigning each of four exterior triangular regions, not within the inner rectangular
region, a color the same as a corresponding adjacent pixel of the original image;
and,
if exactly one pair of diagonally opposite exterior triangular regions has the same
color then assigning all of the interior triangular regions such color, else assigning
each interior triangular region the same color as an adjacent exterior triangular
region.
2. The method of Claim 1, wherein each triangular region is mapped to selected pixels
of the resulting image.
3. The method of Claim 1 or 2, further comprising the step of:
displaying the resulting image on a display device.
4. The method of Claim 3, wherein the display device is a video monitor.
5. The method of Claim 3, wherein the display device is a printer.
6. A method for coloring pixels in a resulting raster image having more pixels than an
original raster image, comprising the steps of:
for each intersection of four adjacent pixels in the original image, defining a rectangular
region having eight equal sized triangular regions contained therein, wherein four
of the triangular regions form an inner rectangular region centered within the rectangular
region and the remaining triangular regions are exterior triangular regions each corresponding
to one of the adjacent pixels;
for each rectangular region, calling a procedure which assigns color values to each
triangular region; and
coloring the pixels in the resulting raster image according to the assignments made
by the called procedure.
7. The method of Claim 6, wherein the called procedure comprises the steps of:
assigning each exterior triangular region the color of its corresponding adjacent
pixel;
if all four exterior triangular regions have the same color, assigning all of the
inner triangular regions such color and exiting the procedure;
if exactly one pair of diagonally opposite exterior triangular regions has the same
color assigning all of the interior triangular regions such color, else assigning
each interior triangular region the same color as an adjacent exterior triangular
region.
8. A method for performing anti-aliasing when an original raster image is translated
to a resulting raster image having a greater number of pixels comprising the steps
of:
defining a rectangular region at each intersection of four pixels of the original
image, wherein the rectangular region is divided into a plurality of triangular regions,
a first set of such triangular regions being exterior triangular regions and having
at least one side lying along an exterior side of the rectangular region, and a second
set of such triangular regions being interior triangular regions and not having any
sides lying along an exterior side of the rectangular region; and
assigning colors to each of the triangular regions as a function of the colors of
the four original image pixels.
9. The method of Claim 8, wherein all of the triangular regions have the same size.
10. The method of Claim 8 or 9, wherein there are four interior regions forming an interior
rectangular region centered within the rectangular region, and four exterior triangular
regions.
11. The method of one of Claims 8 to 10, wherein said assigning step comprises the steps
of:
assigning each of the exterior triangular regions a color the same as a corresponding
adjacent pixel of the original image; and,
if exactly one pair of diagonally opposite exterior triangular regions has the same
color then assigning all of the interior triangular regions such color, else assigning
each interior triangular region the same color as an adjacent exterior triangular
region.