# Anti-aliased pixel and intensity slope detector/Susiliejanciu ir ryskumo slaito tasku nustatymas.

Image anti-aliasing technique

Image anti-aliasing filter use convolution as the most of image-processing methods use. The simplest convolution kernel

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII] (1)

The C code implementation of this convolution algorithm is very simple and shows how it works.
```int smooth_mpixel(int x,  int y)
{
int sum;

sum = get_mpixel(source, x, y);
if  (sum == 255)
{
// pixel is transparent, do not filter
return sum;
}
else
{
sum += get_mpixel(source,x - 1,y);
sum += get_mpixel(source,x + 1,y);
sum += get_mpixel(source,x,        y - 1);
sum += get_mpixel( source,x,        y + 1);
return sum / 5;
}
}

void simple_smooth(int width,  int height)
{
int x, y;

for(y=1; y<height-1; y++)
{
for(x=1; x<width-1; x++)
{
set_mpixel(target,x,y,smooth_mpixel(x,y));
}
}
}
```

[FIGURE 1 OMITTED]

[FIGURE 2 OMITTED]

Each anti-aliased image (Fig. 2) pixel is calculated as mean of five pixels (Fig. 1). This routine has an asymmetry, which can be both an advantage and a disadvantage: diagonal edges are blurred more than horizontal or vertical edges. To show why, the filter matrix was put in the following figure (Fig. 1) on a horizontal edge, a vertical edge and an edge at 45 degrees. Assume that in this figure, a white pixel has value one (1.0) and a gray pixel has value zero (0.0). Anti-aliasing filter blur an image and it looks slightly like an image from a digital camera. However, in real camera anti-aliased pixel is only one pixel that is between light and dark area. When there is more than one pixel, they represent a ramp of image intensity. In this situation, there are two anti-aliased pixels, one on the top of ramp and other on the bottom of the ramp.

Anti-aliased and intensity slope pixel detection

Most of mathematic methods are reciprocal, and anti- aliased pixel can be detected with inverting previous method. Coefficients for surround pixel values are calculated from image A pixels as matrix:

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII] (2)

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII] (3)

After number of tests it was found, that anti-aliased and slope pixels has some positive and negative and no coefficients with zero value. Zero values means that pixel is on the top or the bottom of intensity hop or on the straight line.

[FIGURE 3 OMITTED]

Very simple situation (Fig. 3) shows how slope and anti-aliased pixel detector works. When pixel lies on slope or is anti-aliased, surround coefficients have positive and negative values and when line intensity unvarying no more than two zero values which direction is the same as line.

[FIGURE 4 OMITTED]

The same algorithm can be applied for curves (Fig. 4) with the same results. Curve shape lines sometimes have more than one direction. Therefore, algorithm will be supplemented with direction evaluation function.

[FIGURE 5 OMITTED]

[FIGURE 6 OMITTED]

Real pictures (Fig. 5) have flashes, shadows, noise and digitization artifacts, which disturb simple algorithm and it must be enhanced. Image (Fig. 6) shows anti-aliased (black) ant slope (gray) pixels to show how this algorithm works. The main feature, that matrix coefficients must have with different signs have been supplemented with direction evaluation. Image and digitization noise can be recognized as anti-aliased or slope pixel. Some kind of noise as "salt and pepper" noise commonly is only one pixel noise, and this algorithm is insensitive for that kind of noise, because all surrounded pixels intensity are lower for "salt" pixels or higher for "pepper" pixels, than difference of pixel intensity always have the same sign.

[FIGURE 7 OMITTED]

For each pixel is checking surrounded pixels difference with center pixel if it has positive and negative values and no more than two zero values. Therefore, this pixel is at least slope pixel. Then check if the pixel is anti- aliased. Previously, pixel numbers were obtained with maximal and minimal values. Later try these pixels as center and check if these pixels are on top or bottom of brightness landscape. A top or bottom pixel has more than two zero values in difference matrix.

Testing and results

Other method to detect anti-aliased and slope pixels was not found, therefore this method cannot be compared with another method. Therefore, there was only optical method to check how it works.

For artificial images, created with drawing tools, this method works excellent. However, with real pictures, taken with photo camera or unknown source, accuracy is about 65-95 percent. One problem that decreases accuracy is noise that come from image sensor. Image with good lightning draw better results when pour lighted images have more random noise and shows worse results. The other source of errors is image compression artifacts that are visible as intensity waves near edges--these artificial waves are recognized by detector.

After number of tests it was defined, that pixel that was unrecognized as anti-aliased was impacted with noise, accordingly method, as it is designed work perfect.

Conclusion

After revising, a lot of literature another method to detect anti-aliased pixel was not found. There are many methods to make anti-aliased image from aliased. In many application anti-aliased image is exactly what expected, and feature for anti-aliased pixel detection is unnecessary.

Anti-aliased and slope pixel detector works perfect as it was designed, but for better results for image magnification purposes it must be improved. Small kernel 3x3 guarantee high processing speed, but cannot detect continuous lines in noisy images.

References

[1.] Vysniauskas Vytautas. Subpixel Edge Reconstruction using Aliased Pixel Brightness // Electronics and Electrical Engineering.--Kaunas: Technologija, 2008.--No. 8(88).--P. 43-46.

[2.] Vysniauskas Vytautas. Triangle Based Image Magnification.--Electronics and Electrical Engineering.--Kaunas: Technologija, 2006.--No. 6(70).--P. 45-48.

[3.] Nixon M S., Aguado A. S. Feature Extraction and Image Processing.--Newnes.--2002.--P. 40-45.

[4.] Lagendijk R. L., Biemond J. Basic Methods for Image Restoration and Identification. Handbook of Image And Video Processing.--Academic Press.--2000.--P. 125-140.

[5.] Muresan D. D., Parks T. W. Demosaicing using Optimal Recovery Image Processing // IEEE Transactions.--2005. - Vol. 14.-P. 267-278.ioio

V. Vysniauskas

Siauliai University,

Vilniaus str. 141, LT- 76353 Siauliai, Lithuania
COPYRIGHT 2009 Kaunas University of Technology, Faculty of Telecommunications and Electronics
No portion of this article can be reproduced without the express written permission from the copyright holder.