image compression using FFT
18 views (last 30 days)
Show older comments
Sir how can we compress image using FFT transform..RLE coding is not suitable with the FFT..what coding technique is suitable for FFT to compress the image..
0 Comments
Answers (2)
Walter Roberson
on 3 Apr 2014
RLE is a lossless compression technique. Compression with FFT is a lossy compression technique. You do the FFT, and you throw away some of the coefficients and output the rest; then for reconstruction you let the missing coefficients be 0 and do the inverse FFT.
Which coefficients you should throw away is something for you to explore.
0 Comments
sam k
on 6 Jun 2020
a=imread('link.jpeg');
grayIm =rgb2gray(a);
[row col] = size(grayIm);
subplot(2, 2, 1);
imshow(grayIm);
title('original image')
A=fft2(grayIm); %2D fft
count_pic=2;
for thresh=0.1*[0.001 0.005 0.006]*max(max(abs(A)))
ind=abs(A)>thresh;
count=row*col-sum(sum(ind));
Alow=A.*ind;
per=100-count/(row*col)*100;
Blow=uint8(ifft2(Alow));
subplot(2,2,count_pic);
imshow(Blow);
count_pic=count_pic+1;
title([num2str(per) '% of fft basis'])
end
2 Comments
Sulaymon Eshkabilov
on 15 Nov 2023
This means what % of the highest FFT coeffcients to keep.
It can be also applied for color (RGB) images as well:
A = imread('A1.jpeg');
Afft=fft2(A);
Asort = sort(abs(Afft(:)));
counter=0;
for Keep = [.95 .1 .05 .001]
threshold = Asort(floor((1-Keep)*length(Asort)));
Ind = abs(Afft)>threshold;
Atlow = Afft.*Ind;
Alow = uint8(ifft2(Atlow));
s = whos('Alow');
totSize = s.bytes;
counter=counter+1;
figure(counter)
imshow(Alow)
saveas(gcf, strcat(['FFT_IMG', num2str(counter) '.jpeg']))
s = dir(strcat(['FFT_IMG', num2str(counter) '.jpeg']));
filesize(counter)=s.bytes
title([num2str(Keep) '% of fft basis is kept and updated image file size is: ' num2str(s.bytes)])
end
See Also
Categories
Find more on Denoising and Compression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!