过滤器以反转抗锯齿效果
我有线条和文本的位图,它们应用了抗锯齿功能。我想开发一个过滤器来消除抗锯齿影响。我正在寻找有关如何做到这一点的想法,因此首先我需要了解抗锯齿算法的工作原理。有没有好的链接,甚至代码?
I have bitmaps of lines and text that have anti-alias applied to them. I want to develop a filter that removes tha anti-alias affect. I'm looking for ideas on how to go about doing that, so to start I need to understand how anti-alias algorithms work. Are there any good links, or even code out there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抗锯齿的工作原理是在将图像下采样到输出分辨率之前以更高分辨率渲染图像。在下采样过程中,对较高分辨率的像素进行平均以创建较低分辨率的像素。这将在渲染图像中产生更平滑的颜色变化。
考虑这个非常简单的示例,其中块轮廓呈现在白色背景上。
然后在创建具有灰色阴影的像素的过程中将分辨率下采样到一半:
这是用于渲染字母 S 的抗锯齿的更真实演示:
Anti-aliasing works by rendering the image at a higher resolution before it is down-sampled to the output resolution. In the down-sampling process the higher resolution pixels are averaged to create lower resolution pixels. This will create smoother color changes in the rendered image.
Consider this very simple example where a block outline is rendered on a white background.
It is then down-sampled to half the resolution in the process creating pixels having shades of gray:
Here is a more realistic demonstration of anti-aliasing used to render the letter S:
我对 C# 编程一点也不熟悉,但我有图形方面的经验。最接近抗锯齿滤镜的是锐化滤镜(至少在实践中,使用 Photoshop),通常根据所需效果多次应用。当抗锯齿元素和背景之间已经存在很大对比度时,锐化滤镜效果最佳,如果背景是一种纯色而不是复杂的图形,效果会更好。
如果您可以使用任何高级图形编辑器,则可以尝试一些测试,如果您对结果感到满意,则可以开始研究锐化过滤器。
另外,如果您使用灰度位图,更好的解决方案是将其转换为黑白图像 - 这将消除其上的任何抗锯齿效果。
希望这至少有一点帮助:)
I am not familiar at all with C# programming, but I do have experience with graphics. The closest thing to an anti-anti-alias filter would be a sharpening filter (at least in practice, using Photoshop), usually applied multiple times, depending on the desired effect. The sharpening filter work best when there is great contrast already between the anti-aliased elements and the background, and even better if the background is one flat color, rather than a complex graphic.
If you have access to any advanced graphics editor, you could try a few tests, and if you're happy with the results you could start looking into sharpening filters.
Also, if you are working with grayscale bitmaps, an even better solution is to convert it to a B/W image - that will remove any anti-aliasing on it.
Hope this helps at least a bit :)