我正在尝试通过对最近像素求和来缩小图像来实现自定义消除锯齿程序。
我尝试求和并且意味着最多3个像素宽,但结果并不好,它与以前一样多的防褪色(编辑我的意思是别名)。< / p>
这是我使用的代码:
h is height
w is width
buf is a buffer containing the values.
out is the output buffer
for (int x = 0; x < w; x++)
for (int y = 0; y < h; y++)
{
int n = 3;
int x1 = x - n;
int x2 = x + n;
if (x1 < 0) x1 = 0;
if (x2 > w -1) x2 = w - 1;
int y1 = y - n;
int y2 = y + n;
if (y1 < 0) y1 = 0;
if (y2 > h - 1) y2 = h - 1;
double sum = 0;
for (int i = x1; i <= x2; i++)
for (int j = y1; j <= y2; j++)
sum += buf[i][j];
sum = sum / double((x2 - x1 +1) * (y2 - y1 +1));
out[x][y] = sum;
}
我可以用什么快速例程来做一个简单的基本抗锯齿?