📄 uplusg_gaussianitytest.m
字号:
clear;
clc;
%确定局部区域大小: (2*offset+1)*(2*offset+1)
offset=1;
[x,map]=imread('img_in.bmp');
subplot(3,4,5);
image(x);
title('原图像');
colormap(map);
x=double(x);
[ny,nx]=size(x);
y=zeros(ny,nx);
if (offset==1)
%Uniform kernel 3*3
wcoef=ones(3)/9;
else
%Uniform kernel 7*7
wcoef=ones(7)/49;
end
%用Uniform Kernel 进行背景抑制
for i=1:(ny-2*offset)
for j=1:(nx-2*offset)
arr=x(i:(2*offset+1)+i-1,j:(2*offset+1)+j-1);
weightedsum=sum(sum(arr.*wcoef));
yn(i,j)= arr(1,1)-weightedsum;
yb(i,j)= weightedsum;
if (j==nx-2*offset)
for k=1:2*offset
yn(i,j+k)= arr(1,k)-weightedsum;
yb(i,j+k)= weightedsum;
end
end
if (i==ny-2*offset)
for k=1:2*offset
yn(i+k,j)= arr(k,1)-weightedsum;
yb(i+k,j)= weightedsum;
end
end
if (j==nx-2*offset)&(i==ny-2*offset)
for k=1:2*offset
for l=1:2*offset
yn(i+k,j+l)= arr(k,l)-weightedsum;
yb(i+k,j+l)= weightedsum;
end
end
end
end
end
%显示估计及残留噪声
ax=subplot(3,4,2);
image(uint8(yb));
title('局部Uniform加权回归估计');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
ax=subplot(3,4,3);
image(uint8(yn));
title('残留噪声');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
%从残留图像中选取大小为100*100的像素块,对其进行高斯性检验,并显示结果
yn=yn(ny/2:(ny/2+99),nx/2:(nx/2+99));
ax=subplot(3,4,4);
[tstar,meanval]=kendallrankcorr(yn(20:40,60:70));
%变量初始化
y=zeros(ny,nx);
yn=zeros(ny,nx);
yb=zeros(ny,nx);
if (offset==1)
%UniformplusGabor kernel 3*3
wcoef=((ones(3)/9) +[0.2820,0.1904,0.0586;0.1904,0.1286,0.0396;0.0586,0.0396,0.0122])/2;
else
%UniformplusGabor 7*7
w=[0.0491, 0.0470, 0.0412, 0.0331, 0.0244, 0.0165, 0.0102;
0.0470, 0.0450, 0.0394, 0.0317, 0.0234, 0.0158, 0.0098;
0.0412, 0.0394, 0.0346, 0.0278, 0.0205, 0.0138, 0.0086;
0.0331, 0.0317, 0.0278, 0.0224, 0.0165, 0.0111, 0.0069;
0.0244, 0.0234, 0.0205, 0.0165, 0.0121, 0.0082, 0.0055;
0.0165, 0.0158, 0.0138, 0.0111, 0.0082, 0.0055, 0.0034;
0.0102, 0.0098, 0.0086, 0.0069, 0.0051, 0.0034, 0.0021];
wcoef=(ones(7)/49)+w;
wcoef=wcoef/2;
end
%用UniformplusGabor Kernel 进行背景抑制
for i=1:(ny-2*offset)
for j=1:(nx-2*offset)
arr=x(i:(2*offset+1)+i-1,j:(2*offset+1)+j-1);
weightedsum=sum(sum(arr.*wcoef));
yn(i,j)= arr(1,1)-weightedsum;
yb(i,j)= weightedsum;
if (j==nx-2*offset)
for k=1:2*offset
yn(i,j+k)= arr(1,k)-weightedsum;
yb(i,j+k)= weightedsum;
end
end
if (i==ny-2*offset)
for k=1:2*offset
yn(i+k,j)= arr(k,1)-weightedsum;
yb(i+k,j)= weightedsum;
end
end
if (j==nx-2*offset)&(i==ny-2*offset)
for k=1:2*offset
for l=1:2*offset
yn(i+k,j+l)= arr(k,l)-weightedsum;
yb(i+k,j+l)= weightedsum;
end
end
end
end
end
%显示估计及残留噪声
ax=subplot(3,4,6);
image(uint8(yb));
title('局部(U+G)加权回归估计');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
ax=subplot(3,4,7);
image(uint8(yn));
title('残留噪声');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
%从残留图像中选取大小为100*100的像素块,对其进行高斯性检验,并显示结果
yn=yn(ny/2:(ny/2+99),nx/2:(nx/2+99));
ax=subplot(3,4,8);
[tstar,meanval]=kendallrankcorr(yn(20:40,60:70));
%变量初始化
y=zeros(ny,nx);
yn=zeros(ny,nx);
yb=zeros(ny,nx);
if (offset==1)
%Gabor kernel 3*3
wcoef=[0.2820,0.1904,0.0586;
0.1904,0.1286,0.0396;
0.0586,0.0396,0.0122];
else
%Gabor kernel 7*7
wcoef=[0.0491, 0.0470, 0.0412, 0.0331, 0.0244, 0.0165, 0.0102;
0.0470, 0.0450, 0.0394, 0.0317, 0.0234, 0.0158, 0.0098;
0.0412, 0.0394, 0.0346, 0.0278, 0.0205, 0.0138, 0.0086;
0.0331, 0.0317, 0.0278, 0.0224, 0.0165, 0.0111, 0.0069;
0.0244, 0.0234, 0.0205, 0.0165, 0.0121, 0.0082, 0.0055;
0.0165, 0.0158, 0.0138, 0.0111, 0.0082, 0.0055, 0.0034;
0.0102, 0.0098, 0.0086, 0.0069, 0.0051, 0.0034, 0.0021];
end
%用Gabor Kernel 进行背景抑制
for i=1:(ny-2*offset)
for j=1:(nx-2*offset)
arr=x(i:(2*offset+1)+i-1,j:(2*offset+1)+j-1);
weightedsum=sum(sum(arr.*wcoef));
yn(i,j)= arr(1,1)-weightedsum;
yb(i,j)= weightedsum;
if (j==nx-2*offset)
for k=1:2*offset
yn(i,j+k)= arr(1,k)-weightedsum;
yb(i,j+k)= weightedsum;
end
end
if (i==ny-2*offset)
for k=1:2*offset
yn(i+k,j)= arr(k,1)-weightedsum;
yb(i+k,j)= weightedsum;
end
end
if (j==nx-2*offset)&(i==ny-2*offset)
for k=1:2*offset
for l=1:2*offset
yn(i+k,j+l)= arr(k,l)-weightedsum;
yb(i+k,j+l)= weightedsum;
end
end
end
end
end
%显示估计结果及残留噪声
ax=subplot(3,4,10);
image(uint8(yb));
title('局部Gabor加权回归估计');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
ax=subplot(3,4,11);
image(uint8(yn));
title('残留噪声');
colormap(map);
set(ax,'Xtick',[],'Xticklabel',[],...
'Ytick',[],'Yticklabel',[]);
%从残留图像中选取大小为100*100的像素块,对其进行高斯性检验,并显示结果
yn=yn((ny/2):((ny/2)+99),(nx/2):((nx/2)+99));
ax=subplot(3,4,12);
[tstar,meanval]=kendallrankcorr(yn(20:40,60:70));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -