5
$\begingroup$

I need to solve the following problem: do some anti-aliasing onto an image that contains rasterized "lines".

I have some post-processing effects that output super-thin (~1px) features such as silhouette-edges and outlines as shown here:

enter image description here

I tried with an FXAA shader I found online, which works fine if the line is at least 2px wide, doesn't work with 1px lines. I guess the edge detection method completely breaks with such thin features (also the common optimization to sample at the boundary of the edge won't work with lines).

How should I address this issue?

Is there a technique out there specifically designed to solve this problem?

$\endgroup$

1 Answer 1

3
$\begingroup$

A gaussian blur with a small kernel size, like 3, would blur the line into adjacent pixels and may be all that is needed.

There is a technique called jump flooding that will turn an image like this, even with very thin lines into a signed distance field. The signed distance field can then be used to recreate the lines at any thickness, with anti-aliasing. There was a paper written "Jump Flooding in GPU with Applications to Voronoi Diagram and Distance Transform" and there is an interesting blog post at https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9. The blog post is about generating wide outlines but it applies to thin lines and anti-aliasing lines as well.

One interesting thing about jump flooding is it allows for fractional pixel widths like 1.5px wide lines.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.