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

  • 相关阅读:
    oracle数据库连接不上
    Oracle的regexp_instr函数简单用法
    Oracle中dbms_random.string 的用法
    oracle 简单输出语句与赋值
    oracle中sequence(自增序号)的用法
    oracle 函数的返回值与out参数
    SQL%ROWCOUNT作用
    100多个基础常用JS函数和语法集合大全
    题解【AcWing272】最长公共上升子序列
    题解【POJ1062】昂贵的聘礼
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/1916906.html
Copyright © 2011-2022 走看看