function y = daubech4( x ) % DAUBECH4 4 tap Daubechies wavelet kernel c0 = 0.4829629; c1 = 0.8365163; c2 = 0.2241439; c3 = -0.1294095; d_kernel_l = [ c0 c1 c2 c3 ]; d_kernel_h = [ c3 -c2 c1 -c0 ]; [ size_v, size_h ] = size( x ); boundary = size_h - 3; half = size_h / 2; % Convolve with the filter kernels z = [ 1:size_h ]; for start = 1:2:size_h if( start <= boundary ) a = x( start:start+3 ); else residual = (size_h - start) + 1; a( 1:residual ) = x( start:size_h ); a( residual+1:4 ) = x( 1:4-residual ); end z( start ) = a * d_kernel_l'; z( start + 1 ) = a * d_kernel_h'; end % Shuffle the data into a temporary vector y = [ 1:size_h ]; y( 1:1:half ) = z( 1:2:size_h ); y( half+1:1:size_h ) = z( 2:2:size_h );