Moiré, when Open Source can be usefull to work

Sometime I get asked whether what I do in open source is useful for my work. Except for the thing like kalculus that were explicitly written for my work needs, usually the time invested does not pay at all, despite using Krita for scaling or cropping images to put in a paper. But sometime you get the opportunity to accomplish a task in five minutes that would have taken way more time if you had not invest years of development before. Small victory.

Since my thesis deals a lot with computer vision, I wanted to make an introduction to signal and image processing concepts. One of them is the issue of aliasing, which happen when under sampling a signal. And one of the classical artifact caused by sampling is called Moiré. The image below show the result of rescaling a set of concentric circles by three and four (the image were resized up for display):

So my need was to generate those circles. And what better than a programming language made for generating images, such as Shiva ? One can argue that some other tool would have make a better choice. But I was very quick to get to this first version, where I just check if the pixel is inside a white circle or a black one:

kernel ConcentricCircles
  const int radius = 3;
  const float4 color1 = { 0.0, 0.0, 0.0, 1.0 };
  const float4 color2 = { 1.0, 1.0, 1.0, 1.0 };
  const float2 center = { IMAGE_WIDTH * 0.5 , IMAGE_HEIGHT * 0.5 };
  void evaluatePixel(out pixel4 result)
    float lf = length(result.coord - center);
    int l = lf;
    if( (l / radius & 1) == 1 )
      result = color1;
    } else {
      result = color2;

I then improved that version to get parameters and anti aliasing of the circles, the full Shiva kernel can be found in the shiva collections repository.

This entry was posted in Open Source, OpenGTL. Bookmark the permalink.

One Response to Moiré, when Open Source can be usefull to work

  1. Thomas Olsen says:

    Wow. That image makes my head hurt!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>