zoukankan      html  css  js  c++  java
  • 形态学滤波

      最烦的事情莫过于每年的遥感图像处理软件的测评了,这个月逃不掉了,只好坐软件开发方面的工作,其实我自己好喜欢研究算法而不是成熟算法的实现。今天下午和晚上实现了二值和灰度图象的形态学滤波算法的实现。 其中二值图像部分暂且用MATLAB实现的,灰度图部分采用了C#。
          文献参考:
       (1)数字图像处理(MATLAB版)
       (2)http://www.codeproject.com/cs/media/Image_Processing_Lab.asp
          实现的很丑陋,都不好意思贴出来了:(
    function out = mydialate;%(inimg, structure)
    in = imread('binary.tif');
    out = in;
    structure=[ 1 1 1;
        1 1 1;
        1 1 1;];
    [cy,cx]=size(in);
    [sey,sex]=size(structure);
    halfsex =floor(sex/2);
    halfsey =floor(sey/2);
    for row = halfsey+1:(cy-halfsey)
        for col = halfsex+1:(cx-halfsex)
             for indexrow=row-halfsey:row+halfsey
                   for indexcol = col-halfsex:col+halfsex
                       winrow=indexrow-row+halfsey+1;
                       wincol = indexcol-col+halfsex+1;
                       tempwin=structure(winrow,wincol);
                      if in(row,col)==1
                       out(indexrow,indexcol) = or(tempwin,out(indexrow,indexcol)); 
                      end
                   end
             end
        end
    endfunction out = myerosion;%(inimg, structure)
    in = imread('binary.tif');
    out = in;
    structure=[ 1 1 1;
        1 1 1;
        1 1 1;];
    [cy,cx]=size(in);
    [sey,sex]=size(structure);
    halfsex =floor(sex/2);
    halfsey =floor(sey/2);
    for row = halfsey+1:(cy-halfsey)
        for col = halfsex+1:(cx-halfsex)
             for indexrow=row-halfsey:row+halfsey
                   for indexcol = col-halfsex:col+halfsex
                       winrow=indexrow-row+halfsey+1;
                       wincol = indexcol-col+halfsex+1;
                       tempwin=structure(winrow,wincol);
                       if tempwin == 1
                           if in(indexrow,indexcol)==0
                             out(row,col) = 0;
                         end
                      end
                   end
             end
        end
    end

  • 相关阅读:
    CSRF小结
    代码注入小结
    文件上传漏洞小结
    解决Burpsuite_pro_v1.6破解版https证书导入问题
    Java HTTP 组件库选型看这篇就够了
    趣图:我正在演示一个功能,但没有达到预期效果
    阅读源码的利器——Intellij-IDEA-Replace-in-Path-使用技巧
    分享一些好用的 Chrome 插件!
    趣图:程序员发量的变化过程
    Spring循环依赖的三种方式
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/1916906.html
Copyright © 2011-2022 走看看