Home > Open Source, OpenGTL > Moiré, when Open Source can be usefull to work

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.

About these ads
Categories: Open Source, OpenGTL
  1. Thomas Olsen
    20 October, 2009 at 23:24

    Wow. That image makes my head hurt!

  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: