Open in the MATLAB editor: c09fb_example
function c09fb_example fprintf('c09fb example results\n\n'); m = int64(5); n = int64(4); fr = int64(3); wavnam = 'Haar'; mode = 'half'; wtrans = 'Single Level'; a = zeros(m, n, fr); a(:, :, 1) = [3, 2, 2, 2; 2, 9, 1, 2; 2, 5, 1, 2; 1, 6, 2, 2; 5, 3, 2, 2]; a(:, :, 2) = [2, 1, 5, 1; 2, 9, 5, 2; 2, 3, 2, 7; 2, 1, 1, 2; 2, 1, 2, 8]; a(:, :, 3) = [3, 1, 4, 1; 1, 1, 2, 1; 4, 1, 7, 2; 3, 2, 1, 5; 1, 1, 2, 2]; % Query wavelet filter dimensions [lmax, nf, nwct, nwcn, nwcfr, icomm, ifail] = ... c09ac(wavnam, wtrans, mode, m, n, fr); nwcm = nwct/(8*nwcn*nwcfr); % 3D DWT decomposition [c, icomm, ifail] = c09fa(n, fr, a, nwct, icomm); d = zeros(nwcm, nwcn, nwcfr); for cindex = 0:7 % Decide which coefficient type we are considering and advance the % pointer locc to the first element of that 3D array in C. switch (cindex) case {0} fprintf('Approximation coefficients (LLL)\n'); locc = 1; case {1} fprintf('Detail coefficients (LLH)\n'); % Advance pointer past approximation coefficients locc = nwcm*nwcn*nwcfr + 1; case {2} fprintf('Detail coefficients (LHL)\n'); % Advance pointer past approximation coefficients and 1 set of % detail coefficients locc = 2*nwcm*nwcn*nwcfr + 1; case {3} fprintf('Detail coefficients (LHH)\n'); % Advance pointer past approximation coefficients and 2 sets of % detail coefficients locc = 3*nwcm*nwcn*nwcfr + 1; case {4} fprintf('Detail coefficients (HLL)\n'); % Advance pointer past approximation coefficients and 3 sets of % detail coefficients locc = 4*nwcm*nwcn*nwcfr + 1; case {5} fprintf('Detail coefficients (HLH)\n'); % Advance pointer past approximation coefficients and 4 sets of % detail coefficients locc = 5*nwcm*nwcn*nwcfr + 1; case {6} fprintf('Detail coefficients (HHL)\n'); % Advance pointer past approximation coefficients and 5 sets of % detail coefficients locc = 6*nwcm*nwcn*nwcfr + 1; case {7} fprintf('Detail coefficients (HHH)\n'); % Advance pointer past approximation coefficients and 6 sets of % detail coefficients locc = 7*nwcm*nwcn*nwcfr + 1; end for k = 1:nwcfr for j = 1:nwcn for i = 1:nwcm i1 = locc - 1 + (j-1)*nwcfr*nwcm + (i-1)*nwcfr + k; d(i,j,k) = c(i1); end end end for j = 1:nwcfr if (j==1) fprintf('Coefficients Frame 1'); else fprintf(' Frame %d', j); end end fprintf('\n'); d2 = reshape(d, nwcm, nwcn*nwcfr); for i = 1:nwcm if i == 1 fprintf(' %d ', cindex); else fprintf(' '); end for j=1:nwcn*nwcfr fprintf('%8.4f ', d2(i,j)); end fprintf('\n'); end end % 3D DWT reconstruction [b, ifail] = c09fb(m, n, fr, c, icomm); fprintf('\nOutput Data b : \n'); % Convert to int16 to get more compact output for i=1:nwcm fprintf('Frame %d :\n', i); disp(b(:, :, i)); end
c09fb example results Approximation coefficients (LLL) Coefficients Frame 1 Frame 2 0 10.6066 7.0711 4.2426 5.6569 7.7782 6.7175 7.0711 10.6066 7.7782 9.8995 2.8284 5.6569 Detail coefficients (LLH) Coefficients Frame 1 Frame 2 1 0.7071 -2.1213 0.0000 0.0000 2.1213 -1.7678 0.0000 0.0000 3.5355 -4.2426 0.0000 0.0000 Detail coefficients (LHL) Coefficients Frame 1 Frame 2 2 -4.2426 2.1213 1.4142 2.8284 -2.8284 -2.4749 2.8284 0.7071 2.1213 -4.2426 0.0000 0.0000 Detail coefficients (LHH) Coefficients Frame 1 Frame 2 3 0.0000 -2.8284 0.0000 0.0000 -2.8284 1.7678 0.0000 0.0000 0.7071 4.2426 0.0000 0.0000 Detail coefficients (HLL) Coefficients Frame 1 Frame 2 4 -4.9497 0.0000 1.4142 1.4142 0.7071 1.7678 -0.0000 2.1213 0.0000 0.0000 0.0000 0.0000 Detail coefficients (HLH) Coefficients Frame 1 Frame 2 5 0.7071 0.7071 0.0000 0.0000 -0.7071 -2.4749 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Detail coefficients (HHL) Coefficients Frame 1 Frame 2 6 5.6569 0.7071 1.4142 1.4142 0.0000 -1.7678 1.4142 6.3640 0.0000 0.0000 0.0000 0.0000 Detail coefficients (HHH) Coefficients Frame 1 Frame 2 7 0.0000 0.0000 0.0000 0.0000 1.4142 1.0607 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Output Data b : Frame 1 : 3.0000 2.0000 2.0000 2.0000 2.0000 9.0000 1.0000 2.0000 2.0000 5.0000 1.0000 2.0000 1.0000 6.0000 2.0000 2.0000 5.0000 3.0000 2.0000 2.0000 Frame 2 : 2.0000 1.0000 5.0000 1.0000 2.0000 9.0000 5.0000 2.0000 2.0000 3.0000 2.0000 7.0000 2.0000 1.0000 1.0000 2.0000 2.0000 1.0000 2.0000 8.0000 Frame 3 : 3.0000 1.0000 4.0000 1.0000 1.0000 1.0000 2.0000 1.0000 4.0000 1.0000 7.0000 2.0000 3.0000 2.0000 1.0000 5.0000 1.0000 1.0000 2.0000 2.0000