• 形态学滤波


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

  • 相关阅读:
    卡牌配对
    SNOI2017 礼物
    【BZOJ2893】征服王
    景中人
    钦点
    杨柳
    兼容IE与firefox、chrome的css 线性渐变(linear-gradient)
    使用C# DES解密java DES加密的字符串
    jQuery插件autoComplete使用
    hadoop SQL使用
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/1916906.html
Copyright © 2020-2023  润新知