0
$\begingroup$

I have the following challenge. I am given a black and white image with rasterized lines. enter image description here

Given this input, I want to extend the edges to cover more than one pixel and antialias the edges.

My first attempt was to pass a morphological dilation followed by a gaussian filter. But that straight up did not work, all i got is for the image to look blurry.

I instead tried combining both effects into a single shader and go the following:

enter image description here enter image description here

This is decent, but you can still see a lot of the original aliasing of the edges.

Assuming that I only have the input image, are there any image based / screen space based AA techniques I can use to make the edges look smooth?

$\endgroup$
9
  • $\begingroup$ That isn't aliasing. It's distortion caused by your filtering techniques. $\endgroup$ Dec 21, 2020 at 2:17
  • $\begingroup$ It's 100% the aliasing from the original image. The original image is a rasterized line, when the pixels get dilated the pixelation from the original rasterization is dilated, as is. That's what's causing the jaggies in the lines. $\endgroup$
    – Makogan
    Dec 21, 2020 at 2:35
  • $\begingroup$ Yes, the original image has aliasing in it, but once you do your amplification, it stops being aliasing (which is a very specific signal processing term referring to a particular artifact that is the result of analog-to-digital conversions below a certain resolution) and is just data. As such, a technique designed specifically to combat aliasing specifically cannot fix a thing that is itself not aliasing. $\endgroup$ Dec 21, 2020 at 2:39
  • 2
    $\begingroup$ @NicolBolas It does no one any good to be this pedantic. Techniques that try to repair jaggies in the image after the fact are widely referred to as antialiasing in the industry and literature. $\endgroup$ Dec 21, 2020 at 5:40
  • 1
    $\begingroup$ @NicolBolas Aliasing is simply the higher frequency components of the copies in the Fourier domain leaking into the lower frequencies of the copy which we filter out through the reconstruction function. Note that the reconstruction function is included in there. Makogan's reconstruction is a box filter composed with a dilation operation. You're in the exact same setting as the original definition: you have point samples and a reconstruction function. It is aliasing with a different function than the one you are used to, but it is aliasing. $\endgroup$
    – lightxbulb
    Dec 22, 2020 at 12:53

1 Answer 1

2
$\begingroup$

The easiest way to deal with this would be to provide thickness for the edges in the continuous setting. That is, make your edges out of solid capsules/cylinders, then you would not have this issue. Technically, this is is neither a supersampling nor a filtering technique, but rather a reformulation of the problem in the continuous setting. Another equivalent reformulation is considering only the vertices and then your reconstruction function being thick edges between those (using a thick line algorithm).

This doesn't seem to be your setting however? Since you mentioned that you only have the raster (aliased) image already, in which case you have already introduced the error so it is hard to get rid off. If you can "access" the continuous model it is a lot easier to fix. If you cannot, then I could recommend using a different reconstruction filter than the dilation that you are using. For instance you can do a thickening based on distance to pixels (sdf) with a step function. This should remove the issues you are having, at least for the example you showed.

$\endgroup$
2
  • $\begingroup$ Ineed the algorithm is being designed around the presuposition that the inputs are images, not polygons, so i won;t have access to the original information of the lines. $\endgroup$
    – Makogan
    Dec 22, 2020 at 16:53
  • 1
    $\begingroup$ @Makogan The sdf (in screen space) ought to work then. $\endgroup$
    – lightxbulb
    Dec 23, 2020 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.