Antialiasing algorithm?

柔情痞子 提交于 2019-12-23 09:39:24

问题


I have textures that i'm creating and would like to antialias them. I have access to each pixel's color, given this how could I antialias the entire texture?

Thanks


回答1:


The basic method for anti-aliasing is: for a pixel P, sample the pixels around it. P's new color is the average of its original color with those of the samples.

You might sample more or less pixels, change the size of the area around the pixel to sample, or randomly choose which pixels to sample.

As others have said, though: anti-aliasing isn't really something that's done to an image that's already a bitmap of pixels. It's a technique that's implemented in the 2D/3D rendering engine.




回答2:


I'm sorry but true anti-aliasing does not consist in getting the average color from the neighbours as commented above. This will undoubtfully soften the edges but it's not anti-aliasing but blurring. True anti-aliasing just cannot be done properly on a bitmap, since it has to be calculated at drawing time to tell which pixels and/or edges must be "softened" and which ones must not. For instance: imagine you draw an horizontal line which must be exactly 1 pixel thick (say "high") and must be placed exactly on an integer screen row coordinate. Obviously, you'll want it unsoftened, and proper anti-aliasing algorithm will do it, drawing your line as a perfect row of solid pixels surrounded by perfect background-coloured pixels, with no tone blending at all. But if you take this same line once it's been drawn (i.e. bitmap) and apply the average method, you'll get blurring above and below the line, resulting a 3 pixels thick horizontal line, which is not the goal. Of course, everything could be achieved through the right coding but from a very different and much more complex approach.




回答3:


"Anti-aliasing" can refer to a broad range of different techniques. None of those would typically be something that you would do in advance to a texture.

Maybe you mean mip-mapping? http://en.wikipedia.org/wiki/Mipmap




回答4:


It's not very meaningful to ask about antialiasing in terms this vague. It all depends on the nature of the textures and how they will be used.

Generally though, if you don't have control over the display environment and your textures might be scaled, rotated, or composited with other elements you don't have any control over, you should use transparency to indicate where your image ends and where it only partially fills a pixel.

It's also generally good to avoid sharp edges and features that are small relative to the amount of scaling that might be done.



来源:https://stackoverflow.com/questions/3011274/antialiasing-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!