# Aliasing and image resizing – part 2

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.

Published with MATLAB® R2016b

|