• 形态学滤波


      最烦的事情莫过于每年的遥感图像处理软件的测评了,这个月逃不掉了,只好坐软件开发方面的工作,其实我自己好喜欢研究算法而不是成熟算法的实现。今天下午和晚上实现了二值和灰度图象的形态学滤波算法的实现。 其中二值图像部分暂且用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

  • 相关阅读:
    sql server 2008 r2安装详解 (转)
    SQL SERVER 与ORACLE常用函数比较(转)
    android色码对照表
    java小结
    如何查看android虚拟机的目录及文件
    java中的Serializable接口的作用
    android布局属性详解
    android 如何连接sqlserver数据库
    android 中Network error IOException: failed to connect to /127.0.0.1 (port 1433): connect failed: ECONNREFUSED (Connection refused)
    IDEA 将项目打包war包
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/1916906.html
Copyright © 2020-2023  润新知