【代码备份】原图降采样后进行NLM滤波

文件路径:

滤波算法main.m:

%% 测试函数
%NLM滤波及滤波与
clc,clear all,close all;
ima_ori=double(imread('F:\Users\cylan\Documents\MATLAB\TestImages\标准图像\lenna.bmp'));%原图

ima=imresize(ima_ori,0.5,'nearest');
[wid,len,channels]=size(ima);
search=1;%搜索窗半径大小=4
patch=1;%匹配窗半径大小
sigma=5;
rima=imresize(ima,2,'bicubic');%原图降采样后的双三次插值放大
% denoise
fima=rima;
if channels>2 
    for i=1:channels      
       fima(:,:,i)=NLmeansfilter(rima(:,:,i),search,patch,sigma);
    end
end

% show results
%subplot(1,3,1),imshow(uint8(ima)),title('original');
subplot(1,3,2),imshow(uint8(rima)),title('ori-bicubic');
subplot(1,3,3),imshow(uint8(fima)),title('filtered');%NLM滤波后图像
[PSNR_ori, MSE_ori] = psnr(rima, ima_ori);
[PSNR_nlm, MSE_nlm] = psnr(fima, ima_ori);%将双三次插值的结果

 


记录:有些忘了,貌似是想对比滤波+插值插值+滤波?

[PSNR_ori, MSE_ori] = psnr(rima, ima_ori);
[PSNR_nlm, MSE_nlm] = psnr(fima, ima_ori);

分别计算的是单纯降采样后又插值的psnr,以及,插值后又进行了滤波的psnr。

可以发现,多了nlm滤波步骤后,psnr由29.1026->29.2503,提高了0.1477。

猜你喜欢

转载自www.cnblogs.com/wxl845235800/p/10150578.html