필터 지우기
필터 지우기

How to reduce size of 2D image ?

조회 수: 1 (최근 30일)
judy  frost
judy frost 2012년 11월 28일
I have to compress 2D NxN image by taking the fourier transform first, then in the frequency domain I have used high pass filtering and took the inverse fourier transform back. This method has worked in (.tiff,.jpg .png)and the size has reduced. I want to make the method work also for .ppm format but it does not work. I did not understand why it did not work and how can I make it work? Thank you.
  댓글 수: 3
judy  frost
judy frost 2012년 11월 28일
편집: judy frost 2012년 11월 28일
g = im2double(rgb2gray(image));
F = fft2(g);
A = lowpass(3,size(F,1),size(F,2),10,1); Gaussian lowpass
A = A-1;
B = A.*F;
res = ifft2(B);
imwrite(res,'a.ppm');
Does not work with ppm but works with others.
Walter Roberson
Walter Roberson 2012년 11월 28일
What datatype do you end up with?
Note: "image" is a built-in MATLAB graphics routine; you should avoid calling a variable by the same name.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2012년 11월 28일
Your routine did no compression at all. The compression was done by the saving routine because of the format you chose. When you got rid of high frequencies, it made the saving routine able to compress more IF the format is to be compressed at all. Here's what Wikipedia says about PPM:
"The PPM format is not compressed, and thus requires more space and bandwidth than a compressed format would require. For example, the above 192x128 PNG image has a file size of 166 bytes. When converted to a 192x128 PPM image, the file size is 73,848 bytes. The PPM format is generally an intermediate format used for image work before converting to a more efficient format, for example the PNG (Portable Network Graphics) format, without any loss of information in the intermediate step."
That is why you didn't see any change. Why do you want that format anyway? I see the world moving towards PNG, and for good reason - it's a lossless compressed image that virtually every program can read.

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by