Tuesday, October 30, 2007

JPEG compression

The basic jpeg compression steps (only think of gray level image):
  1. divide the image to 8x8 matrices
  2. use DCT to each 8x8 matrix
  3. sum up all the 8x8 matrices and get a matrix sum_mat
  4. sort the elements of 8x8 matrix(sum_mat) from the highest to the smallest, and get the indices list
  5. choose (some) highest coefficients: the ratio: (some high energy)/(total energy) is good enough (or pick the first N highest coefficients)
  6. save the index list of the high energy (coefficient). In each 8x8 matrix, only save these coefficients.
  7. build 8x8 matrices with zero and store the right coefficient in the right place with the index list.
  8. use IDCT to each matrix
  9. 8x8 matrices to big image size matrix. (restored_img)
  10. Calculate SNR: SNR = (sum(original_img(:).^2)) / (sum(original_img(:)-restored_img(:)).^2)
Also look at the book digital image processing 2nd Ed. page 498. Some relevant matlab code can be found at former post Use DCT for image compression

No comments:

Post a Comment