【代码备份】NLM插值

文件路径:

main.m:

%% 测试函数
clc,clear all,close all;
%输入的原始小图
ima_ori=double(imread('F:\Users\****n\Documents\MATLAB\TestImages\标准图像\monarch.bmp'));%原图

ima=imresize(ima_ori,0.5,'nearest');%降采样图,待输入处理。在该原始分辨率图像中进行搜索窗确认,遍历进行匹配相似度计算
%主功能函数
search=1;%搜索窗半径大小
patch=1;%匹配窗半径大小
sigma=5; %高斯核分配权重:h
ima1=imresize(ima,2,'bicubic');%初始升采样图中进行匹配窗口选取
[wid,len,channels]=size(ima1);
HRima=ima1;%大小需要注意!
if channels>2    
    for k=1:channels 
       %原图小图输入
       %                                                                
       HRima(:,:,k)=NLmeansfilter(ima(:,:,k),ima1(:,:,k),search,patch,sigma);%调用的是插值后的大图。
    end
end

% show results 
subplot(1,2,1),imshow(uint8(ima1)),title('original bicubic');
subplot(1,2,2),imshow(uint8(HRima)),title('NLM Inter');
imwrite(uint8(ima_ori),strcat('search=',num2str(search),'_patch=',num2str(patch),'_original','.tif'));
imwrite(uint8(ima1),strcat('search=',num2str(search),'_patch=',num2str(patch),'_original_bicubic','.tif'));
imwrite(uint8(HRima),strcat('search=',num2str(search),'_patch=',num2str(patch),'_NLM_Inter','.tif'));
[PSNR_ori, MSE_ori] = psnr(ima1, ima_ori);       
[PSNR_nlm, MSE_nlm] = psnr(HRima, ima_ori);

 monarch:

 

耗时:

 

psnr由28.4249->30.1206,提升了1.6957。

 

posted @ 2018-12-20 17:39  ostartech  阅读(276)  评论(0编辑  收藏  举报