None.
Open in the MATLAB editor: c09ab_example
function c09ab_example fprintf('c09ab example results\n\n'); m = int64(8); n = int64(8); a = [6, 7, 8, 0, 1, 9, 7, 8; 9, 1, 9, 9, 2, 8, 1, 9; 3, 0, 4, 1, 3, 1, 0, 4; 2, 5, 9, 4, 4, 2, 5, 9; 1, 8, 3, 3, 5, 3, 8, 3; 8, 1, 6, 4, 6, 1, 1, 6; 8, 1, 1, 1, 2, 3, 1, 6; 9, 2, 2, 4, 6, 1, 2, 9]; fprintf('\nInput data:\n'); disp(a); wavnam = 'Haar'; mode = 'Whole'; wtrans = 'Multilevel'; [nwl, nf, nwct, nwcn, icomm, ifail] = ... c09ab(... wavnam, wtrans, mode, m, n); lenc = nwct; % Calculate one less than the max possible number of levels nwl = nwl - 1; % Perform Discrete Wavelet transform [c, dwtlvm, dwtlvn, icomm, ifail] = c09ec(a, lenc, nwl, icomm); % c09ab returns nwct based on max levels % so recalculate based on nwl levels nwct = 3*sum(dwtlvm(1:nwl).*dwtlvn(1:nwl)); nwct = nwct + dwtlvm(1)*dwtlvn(1); fprintf('\nLength of wavelet filter : %d\n', nf); fprintf('Number of Levels : %d\n', nwl); fprintf('Number of coefficients in first dimension for each level :\n'); disp(transpose(dwtlvm(1:nwl))); fprintf('Number of coefficients in second dimension for each level :\n'); disp(transpose(dwtlvn(1:nwl))); fprintf('\nTotal number of wavelet coefficients : %d\n', nwct); fprintf('\nWavelet coefficients c :\n'); % print c using groups of eight ngroups = nwct/8; nleft = mod(nwct,8); for i=0:ngroups-1 fprintf('%8.4f', c(8*i+1:8*i+8)); fprintf('\n'); end fprintf('%8.4f', c(nwct-nleft+1:nwct)); fprintf('\n\n'); % Now select a nominated matrix of coefficients at a nominated level. % level 0 is input data, 1 first coeffs and so on up to nwl: % the deepest level and containing approximation coefficients. want_level = nwl - 1; % Only vertical detail coeffs at selected level. want_coeffs = int64(1); nwcm = dwtlvm(nwl-want_level+1); nwcn = dwtlvn(nwl-want_level+1); % Extract the selected set of coefficients. [d, icomm, ifail] = c09ey(want_level, want_coeffs, c, icomm); % Display the selected coefficients fprintf('\nType %3d coefficients at selected wavelet level %3d :\n', ... want_coeffs, want_level); disp(d); % Reconstruct original data [b, ifail] = c09ed(nwl, c, m, n, icomm); fprintf('Reconstruction b:\n'); disp(b);
c09ab example results Input data: 6 7 8 0 1 9 7 8 9 1 9 9 2 8 1 9 3 0 4 1 3 1 0 4 2 5 9 4 4 2 5 9 1 8 3 3 5 3 8 3 8 1 6 4 6 1 1 6 8 1 1 1 2 3 1 6 9 2 2 4 6 1 2 9 Length of wavelet filter : 2 Number of Levels : 2 Number of coefficients in first dimension for each level : 2 4 Number of coefficients in second dimension for each level : 2 4 Total number of wavelet coefficients : 64 Wavelet coefficients c : 19.2500 15.5000 18.2500 15.7500 -2.7500 3.5000 -3.2500 -2.2500 5.2500 1.5000 4.2500 0.7500 1.2500 -2.5000 0.7500 0.7500 3.5000 0.0000 0.0000 7.0000 4.0000 4.0000 1.0000 -1.0000 -7.0000 2.0000 3.5000 2.0000 -4.5000 -4.0000 0.0000 -6.0000 1.5000 -2.0000 0.0000 -1.0000 -5.0000 -4.0000 -2.0000 -2.0000 0.0000 -1.0000 0.5000 -1.0000 2.5000 -5.0000 2.0000 -2.0000 -4.5000 3.0000 -7.0000 -0.0000 4.0000 -1.0000 -1.0000 1.0000 -1.0000 0.0000 -1.5000 -3.0000 3.5000 0.0000 5.0000 1.0000 Type 1 coefficients at selected wavelet level 1 : 3.5000 4.0000 -7.0000 -4.5000 0 4.0000 2.0000 -4.0000 0 1.0000 3.5000 0 7.0000 -1.0000 2.0000 -6.0000 Reconstruction b: 6.0000 7.0000 8.0000 0.0000 1.0000 9.0000 7.0000 8.0000 9.0000 1.0000 9.0000 9.0000 2.0000 8.0000 1.0000 9.0000 3.0000 0.0000 4.0000 1.0000 3.0000 1.0000 0.0000 4.0000 2.0000 5.0000 9.0000 4.0000 4.0000 2.0000 5.0000 9.0000 1.0000 8.0000 3.0000 3.0000 5.0000 3.0000 8.0000 3.0000 8.0000 1.0000 6.0000 4.0000 6.0000 1.0000 1.0000 6.0000 8.0000 1.0000 1.0000 1.0000 2.0000 3.0000 1.0000 6.0000 9.0000 2.0000 2.0000 4.0000 6.0000 1.0000 2.0000 9.0000