X=imread('lena128.bmp');
iterative_number=500;
t1=clock;
photo=zeros(128,128);
%%%循环1%%%
image=X(1:64,1:64);
[M,N]=size(image);
K_thmin=0;
%K_thmax=max(M,N)-1;
K_thmax=179;
K_umin=0;
K_umax=M;
K_vmin=0;
K_vmax=N;
K_sxmin=0;
K_sxmax=round(log2(M));
K_symin=0;
K_symax=round(log2(N));
image_reconstruct=zeros(M,N);
image_r=image;
%image_reconstruct=(1/(M*N))*sum(sum(image));
%image_r=image-image_reconstruct;
result=zeros(6,iterative_number);
for n=1:iterative_number
[proj,u_re,v_re,sx_re,sy_re,K_re]=GAS(image_r,M,N,K_thmin,K_thmax,K_umin,K_umax,K_vmin,K_vmax,K_sxmin,K_sxmax,K_symin,K_symax);
result(1,n)=proj;
result(2,n)=u_re;
result(3,n)=v_re;
result(4,n)=sx_re;
result(5,n)=sy_re;
result(6,n)=K_re;
if(sx_re<M/10&&sy_re<N/10)
sx_left=u_re-2*sx_re;
sy_left=v_re-2*sy_re;
sx_right=u_re+2*sx_re;
sy_right=v_re+2*sy_re;
if(sx_left<1)
sx_left=1;
end
if(sy_left<1)
sy_left=1;
end
if(sx_right>M)
sx_right=M;
end
if(sy_right>N)
sy_right=N;
end
g=zeros(M,N);
for X=sx_left-1:sx_right-1
for Y=sy_left-1:sy_right-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
g(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
elseif (sx_re>M/4&&sy_re>N/4)
sx_re=sx_re/2;
sy_re=sy_re/2;
for X=0:M-1
for Y=0:N-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
gr(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
x=0:N-1;
y=0:M-1;
xi=0:.5:N-1;
yi=0:.5:M-1;
[XI YI]=meshgrid(xi,yi);
z=interp2(x,y,gr,XI,YI);
g=z((M/2+1):(3*M/2),(N/2+1):(3*N/2));
else
for X=0:M-1
for Y=0:N-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
g(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
end
g=g./sqrt(sum(sum(g.*g)));
image_reconstruct=image_reconstruct+proj*g;
image_r=double(image_r)-proj*g;
n;
end
%X=imread('lena128.bmp');
%imshow(X);
%figure;
I1=mat2gray(image_reconstruct);
%imshow(I1);
photo(1:64,1:64)=I1;
%%%循环2%%%
X=imread('lena128.bmp');
image=X(65:128,1:64);
[M,N]=size(image);
K_thmin=0;
%K_thmax=max(M,N)-1;
K_thmax=179;
K_umin=0;
K_umax=M;
K_vmin=0;
K_vmax=N;
K_sxmin=0;
K_sxmax=round(log2(M));
K_symin=0;
K_symax=round(log2(N));
image_reconstruct=zeros(M,N);
image_r=image;
%image_reconstruct=(1/(M*N))*sum(sum(image));
%image_r=image-image_reconstruct;
result=zeros(6,iterative_number);
for n=1:iterative_number
[proj,u_re,v_re,sx_re,sy_re,K_re]=GAS(image_r,M,N,K_thmin,K_thmax,K_umin,K_umax,K_vmin,K_vmax,K_sxmin,K_sxmax,K_symin,K_symax);
result(1,n)=proj;
result(2,n)=u_re;
result(3,n)=v_re;
result(4,n)=sx_re;
result(5,n)=sy_re;
result(6,n)=K_re;
if(sx_re<M/10&&sy_re<N/10)
sx_left=u_re-2*sx_re;
sy_left=v_re-2*sy_re;
sx_right=u_re+2*sx_re;
sy_right=v_re+2*sy_re;
if(sx_left<1)
sx_left=1;
end
if(sy_left<1)
sy_left=1;
end
if(sx_right>M)
sx_right=M;
end
if(sy_right>N)
sy_right=N;
end
g=zeros(M,N);
for X=sx_left-1:sx_right-1
for Y=sy_left-1:sy_right-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
g(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
elseif (sx_re>M/4&&sy_re>N/4)
sx_re=sx_re/2;
sy_re=sy_re/2;
for X=0:M-1
for Y=0:N-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
gr(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
x=0:N-1;
y=0:M-1;
xi=0:.5:N-1;
yi=0:.5:M-1;
[XI YI]=meshgrid(xi,yi);
z=interp2(x,y,gr,XI,YI);
g=z((M/2+1):(3*M/2),(N/2+1):(3*N/2));
else
for X=0:M-1
for Y=0:N-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
g(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
end
g=g./sqrt(sum(sum(g.*g)));
image_reconstruct=image_reconstruct+proj*g;
image_r=double(image_r)-proj*g;
n;
end
X=imread('lena128.bmp');
%image=X(1:128,1:128);
%I1=mat2gray(image);
%imshow(I1);
%imshow(X);
%figure;
I2=mat2gray(image_reconstruct);
photo(65:128,1:64)=I2;
%%%循环3%%%
X=imread('lena128.bmp');
image=X(1:64,65:128);
[M,N]=size(image);
K_thmin=0;
%K_thmax=max(M,N)-1;
K_thmax=179;
K_umin=0;
K_umax=M;
K_vmin=0;
K_vmax=N;
K_sxmin=0;
K_sxmax=round(log2(M));
K_symin=0;
K_symax=round(log2(N));
image_reconstruct=zeros(M,N);
image_r=image;
%image_reconstruct=(1/(M*N))*sum(sum(image));
%image_r=image-image_reconstruct;
result=zeros(6,iterative_number);
for n=1:iterative_number
[proj,u_re,v_re,sx_re,sy_re,K_re]=GAS(image_r,M,N,K_thmin,K_thmax,K_umin,K_umax,K_vmin,K_vmax,K_sxmin,K_sxmax,K_symin,K_symax);
result(1,n)=proj;
result(2,n)=u_re;
result(3,n)=v_re;
result(4,n)=sx_re;
result(5,n)=sy_re;
result(6,n)=K_re;
if(sx_re<M/10&&sy_re<N/10)
sx_left=u_re-2*sx_re;
sy_left=v_re-2*sy_re;
sx_right=u_re+2*sx_re;
sy_right=v_re+2*sy_re;
if(sx_left<1)
sx_left=1;
end
if(sy_left<1)
sy_left=1;
end
if(sx_right>M)
sx_right=M;
end
if(sy_right>N)
sy_right=N;
end
g=zeros(M,N);
for X=sx_left-1:sx_right-1
for Y=sy_left-1:sy_right-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
g(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
elseif (sx_re>M/4&&sy_re>N/4)
sx_re=sx_re/2;
sy_re=sy_re/2;
for X=0:M-1
for Y=0:N-1
x=(X-u_re)/sx_re;
y=(Y-v_re)/sy_re;
XY=[cos(K_re) sin(K_re);-sin(K_re) cos(K_re)]*[x y]';
xx=XY(1);
yy=XY(2);
gr(X+1,Y+1)=(4*(xx^2)-2)*exp(-(xx^2+yy^2));
end
end
x=0:N-1;
y=0:M-1;
5162FINAL.rar_matlab 去噪_图像 阈值去噪
版权申诉
117 浏览量
2022-07-15
15:50:17
上传
评论
收藏 5.39MB RAR 举报
御道御小黑
- 粉丝: 61
- 资源: 1万+
最新资源
- 88-520告白(520气球).zip
- HTML+CSS+JS精品网页模板H126.rar
- n.cpp
- jdk-8u411-windows-x64下载安装可用
- vgg模型-图像分类算法对水果识别-不含数据集图片-含逐行注释和说明文档.zip
- KMP算法(Knuth-Morris-Pratt算法
- vgg模型-python语言pytorch框架训练识别化妆品分类-不含数据集图片-含逐行注释和说明文档.zip
- KMP算法(Knuth-Morris-Pratt算法
- shufflenet模型-基于人工智能的卷积网络训练识别狗的表情-不含数据集图片-含逐行注释和说明文档.zip
- EPIC Fantasy Town 1.0
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0