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

📄 kernelsandgaussiantest.m

📁 加权核函数的静态杂波抑制效果以及残留噪声的高斯性和独立性检验实验结果演示程序。 另外
💻 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)
    %Epanechnikov kernel 3*3
    wcoef=[0.1899,0.1671,0.0962;0.1671,0.1418,0.0709;0.0962,0.0709,0];
else
    %Epanechnikov kernel 7*7
    wcoef=[0.0322,0.0318,0.0305,0.0284,0.0249,0.0210,0.0163;
           0.0318,0.0314,0.0301,0.0279,0.0245,0.0206,0.0159;
           0.0305,0.0301,0.0288,0.0266,0.0232,0.0193,0.0142;
           0.0284,0.0279,0.0266,0.0241,0.0210,0.0168,0.0103;
           0.0249,0.0245,0.0232,0.0210,0.0180,0.0137,0.0073;
           0.0210,0.0206,0.0193,0.0168,0.0137,0.0099,0.0034;
           0.0163,0.0159,0.0142,0.0103,0.0073,0.0034,0];
end
%用Epanechnikov 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('局部Epanechnikov加权回归估计');
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 + -