📄 wave2_nla.m
字号:
function imrec = wave2_nla(im, wname, nlev, ncoefs, plotflag)% WAVE2_NLA Non-linear approximation using 2-D wavelet transform%% imrec = wave2_nla(im, wname, nlev, ncoefs, [plotflag])edge = 'per';st = dwtmode('status', 'nodisp');if ~strcmp(st, edge) dwtmode(edge);end% Wavelet transform[c, s] = wavedec2(im, nlev, wname);% Sort the coefficients in descending order of the magnitudecsort = sort(abs(c(:)));csort = flipud(csort);lk = length(ncoefs);imrec = cell(1, lk);% Non-linear or N-best terms approximationfor k = 1:lk cn = c .* (abs(c) >= csort(ncoefs(k))); % Reconstruct with the most significant coefficients imrec{k} = waverec2(cn, s, wname);endif exist('plotflag', 'var') clf; range = [-0.25, 1.25]; % range = [-.5, 1.25]; colormap('gray'); ssize = round(sqrt(lk)); for k = 1:lk % subplot(ssize, ssize, k); subplot(1, lk, k); imagesc(imrec{k}, range); axis image, axis off, set(gca, 'FontSize', 8); title(sprintf('%d coefficients\n(SNR = %.2f dB)', ... ncoefs(k), SNR(im, imrec{k})), 'FontSize', 9); % imr = im - imrec; % subplot(2, lk, lk + k); % imagesc(imr, range); % axis image % set(gca, 'FontSize', 8); % title('Residue', 'FontSize', 10); endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -