JPEG压缩解压缩的matlab源代码:
1) take an image (2D matrix) and devide it to 8x8 matrices
2) for each matrix (8x8) use the DCT conversion (from the signal
processing toolbox). you will get an (8x8) matrix as an answer
3) build an 8x8 matrix, which is the sum off all the matrices, such
that sum_matrix = A + B + C + ...
4) sort elements of the 8x8 matrix from the highest to the smallest
and get the indices list.
5) sum the last matrix with part of the elements which have the
higher coefficients, until you have a sufficient ratio (lets say
80%). for example :
idx = sort( sum_matrix (:) );
part_of_energy = sum_matrix(idx(1:20));
all_energy = sum_matrix(:);
ratio = part_of_energy/all_energy;
6) save the partial list of indices, number of matrices (rows,lines)
and from each matrix from step (2) save ONLY these coefficients
(remember the order you save them)