# MATLAB: Decimation image

I'm trying to decimate given picture

1. Vertically.
2. Horizontally.
3. Horizontally + Vertically.

I know that I should use low-pass filter* and then downsample** it not to see any aliasing in image. To this my code is below:

Horizontally filter:

filter_hor    = [0.25,0.5,0.25];
filtered_hor  = imfilter(big_shirt,filter_hor);%% big_shirt is shirt image given above
decimated_hor = filtered_hor(1:2:end,:);%%decimated_hor = downsample(filtered_hor,2);
imshow(decimated_hor)
title('Horizontally filtered')
axis on


Vertically filter:

filter_ver    = [0.25;0.5;0.25];
filtered_ver  = imfilter(big_shirt,filter_ver);
decimated_ver = filtered_ver(:,1:2:end);
imshow(decimated_ver)
title('Vertically filtered')
axis on


Horizontally + Vertically filter:

filtered_2D  = imfilter(decimated_hor,filter_ver);
decimated_2D = filtered_2D(:,1:2:end);
imshow(decimated_2D)
title('2D filtered')


What I get is :

*My low pass filter is: [0.25,0.5,0.25]

**By a factor of 2

My expectation is:

When I use horizontal filter, I just get rid of aliasing on lines of shirt collar.

When I use vertical filter, I just get rid of aliasing in vertically lines.

Vertical+horizontal will be nice picture like what I get.

However in first two cases are not satisfied. What can be the problem. My resolution on computer is 1366X768 and image size is 800X600. When I use imshow, I get:

Warning: Image is too big to fit on screen; displaying at 67%


Can be problem related to this or am I doing something wrong?

• The problem is your low-pass filter - it still lets in high frequencies. – geometrikal Feb 22 '15 at 0:48
• I know low pass filter is not good enough. However horizontally filter gives good result for horizontally lines. Vertical filter does not give good result. In 2D cases result seems very good. I don't know why. – toygan kılıç Feb 22 '15 at 9:06
• It just might just be aliasing due to MATLAB displaying it on the screen like you say (sorry I missed that last bit!). Use the zoom to check . :D – geometrikal Feb 22 '15 at 9:53
• Interesting idea to zoom :D. Does my code seem right? The thing I could not understand, in 2D filtered version horizontal aliasing does not occur while vertical filtered version, we see aliasing. – toygan kılıç Feb 22 '15 at 10:09
• looks to me like you just resized those images. – thang Feb 23 '15 at 23:20

After my trials, I realize that problem is directly about Warning: Image is too big to fit on screen; displaying at 67% warning. I use imwrite to my matrix and convert it to jpg file. After looking the image using jpg file , there is no problem.