About three decades ago, pixels where as big as toasters – and mostly green.
Today we have millions of them to deal with, and the terms anti-/aliasing are part of our daily live and every time an image is scaled, it gets interpolated to keep those bad “stairs” away from our eyes.
But what if the source image is aliased in the first place?
Of course there are many ways to antialias cg images when generating them – for example by rendering to a higher resolution than targeted and downscaling the result (FSAA)- or by rendering and merging four slightly offset variations.
While this is as computational intensive as it sounds, modern GPU´s can handle this task rather easily as they have their buffers and hardwired magic to do so, but still it’s not uncommon to come along aliased images in the world of computer graphics.
So is all this material “useless” or can an image that has never seen any antialiasing, or has been upscaled with the nearest neighbour method, be reconstructed?
In fact all that modern imaging software does when rescaling an image is reconstructing its pixels to fit the new dimensions – most times with a bicubic filter.
SmartAA is a bicubic BC-spline reconstruction filter for PixelBender.
Its 3×3 kernel gathers all neighboring pixels of the one to reconstruct and weights them with the Mitchell-Netravali(german link) filter.
In essence, this means that each pixel is modified by the average color of its surrounding friends.
While “average” being the wrong term here as the influence of each pixel is determined by the spline curve of the Mitchell-Netravali filter.
This eliminates those hard, “stair-like” artifacts of the aliasing by visually “softening” or unsharping the image.
However this is not simply a destructive blurring effect but a reconstructive analysis of the source “signal”.
There are many known filters that do this hard job – it´s not easy to reconstruct information that was partly lost (or never there in the first place).
Thus all of them suffer of the same issues – the result always shows some artifacts.
Mostly it’s a visible unsharping, anisotropy or the so-called “ringing“.
In general bicubic reconstruction methods create the best results.
Among the various possible filter methods the windowed Sinc(Lanczos)- and Mitchell-Netravali filter are chosen the most as their output is considered to be the best mix of the inevitable unsharping, anisotropy and ringing.
Just for the record: there are “better” solutions, the so called “adaptive” or “smart” filters that try separate methods on edges, fills and other structures.
They are particularly useful when working with sequences of moving images (video) but again slow to compute.
SmartAA on the other hand is a quite simple implementation of the M.-N. filter and runs blazingly fast when run on the GPU – producing about 70 redraws per sec on a 1024*768 image.
Unfortunately it´s not nearly as fast on the CPU.
If you have a rather slow machine, you will have seen the demo struggling to keep a 24fps framerate, so its just! that bit too slow to to antialias the pixelated output of a flash based C64 emulator.
That would have been cool… would love to see something like that.
I kept it flash compatible anyway – still there might be applications.
Its a matter of personal reception, but to me the M.-N. filter looks better on videos as the inbuild “smooth”-method.
Anyway – flash video has been criticized enaugh for high cpu usage so lets not make things worse
Also: like any reconstruction filter it won´t work in any given scenario as there are some natural and some specific limitations.
So what can SmartAA do and what not? Here is a feature/limitation list:
- Works with Photoshop, After Effects, Flash
- Supports alpha channel
- Is real-time
- Does no up/down scaling – just reconstruction of anti aliasing
- Is scenario specific – for example text will often look strange
- works only with artifacts in the same pixel space.
Let me elaborate on the last point:
As SmartAA takes only neighbouring pixels into account it isn´t able to reconstruct aliasing effects that span over greater distances than 2 pixels.
For example if an image exists of 4*4 pixel blocks of the same color, those blocks would get rounded on the edges but will still be visible as rounded blocks.
But it works ideal on sources like aliased output from a render engine, or images that have been upscaled x2 with the nearest neighbour method.
Aliasing should be fought before it ends up within an image as there are more sophisticated methods to keep it from emerging than to reconstruct it after the damage is done.
But sometimes it´s inevitable and if you are looking for a simple but effective way to get rid of that ugly blocks within an image or video – SmartAA will do the trick.
Try to add a sharpen filter or better an unsharpen mask to the result to counter the blur effect.
Don´t forget to use the width/hight properties – SmartAA will work without but there will be artifacts on the upper- and lower right corner.
I hope this is helpful to anyone out there and would love to hear some comments or ideas.