Open in the MATLAB editor: c09fa_example
function c09fa_example fprintf('c09fa example results\n\n'); % Data m = int64(5); n = int64(4); fr = int64(3); 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 wavnam = 'Haar'; mode = 'half'; wtrans = 'Single Level'; [lmax, nf, nwct, nwcn, nwcfr, icomm, ifail] = ... c09ac(... wavnam, wtrans, mode, m, n, fr); % 3D DWT decomposition [c, icomm, ifail] = c09fa(... n, fr, a, nwct, icomm); cpass = char('LLH','LHL','LHH','HLL','HLH','HHL','HHH'); % Loop over Low/High passes want_level = int64(0); matrix = 'General'; diag = 'Non-unit'; fmt = 'F9.4'; labrow = 'Integer'; labcol = labrow; rlabs = {' '}; clabs = rlabs; ncols = int64(80); indent = int64(0); for cindex = int64(1:7) if cindex==0 fprintf('Approximation coefficients (LLL)\n'); else fprintf('Detail coefficients (%s)\n',cpass(cindex,:)); end % Extract coeficients [d, icomm, ifail] = c09fy(... want_level, cindex, c, icomm); for k = 1:nwcfr title = sprintf('Frame: %3d',k); [ifail] = x04cb(... matrix, diag, d(:,:,k), fmt, title, labrow, ... rlabs, labcol, clabs, ncols, indent); end fprintf('\n'); end % 3D DWT reconstruction [b, ifail] = c09fb(m, n, fr, c, icomm); fprintf('\nReconstructed Data b : \n'); % More compact output for expected values fmt = 'F6.1'; for k=1:fr fprintf('\n'); title = sprintf('Frame: %3d',k); [ifail] = x04cb(... matrix, diag, b(:,:,k), fmt, title, labrow, ... rlabs, labcol, clabs, ncols, indent); end
c09fa example results Detail coefficients (LLH) Frame: 1 1 2 1 0.7071 -2.1213 2 2.1213 -1.7678 3 3.5355 -4.2426 Frame: 2 1 2 1 0.0000 0.0000 2 0.0000 0.0000 3 0.0000 0.0000 Detail coefficients (LHL) Frame: 1 1 2 1 -4.2426 2.1213 2 -2.8284 -2.4749 3 2.1213 -4.2426 Frame: 2 1 2 1 1.4142 2.8284 2 2.8284 0.7071 3 0.0000 0.0000 Detail coefficients (LHH) Frame: 1 1 2 1 0.0000 -2.8284 2 -2.8284 1.7678 3 0.7071 4.2426 Frame: 2 1 2 1 0.0000 0.0000 2 0.0000 0.0000 3 0.0000 0.0000 Detail coefficients (HLL) Frame: 1 1 2 1 -4.9497 0.0000 2 0.7071 1.7678 3 0.0000 0.0000 Frame: 2 1 2 1 1.4142 1.4142 2 -0.0000 2.1213 3 0.0000 0.0000 Detail coefficients (HLH) Frame: 1 1 2 1 0.7071 0.7071 2 -0.7071 -2.4749 3 0.0000 0.0000 Frame: 2 1 2 1 0.0000 0.0000 2 0.0000 0.0000 3 0.0000 0.0000 Detail coefficients (HHL) Frame: 1 1 2 1 5.6569 0.7071 2 0.0000 -1.7678 3 0.0000 0.0000 Frame: 2 1 2 1 1.4142 1.4142 2 1.4142 6.3640 3 0.0000 0.0000 Detail coefficients (HHH) Frame: 1 1 2 1 0.0000 0.0000 2 1.4142 1.0607 3 0.0000 0.0000 Frame: 2 1 2 1 0.0000 0.0000 2 0.0000 0.0000 3 0.0000 0.0000 Reconstructed Data b : Frame: 1 1 2 3 4 1 3.0 2.0 2.0 2.0 2 2.0 9.0 1.0 2.0 3 2.0 5.0 1.0 2.0 4 1.0 6.0 2.0 2.0 5 5.0 3.0 2.0 2.0 Frame: 2 1 2 3 4 1 2.0 1.0 5.0 1.0 2 2.0 9.0 5.0 2.0 3 2.0 3.0 2.0 7.0 4 2.0 1.0 1.0 2.0 5 2.0 1.0 2.0 8.0 Frame: 3 1 2 3 4 1 3.0 1.0 4.0 1.0 2 1.0 1.0 2.0 1.0 3 4.0 1.0 7.0 2.0 4 3.0 2.0 1.0 5.0 5 1.0 1.0 2.0 2.0