• 大小: 1.23MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-02
  • 语言: Matlab
  • 标签: matlab  滤波  遥感  

资源简介

用MATLAB实现梯度倒数加权的滤波算法代码。

资源截图

代码片段和文件信息

a=imread(‘lena.bmp‘);
figure(1);
imshow(a);
a=imnoise(a‘gaussian‘0.005);
figure(2);
imshow(a);
a=double(a);
[depwide]=size(a);
new_image=ones(size(a));

r=0.5;
for i=2:dep-1
    for j=2:wide-1
        g=0;
          for m=-1:1
              for n=-1:1
                  if(a(i+mj+n)-a(ij)==0)
                      g(m+2n+2)=0;
                  else
                      g(m+2n+2)=1/abs(a(i+mj+n)-a(ij));
                  end
              end
          end
          
          G=sum(sum(g));
          for m=-1:1
              for n=-1:1
                  w(m+2n+2)=g(m+2n+2)/G;
              end
          end
          
          new_image(ij)=a(ij)*r+(w(-1+2-1+2)*a(i-1j-1)+w(-1+20+2)*a(i-1j)+w(-1+21+2)*a(i-1j+1)+w(0+2-1+2)*a(ij-1)+w(0+21+2)*a(ij+1)+w(1+2-1+2)*a(i+1j-1)+w(1+20+2)*a(i+1j)+w(1+21+2)*a(i+1j+1))*(1-r);
        
        
    end
end

for i=2:dep-1
    new_image(i1)=new_image(i2);
    new_image(iwide)=new_image(iwide-1);
end

new_image(1:)=new_image(2:);
new_image(dep:)=new_image(dep-1:);

    
    figure(3);
    imshow(uint8(a))
    figure(4);
    imshow(uint8(new_image))
    
    imwrite(uint8(new_image)‘reci_gradu_weighted_0.5.bmp‘‘bmp‘)
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     268254  2008-05-16 16:52  梯度倒数加权\991340203\梯度倒数加权\0.005_reci_gradu_weighted_0.5.bmp

     文件     268254  2008-05-16 16:52  梯度倒数加权\991340203\梯度倒数加权\0.05_reci_gradu_weighted_0.5.bmp

     文件     268254  2008-05-16 16:51  梯度倒数加权\991340203\梯度倒数加权\0.2_reci_gradu_weighted_0.5.bmp

     文件     268254  2008-04-21 09:36  梯度倒数加权\991340203\梯度倒数加权\lena.bmp

     文件       1210  2008-05-16 16:51  梯度倒数加权\991340203\梯度倒数加权\reci_gradu_weighted.asv

     文件       1264  2011-12-02 11:21  梯度倒数加权\991340203\梯度倒数加权\reci_gradu_weighted.m

     文件     268254  2008-05-09 10:25  梯度倒数加权\991340203\梯度倒数加权\reci_gradu_weighted_0.1.bmp

     文件     268254  2011-12-02 11:22  梯度倒数加权\991340203\梯度倒数加权\reci_gradu_weighted_0.5.bmp

     目录          0  2011-12-02 11:15  梯度倒数加权\991340203\梯度倒数加权

     目录          0  2011-12-02 11:15  梯度倒数加权\991340203

     目录          0  2011-12-02 11:33  梯度倒数加权

----------- ---------  ---------- -----  ----

              1612216                    12


评论

共有 条评论