【程式碼備份】NLM插值
阿新 • • 發佈:2018-12-20
檔案路徑:
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。