DSPRelated.com
Code

2D Image Subsample

Ron April 1, 2011 Coded in Matlab

A script that subsamples an 2D matrix (greyscale image).

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;

B = uint8(conv2(double(A),M));
imwrite(B,'out.jpg','JPG');