【图像重建】迭代步长自适应图像超分辨重建【含Matlab源码 048期】

⛄一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【图像重建】基于matlab迭代步长自适应图像超分辨重建【含Matlab源码 048期】
点击上面蓝色字体,直接付费下载,即可。

获取代码方式2:
付费专栏Matlab图像处理(初级版)

备注:
点击上面蓝色字体付费专栏Matlab图像处理(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab图像处理(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:1份本博客上传CSDN资源代码

⛄二、迭代步长自适应简介

传统的超分辨重建算法往往采用梯度下降法进行求解,迭代时步长往往通过经验确定。而且不同的图像的最优步长往往不相同。步长过大会导致发散,步长过小会导致收敛缓慢。本算法基于对正则化超分辨重建算法实现的基础上,对步长的选取进行了优化,推导出了每次迭代时的最优步长大小,并将其自适应化,改进了超分辨算法的收敛性,从而能够在更短的时间内取得更加精确的重建结果。相关具体内容请参考对应的论文:Yingqian Wang, Jungang Yang, Chao Xiao, and Wei An, “Fast convergence strategy for multi-image superresolution via adaptive line search,” IEEE Access, vol. 6, no. 1, pp. 9129-9139.

⛄三、部分源代码

clear all
clc

filename = ‘Set’;
files = dir(fullfile( filename,‘*.bmp’));
file_num = 2; % different number corresponds to defferent test images in ‘Set’
reg_term = 1; %regularization term: 1-BTV, 2-Tikhonov

Image =imread([filename,‘’,files(file_num).name]);
SZ = size(size(Image));

if (SZ(2)==2) % turn grayscale image to RGB image
for qw = 1:3
IMAGE (:,:,qw) = Image;
end
else
IMAGE = Image;
end

%% Image Degradation
D = [1,1;-2,1;-1,-3;3,-2]; % Shearing shift
Gau = fspecial( ‘gaussian’, [3 3], 1); % Gaussian bluring kernel
spf = 2; % sampling factor
sigma2 = 1; % variation of noise
LR = ImDegrate(IMAGE,D,Gau,spf,sigma2); % image degradation function

%% Turn RGB to YCbCr, and only SR the Y component
[~, ~, ~, M] = size(LR);
for w = 1:M
LR(:,:,:,w) = rgb2ycbcr(uint8( squeeze(LR(:,:,:,w))));
end

maxiter = 10; % maximum number of iteration

y1(:,:😅 = LR(:,:,1,:);
y2(:,:😅 = LR(:,:,2,:);
y3(:,:😅 = LR(:,:,3,:);

HRitp1 = imresize(y1(:,:,1), spf, ‘bicubic’); % bicubic interpolation
HRitp1 = ImWarp(HRitp1, -D(1,1), -D(1,2)); % shift recovering

I1 = Wang_SR(HRitp1, y1, D, Gau, spf, maxiter, reg_term); %Our proposed SR method

HRitp2 = imresize(y2(:,:,1), spf, ‘bicubic’);
HRitp2 = ImWarp(HRitp2, -D(1,1), -D(1,2));
I2 = HRitp2;

HRitp3 = imresize(y3(:,:,1), spf, ‘bicubic’);
HRitp3 = ImWarp(HRitp3, -D(1,1), -D(1,2));
I3 = HRitp3;

ImZ(:, :, 1) = I1;
ImZ(:, :, 2) = I2;
ImZ(:, :, 3) = I3;

ImZ = ycbcr2rgb(uint8( ImZ)); % Turn YCbCr to RGB

figure; imshow( uint8( ImZ ) ); title(‘Wang et al.’);
figure; imshow( uint8( IMAGE ) ); title(‘groundtruth’);

%% Evaluation

If = double(ImZ); %output image
Is = double(IMAGE); %reference image
[row,col,~]=size(If);

%RMSE
rmse=0;
for color = 1:3
Ifc = If(:,:,color); Isc = Is(:,:,color);
SSE=sum(sum((Ifc-Isc).^2));
rmsec=sqrt(SSE/(row*col));
rmse = rmse+rmsec/3;
end
rmse

%PSNR
psnr=0;
for color = 1:3
Ifc = If(:,:,color); Isc = Is(:,:,color);
maxIs = max(max(Isc));
minIs = min(min(Isc));
PSNRc = 10log10((rowcol*(maxIs-minIs)2)/sum(sum((Ifc-Isc).2)));
psnr = psnr+PSNRc/3;
end
psnr

%SSIM
ssim=0;
for color = 1:3
Ifc = uint8(If(:,:,color)); Isc = uint8(Is(:,:,color));
ssimc = cal_ssim(Ifc, Isc, 0, 0);
ssim = ssim + ssimc/3;
end
ssim
function ssim = cal_ssim( im1, im2, b_row, b_col)

[h, w, ch] = size( im1 );
ssim = 0;
if (ch == 1)
ssim = ssim_index ( im1(b_row+1:h-b_row, b_col+1:w-b_col), im2(b_row+1:h-b_row,b_col+1:w-b_col));
else
for i = 1:ch
ssim = ssim + ssim_index ( im1(b_row+1:h-b_row, b_col+1:w-b_col, i), im2(b_row+1:h-b_row,b_col+1:w-b_col, i));
end
ssim = ssim/3;
end
return

function [mssim, ssim_map] = ssim_index(img1, img2, K, window, L)

if (nargin < 2 || nargin > 5)
mssim = -Inf;
ssim_map = -Inf;
return;
end

if (size(img1) ~= size(img2))
mssim = -Inf;
ssim_map = -Inf;
return;
end

[M N] = size(img1);

if (nargin == 2)
if ((M < 11) || (N < 11))
mssim = -Inf;
ssim_map = -Inf;
return
end
window = fspecial(‘gaussian’, 11, 1.5); %
K(1) = 0.01; % default settings
K(2) = 0.03; %
L = 255; %
end

if (nargin == 3)
if ((M < 11) || (N < 11))
mssim = -Inf;
ssim_map = -Inf;
return
end
window = fspecial(‘gaussian’, 11, 1.5);
L = 255;
if (length(K) == 2)
if (K(1) < 0 || K(2) < 0)
mssim = -Inf;
ssim_map = -Inf;
return;
end
else
mssim = -Inf;
ssim_map = -Inf;
return;
end
end

if (nargin == 4)
[H W] = size(window);
if ((H*W) < 4 || (H > M) || (W > N))
mssim = -Inf;
ssim_map = -Inf;
return
end
L = 255;
if (length(K) == 2)
if (K(1) < 0 || K(2) < 0)
mssim = -Inf;
ssim_map = -Inf;
return;
end
else
mssim = -Inf;
ssim_map = -Inf;
return;
end
end

if (nargin == 5)
[H W] = size(window);
if ((H*W) < 4 || (H > M) || (W > N))
mssim = -Inf;
ssim_map = -Inf;
return
end
if (length(K) == 2)
if (K(1) < 0 || K(2) < 0)
mssim = -Inf;
ssim_map = -Inf;
return;
end
else
mssim = -Inf;
ssim_map = -Inf;
return;
end
end

img1 = double(img1);
img2 = double(img2);

% automatic downsampling
f = max(1,round(min(M,N)/256));
%downsampling by f
%use a simple low-pass filter
if(f>1)
lpf = ones(f,f);
lpf = lpf/sum(lpf(😃);
img1 = imfilter(img1,lpf,‘symmetric’,‘same’);
img2 = imfilter(img2,lpf,‘symmetric’,‘same’);

img1 = img1(1:f:end,1:f:end);
img2 = img2(1:f:end,1:f:end);

end

C1 = (K(1)*L)^2;
C2 = (K(2)*L)^2;
window = window/sum(sum(window));

mu1 = filter2(window, img1, ‘valid’);
mu2 = filter2(window, img2, ‘valid’);
mu1_sq = mu1.*mu1;
mu2_sq = mu2.*mu2;
mu1_mu2 = mu1.*mu2;
sigma1_sq = filter2(window, img1.*img1, ‘valid’) - mu1_sq;
sigma2_sq = filter2(window, img2.*img2, ‘valid’) - mu2_sq;
sigma12 = filter2(window, img1.*img2, ‘valid’) - mu1_mu2;

if (C1 > 0 && C2 > 0)
ssim_map = ((2mu1_mu2 + C1).(2sigma12 + C2))./((mu1_sq + mu2_sq + C1).(sigma1_sq + sigma2_sq + C2));
else
numerator1 = 2mu1_mu2 + C1;
numerator2 = 2
sigma12 + C2;
denominator1 = mu1_sq + mu2_sq + C1;
denominator2 = sigma1_sq + sigma2_sq + C2;
ssim_map = ones(size(mu1));
index = (denominator1.*denominator2 > 0);
ssim_map(index) = (numerator1(index).*numerator2(index))./(denominator1(index).*denominator2(index));
index = (denominator1 ~= 0) & (denominator2 == 0);
ssim_map(index) = numerator1(index)./denominator1(index);
end

mssim = mean2(ssim_map);

return

⛄四、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

⛄五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.

3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除

  • 18
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab领域

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值