matlab sr,读懂matlab版的SRCNN

本文介绍了如何使用SRCNN(Super-Resolution Convolutional Neural Networks)深度卷积网络进行图像超分辨率重建,通过详细步骤展示了从读取图像、预处理、模型调用到结果展示的全过程,并比较了SRCNN与 bicubic 插值的PSNR。研究了不同模型参数对图像质量的影响,适合对深度学习图像增强感兴趣的读者。
摘要由CSDN通过智能技术生成

% =========================================================================

% Test code for Super-Resolution Convolutional Neural Networks (SRCNN)

%

% Reference

% Chao Dong, Chen Change Loy, Kaiming He, Xiaoou Tang. Learning a Deep Convolutional Network for Image Super-Resolution,

% in Proceedings of European Conference on Computer Vision (ECCV), 2014

%

% Chao Dong, Chen Change Loy, Kaiming He, Xiaoou Tang. Image Super-Resolution Using Deep Convolutional Networks,

% arXiv:1501.00092

%

% Chao Dong

% IE Department, The Chinese University of Hong Kong

% For any question, send email to ndc.forward@gmail.com

% =========================================================================

close all;

clear all;

%% read ground truth image读入图片

im = imread('Set5/butterfly_GT.bmp');

%im = imread('Set14\zebra.bmp');

%% set parameters设置SRCNN的每一层的参数,已经训练好了的

%up_scale = 3;

%model = 'model/9-5-5(ImageNet)/x3.mat';

%up_scale = 3;

%model = 'model/9-3-5(ImageNet)/x3.mat';

%up_scale = 3;

%model = 'model/9-1-5(91 images)/x3.mat';

%up_scale = 2;

%model = 'model/9-5-5(ImageNet)/x2.mat';

up_scale = 4;

model = 'model/9-5-5(ImageNet)/x4.mat';

%% work on illuminance only把图片转化为YCbCr的,进行对某一层的处理

if size(im,3)>1%计算第三层的大小

im = rgb2ycbcr(im);

im = im(:, :, 1)

;这个地方把im转换为第三维的为一,其他的都全部的有什么用??

end剪裁

将图片裁剪为能够调整的大小(与放大率匹配)。裁剪舍掉余数行和列。

im_gnd= modcrop(im, up_scale);

im_gnd = single(im_gnd)/255;

%% bicubic interpolation

im_l = imresize(im_gnd, 1/up_scale, 'bicubic');

im_b = imresize(im_l, up_scale, 'bicubic');

%% SRCNN

im_h = SRCNN(model, im_b);

%% remove border去除边缘

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]);

%% compute PSNR

psnr_bic = compute_psnr(im_gnd,im_b);

psnr_srcnn = compute_psnr(im_gnd,im_h);

%% show results

fprintf('PSNR for Bicubic Interpolation: %f dB\n', psnr_bic);

fprintf('PSNR for SRCNN Reconstruction: %f dB\n', psnr_srcnn);

figure, imshow(im_b); title('Bicubic Interpolation');

figure, imshow(im_h); title('SRCNN Reconstruction');

%imwrite(im_b, ['Bicubic Interpolation' '.bmp']);

%imwrite(im_h, ['SRCNN Reconstruction' '.bmp']);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值