zoukankan      html  css  js  c++  java
  • 图像阈值

    1 ret,dst=cv2.threshold(src,thresh,maxval,type)

    这是threshold()的参数列表,其中:

    ret——阈值

    dst——输出图

    src——输入图

    thresh——阈值(通常为127,因为亮度范围是0~255)

    maxval——(通常为255)像素值超过(或小于)阈值,所赋值 type决定

    type——(以下例子程序中全部应该大写,为方便打字直接用小写替代)

      1、tresh_binary

         >tresh  =maxval

         <tresh  =0

      2、tresh_binary_inv(inv表示反转)

        >tresh  =0

        <tresh  =maxval

      3、tresh_trunc(截断)  像素点最大值只能是tresh

        >tresh  =tresh

        <tresh  不变

      4、tresh_tozero

        >tresh  不变

        <tresh  =0

      5、tresh_tozero_inv

        >tresh  =0

        <tresh  不变

    像素点的值越大表示越亮,值越小则表示越暗

    主要代码如下:

    1 ret,img1=cv2.threshold(img_cat,127,255,cv2.THRESH_BINARY)
    2 ret,img2=cv2.threshold(img_cat,127,255,cv2.THRESH_BINARY_INV)
    3 ret,img3=cv2.threshold(img_cat,127,255,cv2.THRESH_TRUNC)
    4 ret,img4=cv2.threshold(img_cat,127,255,cv2.THRESH_TOZERO)
    5 ret,img5=cv2.threshold(img_cat,127,255,cv2.THRESH_TOZERO_INV)

    显示结果:

  • 相关阅读:
    Linux Windows平台添加pip源
    Python redis交互
    Redis redis-trib集群配置
    Linux 加阿里yum源
    阿里云yum源镜像
    Android实战——GreenDao3.2的使用,爱不释手
    一个Demo带你彻底掌握View的滑动冲突
    观察者模式简单理解
    Android Studio插件之MVPHelper,一键生成MVP代码
    城市导航列表
  • 原文地址:https://www.cnblogs.com/program-ai-cv-ml-se-fighting/p/11696769.html
Copyright © 2011-2022 走看看