Successfully reported this slideshow.                             Upcoming SlideShare
×

# Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall 5/3) and CDF 9/7 Wavelet Transform By Matlab

1,003 views

Published on

Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall 5/3) and CDF 9/7 Wavelet Transform By Matlab

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No • Be the first to comment

### Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall 5/3) and CDF 9/7 Wavelet Transform By Matlab

1. 1. Image Compression Comparison UUssiinngg GGoollddeenn SSeeccttiioonn TTrraannssffoorrmm,, CCDDFF 55//33 ((LLee GGaallll 55//33)) aanndd CCDDFF 99//77 WWaavveelleett TTrraannssffoorrmm BByy MMaattllaabb Jun Li http://GoldenSectionTransform.org/
2. 2. Introduction In mathematics, Golden Section Transform is a new class of discrete orthogonal transform. Its theory involves golden ratio, Fibonacci number, Fourier analysis, wavelet theory, stochastic process, integer partition, matrix analysis, group theory, combinatorics on words, its applied fields include digital signal (image/audio/video) processing, denoising, watermarking, compression, coding and so on. see here.
3. 3. Simple Compression Scheme Source image is divided into 8 × 8 blocks of pixels Apply 2D transform (LGST, HGST, CDF 5/3, CDF 9/7) to each 8 × 8 block
4. 4. Set compression ratio, keep largest abs(elements) in each block, and set all the others to zero Apply inverse 2D transform to each 8 × 8 block to reconstruct the image Compute PSNR and compare the results.
5. 5. Transform matrix for 1D signal 4-level 8×8 LGST matrix for 1D signal
6. 6. 3-level 8×8 CDF 5/3 matrix for 1D singal
7. 7. 3-level 8×8 CDF 9/7 matrix for 1D singal
8. 8. 2-level 8×8 HGST matrix for 1D signal
9. 9. Matlab Code gstdemo.m % main file lgst2d.m % 4-level 2d low golden section transform ilgst2d.m % 4-level inverse 2d low golden section transform lword.m % Type-L golden section decomposion of fibonacci number legall53td.m % 3-level 2d CDF 5/3 transform lifting scheme ilegall53td.m % 3-level inverse 2d CDF 5/3 transform hgst2d.m % 2-level 2d high golden section transform ihgst2d.m % 2-level inverse 2d high golden section transform hword.m % Type-H golden section decomposion of fibonacci number cdf97td.m % 3-level 2d CDF 9/7 transform lifting scheme icdf97td.m % 3-level inverse 2d CDF 9/7 transform keep.m % keep largest abs(values) in matrix psnr.m % compute MSE and PSNR all the codes can be downloaded here: http://goldensectiontransform.org/
10. 10. legall53td.m function H = legall53td(X) % Author: Jun Li, more info@ http://goldensectiontransform.org/ % % function H = legall53td(X,nlevel) % 3-level 2d LeGall 5/3 wavelet transform of 8*8 image matrix nlevel = 3; % 3-level transform for each 8*8 image block [xx,yy] = size(X); H=X; for i=1:nlevel for j=1:xx [ss,dd] = legall531d(H(j,1:yy)); % row transform H(j,1:yy) = [ss,dd]; end for k=1:yy [ss,dd] = legall531d(H(1:xx,k)'); % column transform H(1:xx,k) = [ss,dd]'; end xx = xx/2; yy = yy/2; end %% 1d LeGall 5/3 lifting scheme % symw_ext->...12321... function [ss,dd] = legall531d(S) N = length(S); ga = -1/2; gb = 1/4; gc = sqrt(2); s0 = S(1:2:N-1); % S(1),S(3),S(5),S(7)... d0 = S(2:2:N); % S(2),S(4),S(6),S(8)... d1 = d0 + ga*(s0 + [s0(2:N/2) s0(N/2)]); s1 = s0 + gb*(d1 + [d1(1) d1(1:N/2-1)]); ss = gc*s1; dd = d1/gc;
11. 11. cdf97td.m function H = cdf97td(X) % Author: Jun Li, more info@ http://goldensectiontransform.org/ %% function H = cdf97td(X,nlevel) % 3-level 2d CDF 9/7 wavelet transform of 8*8 image matrix nlevel = 3; % 3-level transform for each 8*8 image block [xx,yy] = size(X); H=X; for i=1:nlevel for j=1:xx [ss,dd] = cdf971d(H(j,1:yy)); % row transform H(j,1:yy) = [ss,dd]; end for k=1:yy [ss,dd] = cdf971d(H(1:xx,k)'); % column transform H(1:xx,k) = [ss,dd]'; end xx = xx/2; yy = yy/2; end %% 1d CDF 9/7 wavelet lifting scheme % symw_ext->...12321... function [ss,dd] = cdf971d(S) N = length(S); fa = -1.586134342; fb = -0.05298011854; fc = 0.8829110762; fd = 0.4435068522; fz = 1.149604398; s0 = S(1:2:N-1); % S(1),S(3),S(5),S(7)... d0 = S(2:2:N); % S(2),S(4),S(6),S(8)... d1 = d0 + fa*(s0 + [s0(2:N/2) s0(N/2)]); s1 = s0 + fb*(d1 + [d1(1) d1(1:N/2-1)]); d2 = d1 + fc*(s1 + [s1(2:N/2) s1(N/2)]); s2 = s1 + fd*(d2 + [d2(1) d2(1:N/2-1)]); ss = fz*s2; dd = d2/fz;
12. 12. lgst2d.m function H = lgst2d(X) % Author: Jun Li, more info@ http://goldensectiontransform.org/ % function H = lgst2d(X,nlevel) % 4-level 2d low golden section transform of 8*8 image matrix nlevel = 4; % 4-level transform for each 8*8 image block global lj; % only used by function lgst1d(S) below. global FBL; % only used by function lgst1d(S) below. [xx,yy] = size(X); ind = floor(log(xx*sqrt(5)+1/2)/log((sqrt(5)+1)/2)); % determine index FBL = filter(1,[1 -1 -1],[1 zeros(1,ind-1)]); % FBL = Fibonacci sequence -> [1 1 2 3 5 8...]; H=X; for lj=1:nlevel for j=1:xx [ss,dd] = lgst1d(H(j,1:yy)); % row transform H(j,1:yy) = [ss,dd]; end for k=1:yy [ss,dd] = lgst1d(H(1:xx,k)'); % column transform H(1:xx,k) = [ss,dd]'; end xx = FBL(end-lj); % round((sqrt(5)-1)/2*xx); 8*8 block: xx=8->5->3->2 yy = FBL(end-lj); % round((sqrt(5)-1)/2*yy); 8*8 block: yy=8->5->3->2 end %% 1d low golden section transform function [ss,dd] = lgst1d(S) global lj; global FBL; index = 0; h = 1; lform = lword(length(S)); for i=1:length(lform) index = index + lform(i); if lform(i) == 1 ss(i) = S(index); else % lform(i) == 2 ss(i) = (sqrt(FBL(lj))*S(index-1)+sqrt(FBL(lj+1))*S(index))/sqrt(FBL(lj+2)); dd(h) = (sqrt(FBL(lj+1))*S(index-1)-sqrt(FBL(lj))*S(index))/sqrt(FBL(lj+2)); h = h+1; end end
13. 13. lword.m function lform = lword(n) % Author: Jun Li, more info@ http://goldensectiontransform.org/ % Type-L golden section decomposion of fibonacci number n, % e.g. lword(8) = [1 2 2 1 2]; if n == 1 lform = ; elseif n == 2 lform = ; else next = round((sqrt(5)-1)/2*n); lform = [lword(n-next),lword(next)]; end
14. 14. hgst2d.m function H = hgst2d(X) % Author: Jun Li, more info@ http://goldensectiontransform.org/ % function H = hgst2d(X,nlevel) % 2-level 2d high golden section transform of 8*8 image matrix nlevel = 2; % 2-level transform for each 8*8 image block global hj; % only used by function hgst1d(S) below. global FBH; % only used by function hgst1d(S) below. [xx,yy] = size(X); ind = floor(log(xx*sqrt(5)+1/2)/log((sqrt(5)+1)/2)); % determine index FBH = filter(1,[1 -1 -1],[1 zeros(1,ind-1)]); % FBH = Fibonacci sequence -> [1 1 2 3 5 8...]; H=X; for hj=1:nlevel for j=1:xx [ss,dd] = hgst1d(H(j,1:yy)); % row transform H(j,1:yy) = [ss,dd]; end for k=1:yy [ss,dd] = hgst1d(H(1:xx,k)'); % column transform H(1:xx,k) = [ss,dd]'; end xx = FBH(end-2*hj); % round((3-sqrt(5))/2*xx); 8*8 block: xx=8->3 yy = FBH(end-2*hj); % round((3-sqrt(5))/2*yy); 8*8 block: yy=8->3 end %% 1d high golden section transform function [ss,dd] = hgst1d(S) global hj; global FBH; index = 0; g = 1; h = 1; hform = hword(length(S)); for i=1:length(hform) index = index + hform(i); if hform(i) == 2 ss(i) = (sqrt(FBH(2*hj-1))*S(index-1)+sqrt(FBH(2*hj))*S(index))/sqrt(FBH(2*hj+1)); dd(2*i-g) = (sqrt(FBH(2*hj))*S(index-1)-sqrt(FBH(2*hj-1))*S(index))/sqrt(FBH(2*hj+1)); g = g+1; else % hform(i) == 3 ss(i) = (sqrt(FBH(2*hj))*S(index-2)+sqrt(FBH(2*hj-1))*S(index-1)+sqrt(FBH(2*hj))*S(index))/sqrt(FBH(2*hj+2)); dd(i+h-1) = (sqrt(FBH(2*hj-1))*S(index-2)-2*sqrt(FBH(2*hj))*S(index-1)+sqrt(FBH(2*hj-1))*S(index))/sqrt(2*FBH(2*hj+2)); dd(i+h) = (S(index-2)-S(index))/sqrt(2); h = h+1; end end
15. 15. hword.m function hform = hword(n) % Author: Jun Li, more info@ http://goldensectiontransform.org/ % Type-H golden section decomposion of fibonacci number n, % e.g. hword(8) = [3 2 3]; if n == 2 hform = ; elseif n == 3 hform = ; else next = round((sqrt(5)-1)/2*n); hform = [hword(n-next),hword(next)]; end
16. 16. keep.m function X = keep(X) % keep the largest abs(elements) of X, % global RATIO set in gstdemo.m is in [0,1]. global RATIO; N = floor(prod(size(X))*RATIO); [MM,i] = sort(abs(X(:))); X(i(1:end-N)) = 0;
17. 17. psnr.m function [MSE,PSNR] = psnr(X,Y) % Compute MSE and PSNR. MSE = sum((X(:)-Y(:)).^2)/prod(size(X)); if MSE == 0 PSNR = Inf; else PSNR = 10*log10(255^2/MSE); end
18. 18. Results
19. 19. Baboon 512*512
20. 20. References  Jun. Li (2007). "Golden Section Method Used in Digital Image Multi-resolution Analysis". Application Research of Computers (in zh-cn) 24 (Suppl.): 1880–1882. ISSN 1001- 3695;CN 51-1196/TP  I. Daubechies and W. Sweldens, "Factoring wavelet transforms into lifting schemes," J. Fourier Anal. Appl., vol. 4, no. 3, pp. 247-269, 1998.  Ingrid Daubechies. 1992. Ten Lectures on Wavelets. Soc. for Industrial and Applied Math., Philadelphia, PA, USA.  Sun, Y.K.(2005). Wavelet Analysis and Its Applications. China Machine Press. ISBN 7111158768  Jin, J.F.(2004). Visual C++ Wavelet Transform Technology and Engineering Practice. Posts & Telecommunications Press. ISBN 7115119597  He, B.;Ma, T.Y.(2002). Visual C++ Digital Image Processing. Posts & Telecommunications Press. ISBN 7115109559  V. Britanak, P. Yip, K. R. Rao, 2007 Discrete Cosine and Sine Transform, General properties, Fast Algorithm and Integer Approximations" Academic Press  K. R. Rao and P. Yip, Discrete Cosine Transform: Algorithms, Advantages, Applications, Academic Press, Boston, 1990.  J. Nilsson, On the entropy of random Fibonacci words, arXiv:1001.3513.  J. Nilsson, On the entropy of a family of random substitutions, Monatsh. Math. 168 (2012) 563–577. arXiv:1103.4777.
21. 21.  J. Nilsson, On the entropy of a two step random Fibonacci substitution, Entropy 15 (2013) 3312—3324; arXiv:1303.2526.  Wai-Fong Chuan, Fang-Yi Liao, Hui-Ling Ho, and Fei Yu. 2012. Fibonacci word patterns in two-way infinite Fibonacci words. Theor. Comput. Sci. 437 (June 2012), 69-81. DOI=10.1016/j.tcs.2012.02.020 http://dx.doi.org/10.1016/j.tcs.2012.02.020  Julien Cassaigne (2008). On extremal properties of the Fibonacci word. RAIRO - Theoretical Informatics and Applications, 42, pp 701-715. doi:10.1051/ita:2008003.  Wojciech Rytter, The structure of subword graphs and suffix trees of Fibonacci words, Theoretical Computer Science, Volume 363, Issue 2, 28 October 2006, Pages 211-223, ISSN 0304-3975, http://dx.doi.org/10.1016/j.tcs.2006.07.025.  Alex Vinokur, Fibonacci connection between Huffman codes and Wythoff array, arXiv:cs/0410013v2  Vinokur A.B., Huffman trees and Fibonacci numbers. Kibernetika Issue 6 (1986) 9-12 (in Russian), English translation in Cybernetics 22 Issue 6 (1986) 692–696; http://springerlink.metapress.com/link.asp?ID=W32X70520K8JJ617  L. Colussi, Fastest Pattern Matching in Strings, Journal of Algorithms, Volume 16, Issue 2, March 1994, Pages 163-189, ISSN 0196-6774, http://dx.doi.org/10.1006/jagm.1994.1008.  Ron Lifshitz, The square Fibonacci tiling, Journal of Alloys and Compounds, Volume 342, Issues 1–2, 14 August 2002, Pages 186-190, ISSN 0925-8388, http://dx.doi.org/10.1016/S0925-8388(02)00169-X.  C. Godr`eche, J. M. Luck, Quasiperiodicity and randomness in tilings of the plane, Journal of Statistical Physics, Volume 55, Issue 1–2, pp. 1–28.  S. Even-Dar Mandel and R. Lifshitz. Electronic energy spectra and wave functions on the square Fibonacci tiling. Philosophical Magazine, 86:759-764, 2006.