分别属于cv2 和 skimage连个库
先来看函数的源代码的解释:

def find_contours(array, level,fully_connected='low', positive_orientation='low'):"""Find iso-valued contours in a 2D array for a given level value.Uses the "marching squares" method to compute a the iso-valued contours ofthe input 2D array for a particular level value. Array values are linearlyinterpolated to provide better precision for the output contours.Parameters----------array : 2D ndarray of doubleInput data in which to find contours.level : floatValue along which to find contours in the array.fully_connected : str, {'low', 'high'}Indicates whether array elements below the given level value are to beconsidered fully-connected (and hence elements above the value willonly be face connected), or vice-versa. (See notes below for details.)positive_orientation : either 'low' or 'high'Indicates whether the output contours will produce positively-orientedpolygons around islands of low- or high-valued elements. If 'low' thencontours will wind counter- clockwise around elements below theiso-value. Alternately, this means that low-valued elements are alwayson the left of the contour. (See below for details.)Returns-------contours : list of (n,2)-ndarraysEach contour is an ndarray of shape ``(n, 2)``,consisting of n ``(row, column)`` coordinates along the contour.Notes-----The marching squares algorithm is a special case of the marching cubesalgorithm [1]_.  A simple explanation is available here::http://www.essi.fr/~lingrand/MarchingCubes/algo.htmlThere is a single ambiguous case in the marching squares algorithm: whena given ``2 x 2``-element square has two high-valued and two low-valuedelements, each pair diagonally adjacent. (Where high- and low-valued iswith respect to the contour value sought.) In this case, either thehigh-valued elements can be 'connected together' via a thin isthmus thatseparates the low-valued elements, or vice-versa. When elements areconnected together across a diagonal, they are considered 'fullyconnected' (also known as 'face+vertex-connected' or '8-connected'). Onlyhigh-valued or low-valued elements can be fully-connected, the other setwill be considered as 'face-connected' or '4-connected'. By default,low-valued elements are considered fully-connected; this can be alteredwith the 'fully_connected' parameter.Output contours are not guaranteed to be closed: contours which intersectthe array edge will be left open. All other contours will be closed. (Theclosed-ness of a contours can be tested by checking whether the beginningpoint is the same as the end point.)Contours are oriented. By default, array values lower than the contourvalue are to the left of the contour and values greater than the contourvalue are to the right. This means that contours will windcounter-clockwise (i.e. in 'positive orientation') around islands oflow-valued pixels. This behavior can be altered with the'positive_orientation' parameter.The order of the contours in the output list is determined by the positionof the smallest ``x,y`` (in lexicographical order) coordinate in thecontour.  This is a side-effect of how the input array is traversed, butcan be relied upon... warning::Array coordinates/values are assumed to refer to the *center* of thearray element. Take a simple example input: ``[0, 1]``. The interpolatedposition of 0.5 in this array is midway between the 0-element (at``x=0``) and the 1-element (at ``x=1``), and thus would fall at``x=0.5``.This means that to find reasonable contours, it is best to find contoursmidway between the expected "light" and "dark" values. In particular,given a binarized array, *do not* choose to find contours at the low orhigh value of the array. This will often yield degenerate contours,especially around structures that are a single array element wide. Insteadchoose a middle value, as above.References----------.. [1] Lorensen, William and Harvey E. Cline. Marching Cubes: A HighResolution 3D Surface Construction Algorithm. Computer Graphics(SIGGRAPH 87 Proceedings) 21(4) July 1987, p. 163-170).Examples-------->>> a = np.zeros((3, 3))>>> a[0, 0] = 1>>> aarray([[ 1.,  0.,  0.],[ 0.,  0.,  0.],[ 0.,  0.,  0.]])>>> find_contours(a, 0.5)[array([[ 0. ,  0.5],[ 0.5,  0. ]])]"""

参数介绍:

这个讲的好

  • array:这就是要输入的照片,,直接cv2.imread(name,0)读进来就能用。0的意思是读成灰度图

  • level:直译就是水平,当我用0.5的时候能探测出几百个,当我用1的时候有几十个,当我用10的时候有4个,100的时候只有两个。
    一个颜色就是一个结果,越来越少对不对,

  • fully_connected:只能选low和high,这个参数解释的有点复杂,这个图是上面那个参数为1的时候,有好多的,当为high的时候检查出来的多一些,当为low的时候,斜着的挨着进的那些更容易合并到一起,建议用low,low就是默认的。可以不管这一项。

    low:
    high:

  • positive_orientation 这个应该没啥用,我也不知道。。求教


def findContours(image, mode, method):

这个cv2中的这个对函数的解释,就是没在这解释,

  • image这个参数上面的第一个参数一样,单通道图像矩阵,可以是灰度图,但更常用的是二值图像,一般是经过Canny、拉普拉斯等边缘检测算子处理过的二值图像

  • mode:定义轮廓的检索模式:
    CV_RETR_EXTERNAL:只检测最外围轮廓,包含在外围轮廓内的内围轮廓被忽。
    CV_RETR_LIST :检测所有的轮廓,包括内围、外围轮廓,但是检测到的轮廓不建立等级关系,彼此之间独立,没有等级关系,这就意味着这个检索模式下不存在父轮廓或内嵌轮廓, 所以hierarchy向量内所有元素的第3、第4个分量都会被置为-1。
    CV_RETR_CCOMP :检测所有的轮廓,但所有轮廓只建立两个等级关系,外围为顶层,若外围 内的内围轮廓还包含了其他的轮廓信息,则内围内的所有轮廓均归属于顶层 。
    CV_RETR_TREE: 检测所有轮廓,所有轮廓建立一个等级树结构。外层轮廓包含内层轮廓,内
    层轮廓还可以继续包含内嵌轮廓。

    RETR_LIST 从解释的角度来看,这中应是最简单的。它只是提取所有的轮廓,而不去创建任何父子关系。
    RETR_EXTERNAL 如果你选择这种模式的话,只会返回最外边的的轮廓,所有的子轮廓都会被忽略掉。
    RETR_CCOMP 在这种模式下会返回所有的轮廓并将轮廓分为两级组织结构。
    RETR_TREE 这种模式下会返回所有轮廓,并且创建一个完整的组织结构列表。它甚至会告诉你谁是爷爷,爸爸,儿子,孙子等

  • method:
    CV_CHAIN_APPROX_NONE:保存物体边界上所有连续的轮廓点到contours向量内
    CV_CHAIN_APPROX_SIMPLE :仅保存轮廓的拐点信息,把所有轮廓拐点处的点保存入contours 向量内,拐点与拐点之间直线段上的信息点不予保留
    CV_CHAIN_APPROX_TC89_L1,CV_CHAIN_APPROX_TC89_KCOS:使用teh-Chinl chain 近 似算法

cv2.findContours 和 measure.find_contours 找轮廓相关推荐

  1. opencv二值化找轮廓检测背景简单小物体

    一.前言 本篇主要是针对背景简单,且具有固定颜色的单类小物体,方法为在灰度化时选用图片的HSV中的S通道,再使用opencv 二值化找轮廓大法可将小物体框出. 原理很简单,图片->取S通道灰度化 ...

  2. 计算机视觉开源库OpenCV之查找轮廓函数cv2.findContours()介绍

    计算机视觉开源库OpenCV之查找轮廓函数cv2.findContours说明如下: 示例代码: #!/usr/bin/env python3import cv2image = cv2.imread( ...

  3. cv2.findContours OpenCV图形轮廓函数python

    contours, hierarchy = cv2.findContours(img, mode=cv2.RETR_EXTERNAL,                                  ...

  4. 利用圆圈轮廓面积求取圆环半径:cv2.findContours, contourArea

    简 介: 利用圆环的面积反向计算圆的半径,可以获得更加稳定的圆的半径.对于标准模板在扫描仪上的移动,可以看到对应的测量得到的结果变化规律.下面对于造成这样变化进行初步分析. 关键词: 抑菌圈测量仪,O ...

  5. python-opencv2利用cv2.findContours()函数来查找检测物体的轮廓

    轮廓检测 轮廓检测也是图像处理中经常用到的.OpenCV-Python接口中使用cv2.findContours()函数来查找检测物体的轮廓. 实现 使用方式如下: import cv2   img ...

  6. cv2.findContours

    opencv - python 使用findContours时报错 image, contours, hierarchy = cv2.findContours(blue_gray, cv2.RETR_ ...

  7. cv2.cv2.findContours opencv-python

    cv2.findContours用于轮廓检测,其输入为二值图像 输入: 有三个输入参数:输入图像(二值图像),轮廓检索方式,轮廓近似方法 轮廓检索方式 mode 含义 cv2.RETR_EXTERNA ...

  8. python 使用opencv找轮廓

    def find_counts(subtracted_img,img, cross_s_text, border_coord, ratio):# height, width = img.shape[: ...

  9. Python OpenCV——函数 cv2.findContours 运行错误【in function ‘cv::pointSetBoundingRect‘】解决方案

    问题描述 cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-r2ue8w6k\opencv\m ...

最新文章

  1. 关于R和Python的安全机制
  2. 闲话WPF之七(XAML的向前兼容性)
  3. zoj 3707 Calculate Prime S
  4. C++ override 关键字用法
  5. 365锦鲤助手 砍价小程序源码 流量主引流裂变
  6. 异常的产生与传递 java
  7. 代码控制树视图 c# 1614262980
  8. 用mendeley在word中插入文献_Mendeley教程-参考文献引用(论文撰写必备!)
  9. 洛谷 1485 火枪打怪
  10. java awt run_JAVA教程 第五讲 AWT图形用户界面设计(一)
  11. 网上出现反绿坝网站,邀请网友签名以抵制绿坝
  12. 51nod 巧克力 1429
  13. 【文科生带你读JavaScript数据结构与算法】2. 双向链表与LRU缓存算法原理与实现(下)
  14. 魔兽电影这么火,做成游戏一定很多人玩吧
  15. C++ 雇员信息保存及查询
  16. 哈工大视听觉信号处理——听觉部分报告——一种智能家居命令词识别系统的设计
  17. 白杨SEO:做个世界杯公众号怎么样?以2022年卡塔尔世界杯来做微信搜一搜的SEO流量实战举例
  18. java timestamp 使用_Java中针对Timestamp的操作解析
  19. Raft和Paxos简易漫画理解
  20. Nico靠接外包,6个月当了老板,这操作绝了...

热门文章

  1. 幽灵行动荒野服务器位置,幽灵行动荒野找出主数据库服务器
  2. php 获取锚文本,php文章内容制作锚文本链接_PHP实现自动锚文本管理
  3. 修改PPT输出图片的DPI值(分辨率)
  4. 阅读笑话及搞笑图片的app
  5. cmd 如何更改IP
  6. 阿里云esc服务器绑定域名及阿里云域名备案简单流程
  7. 从零开始学USB(七、端点、管道、接口、配置、设备)
  8. JavaScript案例——打地鼠游戏及其实现
  9. 索尼音乐应用android,Sony Music Center
  10. 操作系统学习笔记:第1章 计算机系统概述