灰度图超分辨率重建

close all;
clear all;

%% 读取真实图像
im  = imread('Set5\butterfly_GT.bmp');
%im  = imread('Set14\zebra.bmp');

%% 设定参数
up_scale = 3;
model = 'model\x3.mat';
% up_scale = 2;
% model = 'model\x2.mat'; 
% up_scale = 4;
% model = 'model\x4.mat';

%% 仅在照度方面工作
if size(im,3)>1
    im = rgb2ycbcr(im);
    im = im(:, :, 1);
end
im_gnd = modcrop(im, up_scale);
im_gnd = double(im_gnd)/255;%single 这里换成double Matlab 7.0就可以运行了

%% 双三次插值
im_l = imresize(im_gnd, 1/up_scale, 'bicubic'); %缩小
im_b = imresize(im_l, up_scale, 'bicubic');%再放大

%% SRCNN
im_h = SRCNN(model, im_b);

%% 删除边框
im_h = shave(uint8(im_h * 255), [up_scale, up_scale]);
im_gnd = shave(uint8(im_gnd * 255), [up_scale, up_scale]);
im_b = shave(uint8(im_b * 255), [up_scale, up_scale]);

%% 计算 PSNR
psnr_bic = compute_psnr(im_gnd,im_b);
psnr_srcnn = compute_psnr(im_gnd,im_h);

%% 显示结果
fprintf('双三次插值的峰值信噪比: %f dB\n', psnr_bic);
fprintf('SRCNN 重建的峰值信噪比: %f dB\n', psnr_srcnn);

figure, imshow(im_b); title('双三次插值');
figure, imshow(im_h); title('SRCNN 重建');

imwrite(im_b, ['双三次插值' '.bmp']);
imwrite(im_h, ['SRCNN 重建' '.bmp']);

官方地址

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值