//形态学腐蚀
cvErode(pDstImage,pDstImage,,);
//形态学膨胀
cvDilate(pDstImage,pDstImage,,);
//中值滤波
cvSmooth(pDstImage,pDstImage, CV_MEDIAN);//默认窗口大小为3*3
cvShowImage("vei",pDstImage);
if(pNum == )
storage = cvCreateMemStorage();
contours = NULL;
//找出轮廓保存到countours中
cvFindContours(pDstImage, storage, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); bitmap->Canvas->BeginScene(); //bitmap开始显示 //从轮廓中取出外接矩形
cv::Rect r1;
double minArea = ;
std::vector<cv::Rect >curMan,preMan;
//从轮廓中取出外接矩形
while(contours)
{
r1 = cvBoundingRect(contours,);
double tmparea = fabs(cvContourArea(contours));
contours = contours->h_next;
if(tmparea<minArea)continue;
preMan.push_back(r1);
cvRectangleR(pDstImage,r1,CV_RGB(,,),); }
cvShowImage("vi",pDstImage);
//取出嵌套的多余矩形
for(size_t i=; i<preMan.size(); i++)
{
cv::Rect r1=preMan[i];
size_t j= ;
for(; j<preMan.size();j++)
{
if(i!=j && (r1&preMan[j])==r1)
{
break;
}
}
if(j == preMan.size())
{
curMan.push_back(r1);
}
}

Opencv,腐蚀,膨胀,轮廓检测,轮廓外接多边形的更多相关文章

  1. 机器学习进阶-图像金字塔与轮廓检测-轮廓检测 1.cv2.cvtColor(图像颜色转换) 2.cv2.findContours(找出图像的轮廓) 3.cv2.drawContours(画出图像轮廓) 4.cv2.contourArea(轮廓面积) 5.cv2.arcLength(轮廓周长) 6.cv2.aprroxPloyDP(获得轮廓近似) 7.cv2.boudingrect(外接圆)..

    1. cv2.cvtcolor(img, cv2.COLOR_BGR2GRAY) # 将彩色图转换为灰度图 参数说明: img表示输入的图片, cv2.COLOR_BGR2GRAY表示颜色的变换形式 ...

  2. OpenCV 腐蚀膨胀操作

    利用腐蚀膨胀操作实现对椭圆周围线条的消除,椭圆的大小不变 代码如下: #include "cv.h" #include "highgui.h" int main ...

  3. 轮廓检测论文解读 | 整体嵌套边缘检测HED | CVPR | 2015

    主题列表:juejin, github, smartblue, cyanosis, channing-cyan, fancy, hydrogen, condensed-night-purple, gr ...

  4. OpenCV图像轮廓检测

    轮廓检测: 轮廓检测的原理通俗的说就是掏空内部点,比如原图中有3*3的矩形点.那么就可以将中间的那一点去掉. 一.关键函数1.1  cvFindContours函数功能:对图像进行轮廓检测,这个函数将 ...

  5. OpenCV 闭合轮廓检测

    这个好像是骨头什么的,但是要求轮廓闭合,于是对图片进行一下膨胀操作,再次检测轮廓就好了. // A closed contour.cpp : 定义控制台应用程序的入口点. // #include &q ...

  6. OpenCV—Python 轮廓检测 绘出矩形框(findContours\ boundingRect\rectangle

    千万注意opencv的轮廓检测和边缘检测是两码事 本文链接:https://blog.csdn.net/wsp_1138886114/article/details/82945328 1 获取轮廓 O ...

  7. OpenCV 轮廓检测

    使用OpenCV可以对图像的轮廓进行检测.这是之前用过的代码,挺简单的,回顾一下.主要要进行以下2步操作: 1.cvThreshold():对图像进行二值化处理 2.cvFindContours(): ...

  8. 【OpenCV函数】轮廓提取;轮廓绘制;轮廓面积;外接矩形

    FindContours 在二值图像中寻找轮廓  int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_cont ...

  9. 第十七节,OpenCV(学习六)图像轮廓检测

    1.检测轮廓 轮廓检测是图像处理中经常用到的,OpenCV-Python接口中使用cv2.findContours()函数查找检测物体的轮廓. cv2.findContours(image, mode ...

随机推荐

  1. ORACLE 错误:oralce record is locked by another user

     方法/步骤     打开PL/SQL客户端,然后修改表记录中的数据,提交修改,如下提示 步骤阅读 2 我们关闭异常警告窗口,在执行sql的窗口中输入如下命令:select t2.username,t ...

  2. 转:netflix推荐系统竞赛

    原文链接:Netflix recommendations: beyond the 5 stars (Part 1), (Part 2) 原文作者:Xavier Amatriain and Justin ...

  3. ubuntu下eclipse遇到The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Ja ...

  4. Android学习笔记——ListView

    该工程的功能是实现在一个activity中显示一个列表 以下代码是MainActivity.java中的代码 package com.example.listview; import java.uti ...

  5. Linux版MonoDevelop无法连接调试器的解决方案(Could not connet to the debugger)

    安装了Linux版本的MonoDevelop之后,在运行程序的时候会提示Could not connnet to the debugger.的错误. 原因是新版本的Gnome Terminal不再接受 ...

  6. GMU 简单使用一

    <!doctype html> <html> <head> <title>iOS7风格的进度条</title> <meta chars ...

  7. 硬盘安装win10

    http://hd.ruanmei.com/

  8. EF DbModelBuilder

    protected override void OnModelCreating(DbModelBuilder modelBuilder) { var model = modelBuilder.Buil ...

  9. URL中“#” “?” &“”号的作用

    URL中"#" "?" &""号的作用   阅读目录 1. # 2. ? 3. & 回到顶部 1. # 10年9月,twit ...

  10. yii2的urlManager配置

    网址伪静态是一个非常常用的网站需求,Yii2可以非常简单地进行配置. 首先,在配置文件config/main.php的'components' 段中,加入如下设置:'urlManager'=>a ...