zoukankan      html  css  js  c++  java
  • EmguCV 阈值化

    一、public static double cvThreshold(

          IntPtr src,

          IntPtr dst,

          double threshold,

          double maxValue,    //Maximum value to use with CV_THRESH_BINARY and CV_THRESH_BINARY_INV thresholding types

          Emgu.CV.CvEnum.THRESH thresholdType

      )

      thresholdType有如下几种:

      CV_THRESH_BINARY,表示dsti=(srci>T)?M:0。

      CV_THRESH_BINARY_INV,表示dsti=(srci>T)?0:M。

      CV_THRESH_TRUNC,表示dsti=(srci>T)?M:srci。

      CV_THRESH_TOZERO_INV,表示dsti=(srci>T)?0:srci。

      CV_THRESH_TOZERO,表示dsti=(srci>T)?srci:0。

      下图为不同类型的处理结果,第一副为原图:

         

       CV_THRESH_OTSU: use Otsu algorithm to choose the optimal threshold value; combine the flag with one of the above CV_THRESH_* values

    二、public static void cvAdaptiveThreshold(

          IntPtr src,        //single-channel, 8-bit of 32-bit floating point

          IntPtr dst,

          double maxValue,    //Maximum value to use with CV_THRESH_BINARY and CV_THRESH_BINARY_INV thresholding types

          ADAPTIVE_THRESHOLD_TYPE adaptiveType,  //Adaptive method, CV_ADAPTIVE_THRESH_MEAN_C: indicates that Mean minus C; CV_ADAPTIVE_THRESH_GAUSSIAN_C: indicates that Gaussian minus C

          THRESH thresholdType,  //same with cvThreshold

          int blockSize=3,       //The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, ...

          double param1=5      //Constant subtracted from mean or weighted mean. It may be negative.

      )

      通过计算像素点周围的blockSize*blockSize区域的加权平均,然后减去param1来得到自适应阈值。CV_ADAPTIVE_THRESH_MEAN_C指对区域的所有象素平均加权;CV_ADAPTIVE_THRESH_GAUSSIAN_C指对区域内的像素根据高斯函数按照它们离中心点的距离进行加权计算。

  • 相关阅读:
    angular $modal 模态框
    过滤器 ||(filter)
    info sharp Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
    git error: unable to create file Invalid argument
    bash shell 快捷键
    options has an unknown property 'modifyVars'. These properties are valid: 处理方法
    test 分支强制替换master 分支的办法
    脚本统计代码行数
    git commit 后,没有push ,怎么撤销
    php 用户ip的获取
  • 原文地址:https://www.cnblogs.com/alsofly/p/3524905.html
Copyright © 2011-2022 走看看