class MakeOutputImage with anti-aliasing

In the earlier post “Smoothing and anti-aliasing” I discussed how to smooth images and reduce aliasing.This is an important part of the class MakeOutputImage. This class is rather a template for programming and not a finished module. You find its code in the next post.

You create an object of this class with

outputMaker=new MakeOutputImage(outputImage);

where outputImage is a PImage object. The actual image is created in a suitable function that returns a color depending on the coordinates of the pixel. Typically one would use here objects of the class Coordinates and ColorLookup. To test anti-aliasing I used simply

color theImage(float i,float j){
    return ripples(i,j);

You get the image from


if you don’t want any antialiasing. With


we use the first anti-aliasing method, using four points around each pixel. Improved anti-aliasing results from averaging nine points at each pixel with


which does not need much more time because lines of points are evaluated and reused for many pixels. Image filters or cellular automaton use similar methods.

Note that this class needs the class ProgressReport of the last post. The results shown in “smoothing and antialiasing” result from:

MakeOutputImage makeOutputImage;
PImage output;

void setup(){
  makeOutputImage=new MakeOutputImage(output);

void draw(){
//  makeOutputImage.simple();
//  makeOutputImage.block();

color ripples(float i,float j){
  return color(128*(1+cos(2*PI*i*(1+height-j)/600)),128,255*sq(cos(PI*i*j/600)));
This entry was posted in Extra, programming and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.