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']);
灰度图超分辨率重建
最新推荐文章于 2023-09-23 12:07:40 发布