www.gusucode.com > 自己编写的一个基于matlab的图像压缩程序,有GUI界面,不能程度的压缩效果以及信噪比 > 自己编写的一个基于matlab的图像压缩程序,有GUI界面,不能程度的压缩效果以及信噪比/BP神经网络的图像压缩/wavelets压缩/cascade.m
function [x1,phi,x2,psi] = cascade(h,g,dx) % Wavelet cascade algorithm c = h{1}*2/sum(h{1}); x = 0:dx:length(c) - 1; x1 = x - h{2}; phi0 = 1 - abs(linspace(-1,1,length(x))).'; ii = []; jj = []; s = []; for k = 1:length(c) xk = 2*x - (k-1); i = find(xk >= 0 & xk <= length(c) - 1); ii = [ii,i]; jj = [jj,floor(xk(i)/dx)+1]; s = [s,c(k)+zeros(size(i))]; end % Construct a sparse linear operator that iterates the dilation equation Dilation = sparse(ii,jj,s,length(x),length(x)); for N = 1:30 phi = Dilation*phi0; if norm(phi - phi0,inf) < 1e-5, break; end phi0 = phi; end if norm(phi) == 0 phi = ones(size(phi))*sqrt(2); % Special case for Haar scaling function else phi = phi/(norm(phi)*sqrt(dx)); % Rescale result end if nargout > 2 phi2 = phi(1:2:end); % phi2 is approximately phi(2x) if length(c) == 2 L = length(phi2); else L = ceil(0.5/dx); end % Construct psi from translates of phi2 c = g{1}; psi = zeros(length(phi2)+L*(length(c)-1),1); x2 = (0:length(psi)-1)*dx - g{2} - 0*h{2}/2; for k = 1:length(c) i = (1:length(phi2)) + L*(k-1); psi(i) = psi(i) + c(k)*phi2; end end return;