I'm trying to decimate given picture enter image description here

  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);
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);
title('Vertically filtered')
axis on

Horizontally + Vertically filter:

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

What I get is :

enter image description here

enter image description here

enter image description here

*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?

  • $\begingroup$ The problem is your low-pass filter - it still lets in high frequencies. $\endgroup$ Feb 22 '15 at 0:48
  • $\begingroup$ 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. $\endgroup$ Feb 22 '15 at 9:06
  • 2
    $\begingroup$ 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 $\endgroup$ Feb 22 '15 at 9:53
  • $\begingroup$ 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. $\endgroup$ Feb 22 '15 at 10:09
  • 1
    $\begingroup$ looks to me like you just resized those images. $\endgroup$
    – 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.