For a school project, I need to think up some (hopefully easy) ways to compress (and decompress) images. I have looked at JPEG's algorithm, but it seems like much too much work to implement. This is just an assignment, so I was trying to think of algorithms that would be easier to implement in Matlab.(adsbygoogle = window.adsbygoogle || []).push({});

Lately, I have been trying to compress a grayscale image by transforming it into frequency space with a Fourier Transform. Then I would examine each value of the transformed matrix and, if the value was small enough, I would just set it zero. I would then use run-length-encoding to pack all the zeroes. However, when I decoded (i.e. unpacked and transformed back to pixel space) the image, pretty much all the values were zero (i.e. the image was all black); however, most values in frequency space were not zero. What am I doing wrong?

Here is my Matlab code. It takes as input a 3-d matrix that stores red green and blue values.

Also, does anyone have any other good ideas about how I could easily compress images? Furthermore, does anyone know of a good way to compare the quality of a compressed image with its original?Code (Text):function out = FFTCOMPRESS( in )

x = length(in(1,:))/3

y = length(in(:,1))

fr = fft2(in(:,:,1));

fg = fft2(in(:,:,2));

fb = fft2(in(:,:,3));

myout = zeros(1, 5+4*y*x*3);

myout(1) = x;

myout(2) = y;

myout(3) = 6;

for ii=1:y,

for jj=1:x,

if fr(ii,jj)<10

fr(ii,jj)=0;

end

if fg(ii,jj)<10

fg(ii,jj)=0;

end

if fb(ii,jj)<10

fb(ii,jj)=0;

end

end

end

n = 6

nz = 0

for jj=1:x,

for ii=1:y,

if nz ~= 0,

if fr(ii,jj)==0

nz=nz+1;

else

myout(n)=0;

myout(n+1)=nz;

myout(n+2)=fr(ii,jj);

nz=0;

n=n+3;

end

else

if fr(ii,jj)==0

nz=nz+1;

else

myout(n)=fr(ii,jj);

n=n+1;

end

end

end

end

nz=0;

myout(4)=n;

%Do the same think for fg & fb - I ommited this part.

out=myout(1:(n-1));

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Image Compression Methods

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Image Compression Methods | Date |
---|---|

Python Working with PNG images in Python | Oct 10, 2017 |

Image Processing -- Haar Transfrom | Oct 3, 2017 |

Geodesics between Images | Aug 22, 2017 |

Java Help with image icons in java | Mar 21, 2017 |

Huffman coding is currently being replaced with ANS coding | Jan 11, 2017 |

**Physics Forums - The Fusion of Science and Community**