DSPRelated.com
Code

2D Image FIR Subsample

Ron April 1, 2011 Coded in Matlab

A script that subsamples an 2D matrix (greyscale image) using a 2D FIR filter.

A = imread('in.jpg');

M =   [ 1 4  6  4  1;
        4 16 24 16 4;
        6 24 36 24 6;
        4 16 24 16 4;
        1 4  6  4  1 ] / 256;

Y = filter2(M,A);
B = uint8(conv2(double(Y),M));

imwrite(B,'out.jpg','JPG');