⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.m

📁 这是有关matlab的编程
💻 M
字号:
% MAIN 
% ====

% Load original picture :
%load text;
A=imread('Fig2.22(a).jpg');
% Bluring KERNEL :
kernel=ones(3)./9;

% Regularization kernel LAPLASIAN :
laplasian=[0 -.25 0 ; -.25 1 -.25 ; 0 -.25 0 ]; 

% Create N warped , blured and undersampled images :
% ( Comment to skip CREATE_DATA )
 N=input(' => Enter number of images :');
 ratio=input(' => Enter sampling ratio :');
 ImSize=create_data(A,N,kernel,ratio);
%**************************************************************************
%*****
% By now we have N images and their warping coefficients, saved in files (Y1.mat , Y2.mat .... )
% Creating the initial (guess) SuperResolution image ( 2 options )
load Y1

% X0=interpolate(TEMP,ratio,[ImSize,ImSize]);
 X0=initial_interpolate(TEMP,ratio,[ImSize,ImSize]);  %将低分辨率像素的值赋给高分辨率图像中的每个像素
% X0=zeros(ImSize);
 
K=input(' => Enter number of iterations :');
Lambda=input(' => Enter Regularization coeffitient (LAMBDA) :');

EPS = [];
count=[];

% Performong the Restoration procedure :
% ------------------------------------
[P0,R0]=mask( N,ratio,size(X0) );
%[P0,R0]=mask_new( N,ratio,size(X0));
for j=1:K
 Xtemp=blur(X0,kernel); 	% Now Xtemp is blured X0
 eps = Xtemp;
 Xtemp=Xtemp.*R0 - P0 ;
 Xtemp=blur(Xtemp,kernel);	% Now Xtemp = H'*( R0*H*X0 - P0 )
 
 Xtemp=Xtemp + Lambda*( blur( blur(X0,laplasian),laplasian) );
 
 % Calculating new Mu :
 Mu=new_nsd(R0,Xtemp,kernel,Lambda,laplasian);
  
 % Old and Wrong Epsilon :
 %eps=norm(Xtemp,1)+ Lambda*norm( blur( blur(X0,laplasian),laplasian),1);
 eps=(-2)*sum(sum(eps.*P0))+sum(sum( (eps.^2).*R0))+Lambda*sum(sum( blur( blur(X0,laplasian),laplasian) ));

 X0=X0-Mu.*Xtemp;
 % Another Old and WRONG eps :
 % eps = epsilon_calc(X0,N,kernel,ratio,Lambda,laplasian); 
 
 % Show the current result ( of the current iteration )
 figure;
 imshow(X0,[0,255]);
 fprintf(' ==> Iteration No %d :> eps= %d Mu= %d\n',j,eps,Mu); 
   EPS=[EPS,eps];
   count=[count,j];
end
%figure;
plot(count,EPS);			
   xlabel('Iterations');
   ylabel('Epsilon^2');

%figure;			% Show the LAST image - the RESULT
%imshow(X0,[0,255]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -