Steve on Image Processing

Concepts, algorithms & MATLAB

Aliasing and image resizing – part 2 7

Posted by Steve Eddins,

In my 03-Jan-2017 post, I introduced my new topic: aliasing, especially as it relates to resizing images. Today I will get more specific about what aliasing actually is.

I'll use a 1-D sequence to illustrate. Here is part of a 1-D sequence with a period of 8.

a = repmat([1 1 1 1 0 0 0 0],1,9)
a =

  Columns 1 through 13

     1     1     1     1     0     0     0     0     1     1     1     1     0

  Columns 14 through 26

     0     0     0     1     1     1     1     0     0     0     0     1     1

  Columns 27 through 39

     1     1     0     0     0     0     1     1     1     1     0     0     0

  Columns 40 through 52

     0     1     1     1     1     0     0     0     0     1     1     1     1

  Columns 53 through 65

     0     0     0     0     1     1     1     1     0     0     0     0     1

  Columns 66 through 72

     1     1     1     0     0     0     0

Now let's "shrink" the sequence by sampling it with a spacing that is greater than 1, using nearest-neighbor interpolation. First, let's try a spacing of 4/3.

f = 4/3;
a_1 = a(round(1:f:end))
a_1 =

  Columns 1 through 13

     1     1     1     0     0     0     1     1     1     0     0     0     1

  Columns 14 through 26

     1     1     0     0     0     1     1     1     0     0     0     1     1

  Columns 27 through 39

     1     0     0     0     1     1     1     0     0     0     1     1     1

  Columns 40 through 52

     0     0     0     1     1     1     0     0     0     1     1     1     0

  Columns 53 through 54

     0     0

The shrunken sequence has a period of 6. That's consistent with the original sequence period and the shrink factor: $8/(4/3) = 6$.

Now let's increase the shrink factor to 1.6.

f = 1.6;
a_2 = a(round(1:f:end))
a_2 =

  Columns 1 through 13

     1     1     1     0     0     1     1     1     0     0     1     1     1

  Columns 14 through 26

     0     0     1     1     1     0     0     1     1     1     0     0     1

  Columns 27 through 39

     1     1     0     0     1     1     1     0     0     1     1     1     0

  Columns 40 through 45

     0     1     1     1     0     0

The sequence a_2 has a period of 5. Again, that is consistent with the original sequence period and shrink factor: $8/1.6 = 5$.

Let's bump the shrink factor up to 4.

f = 4;
a_3 = a(round(1:f:end))
a_3 =

  Columns 1 through 13

     1     0     1     0     1     0     1     0     1     0     1     0     1

  Columns 14 through 18

     0     1     0     1     0

The sequence a_4 has a period of 2, which is still understandably straightforward: $8/4 = 2$. Note that 2 is the shortest period possible for a nonconstant periodic discrete sequence.

It gets more fun (and less straightforward) when the shrink factor goes above 4.

f = 6;
a_4 = a(round(1:f:end))
a_4 =

     1     0     0     1     1     0     0     1     1     0     0     1

Now the shrunken sequence's periodicity appears to be 5, and that's harder to understand because $8/6 \neq 5$.

To recap what we've seen so far: the period of the shrunken sequence decreased steadily as we increased the shrink factor, but only up to a point. Once the shrink factor increased above 4 (half the original period), the period of the shrunken sequence stopped decreasing and starting changing in a different fashion.

This is an example of what signal processing folk call aliasing. The term is used in the sense of one frequency masquerading as another.

This happens when the shrink factor becomes too high to preserve the period of the original sequence.

Now let me illustrate aliasing using a zone plate image. (You can get imzoneplate from the MATLAB Central File Exchange.)

Z = imzoneplate(501);
imshow(Z)
title('Z')
Z4 = Z(1:4:end,1:4:end);
imshow(Z4)
title('Z4')

That result hardly looks anything like the original image. The visual artifacts are caused by aliasing. The original image has high spatial frequencies near the boundaries that can't be represented when we shrink the image. Those frequencies, instead of just disappearing, get "aliased" into a different set of spatial frequencies.

In general, aliasing distortion can't be removed once it has happened. Instead, antialiasing techniques must be applied as part of the image resizing process. Next time, I'll discuss the particular antialiasing procedure used by imresize.


Get the MATLAB code

Published with MATLAB® R2016b

7 CommentsOldest to Newest

Thomas Kinsman replied on : 1 of 7

When I teach my Computer Science students “aliasing” many students get confused with the overloading of the term. In CS Aliasing means having a second way to reference a memory location — such as a second copy of the address. [See en.wikipedia.org/wiki/Aliasing_(computing)] These days I try to teach it as ~under-sampling~ so they get the meaning with a shorter learning curve.

So, some people might like the term under-sampling as a better introductory alternative term. Then you might explain that it is also called ~aliasing~ because one frequency appears to be another.

The zone plate example is great!

– TK

Steve Eddins replied on : 2 of 7

Thomas—Thanks for the suggestion. In my brief academic career, I once taught a graduate-level image processing class to students with both EE and CS backgrounds. I don’t think I handled it very well! And I never had the chance to try it again.

Steve Eddins replied on : 4 of 7

Joofa—Thanks. I replied to the forum thread you linked to, although my comment hasn’t been passed by the moderators yet. The aliasing shown in the picture there is because of the TV scan lines. They are undersampling the signal in the vertical dimension.

Chad Greene replied on : 5 of 7

Thomas, that’s an interesting point, but I think you’re doing a disservice to your students. When I was a student, I also had trouble remembering vocabulary terms, but in hindsight I realize I only had trouble when I was trying to memorize terms without understanding the underlying concepts. The term “aliasing” is key to understanding what’s going on physically. An under-sampled image can take on an entirely different identity–an alias. Understanding that is much more important than simply being told that an image is under-sampled, without understanding why under-sampling is problem.

Don’t sell your students short. If they understand the concept of aliasing, the vocabulary will be no problem.

Dustin replied on : 6 of 7

In MR imaging, the wrap-around artifact you sometimes see (e.g., the nose goes around the image so that it is behind the head) is a result of aliasing.

The reason is that you actually acquire the image in Fourier space; frequency sampling density corresponds to field-of-view. Insufficient sampling gives an image that’s too small, leading too aliasing.

Add A Comment

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

What is 8 + 9 ?

Preview: hide