1

I have came about a MATLAB code like the following:

xyz = imfilter(A,B);
xyz_subsample = xyz(1:2:size(xyz, 1), 1:2:size(xyz, 2));

The code is related to subsampling. But, what does the second line mean?

Thanks.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Simplicity
  • 47,404
  • 98
  • 256
  • 385

2 Answers2

4

The second line is taking every second sample in each spatial dimension. So it's downsampling by a factor of 2 in each dimension.

Downsampling should be preceded by lowpass filter in order to avoid aliasing effects. The filter in the first line probably does that. Is B a lowpass mask?

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
2

The second line uses the colon operator to select every second row and every second colum, which means that every 4th pixel is selected.

Daniel
  • 36,610
  • 3
  • 36
  • 69