【代码备份】NLM插值

本文介绍了一种基于非局部均值(NLM)的图像插值算法优化方法,通过调整搜索窗和匹配窗大小,结合高斯核权重,实现了对原始图像的高质量放大。实验结果显示,与传统的双三次插值相比,NLM插值能显著提高图像的峰值信噪比(PSNR),提升图像细节和清晰度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文件路径:

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。

 

转载于:https://www.cnblogs.com/wxl845235800/p/10150809.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值