Task 125: Anti-aliasing of an image

Your task is to procedurally generate an anti-aliased 2D raster image. Your method, which returns one color, will be executed (independently) for every pixel of the image.



This assignment is an extension of 123 - addition of anti-aliasing to it.

The application 117raster from the repository grcis (GIT) serves as the basis of this project. For detailed description refer to this page.

Your solution will use ModuleFormula module (documented in the 117raster application). Your solution should be implemented as a CS-script, which will be executed on every pixel of the image (formula.pixelCreate function). If loading of input parameters or some additional initialization is required, use function formula.contextCreate.

Alternative (for easier implementation and debugging of the code in the Visual Studio): instead of CS-script, you can write your implementation directly in full-fledged C# following the example of ModuleFormulaInternal module. Implementation requirements are the same, but the solution is not a CS-script anymore, and as such it is no longer be possible to modify the code and re-run it without recompilation of the whole project. On the other hand you will have available all features of Visual studio (e.g., code completion, debugger, ...).

Examples of scripts generating raster images are: Contrast.cs and Swap.cs (both can be found in the 117raster project folder). Contrast.cs generates colorful visualization of sinc(R2) function, and Swap.cs contains a variation of the same formula with discrete results and without use of goniometric functions.

You can observe how to read and parse input text parameters in the Swap.cs script. If you need to pass some values (parameters) to the formula.pixelCreate function, then save this value to the map Dictionary<string, object> (return value of formula.contextCreate). Later on, it will be accessible in the formula.pixelCreate via ic.context. For example see parameter "freq" (defining frequency of concentric circles) in Swap.cs.

Alternative: Example of alternative implementation via module (as a part of the project) is in modules/Formula/ModuleFormulaInternal.cs, specifically ModuleFormulaInternal class. Do not forget to adjust author name (and name of the module itself) in your implementation.


You can use your solution from assignment 123 (if it is suitable for anti-aliasing) or an "endless checkerboard" (file: Checker4.cs - from download link).

We recommend to use simple super-sampling technique (see lecture) to facilitate anti-aliasing of the image. If you do so, don't forget to add level of super-sampling as a parameter.

Implement your solution in a script file similar to Contrast.cs or Swap.cs. It is necessary to define function formula.pixelCreate and potentially formula.contextCreate for argument parsing.

Alternative: your can also define your pixel function inside of a new class (see modules/Formula/ModuleFormulaInternal.cs for reference). Definition of lambda functions can be found in the GetFormula() method.

What to hand in

Your source file (CS-script). Include instructions for use - especially if you will use modifiable parameters (include their explanations and acceptable ranges of values). Instructions can be represented as a comment block or tooltip text.

Alternative: source file with implementation of your class derived from ModuleFormula.


Hand in the assignment until: 19. 12. 2021


4 až 8 bodů based on quality and originality of the solution and additional available parametrization related to the anti-aliasing (e.g., option to turn anti-aliasing on or off and control its level).


Visual Studio project: 117raster

Source file

Single source file (CS-script), usable as plugin in the ModuleFormula module. Alternatively, source file with implementation of your class derived from ModuleFormula.

Copyright (C) 2010-2021 J. Pelikán & V. Tázlar, last change: 2021-06-07 13:52:48 +0200 (Mon, 07 Jun 2021)