文件名称:RemoveBlackConnectedComponents
介绍说明--下载内容来自于网络,使用问题请自行百度
使用opencv去掉二值化图像中黑色面积较小的连通域。
程序中语句 tmparea = fabs(cvContourArea(contour)) 可以得到当前连通域的面积,当此面积小于阈值时对其填充为白色。
rect = cvBoundingRect(contour,0) 得到的是框住连通域的最小矩形,对矩形中的黑色部分将其填充为白色,但是这样的话,连通域6和4两个连通域被填充成了白色的矩形,这显然不符合我们的要求,这样就要判断此连通域是黑色联通域还是白色连通域,采用的方法是测试矩形的中心点,如果其为黑色,则认为此连通域是黑色连通域,否则为白色联通域,对于黑色联通域我们对其进行白色填充处理,对于白色联通域则保持不变。-Using opencv binary image to remove the black connected components smaller.
Program statement tmparea = fabs (cvContourArea (contour)) can get the current connected component of the area, when this area is less than the threshold when it filled with white.
rect = cvBoundingRect (contour, 0) get is a box to live in the smallest rectangle connected domains, part of the black rectangle to fill with white, but this is the case, connected components 6 and 4 are filled into two connected components of white rectangle, which obviously does not meet our requirements, so we must determine if the connected domain is black or white Unicom domain connected domain, the approach is to test the center of the rectangle, if it is black, is that the black connected components connected domain, otherwise the domain of white Unicom, China Unicom for the black white fill field we deal with them, for the white Unicom domain remains unchanged.
程序中语句 tmparea = fabs(cvContourArea(contour)) 可以得到当前连通域的面积,当此面积小于阈值时对其填充为白色。
rect = cvBoundingRect(contour,0) 得到的是框住连通域的最小矩形,对矩形中的黑色部分将其填充为白色,但是这样的话,连通域6和4两个连通域被填充成了白色的矩形,这显然不符合我们的要求,这样就要判断此连通域是黑色联通域还是白色连通域,采用的方法是测试矩形的中心点,如果其为黑色,则认为此连通域是黑色连通域,否则为白色联通域,对于黑色联通域我们对其进行白色填充处理,对于白色联通域则保持不变。-Using opencv binary image to remove the black connected components smaller.
Program statement tmparea = fabs (cvContourArea (contour)) can get the current connected component of the area, when this area is less than the threshold when it filled with white.
rect = cvBoundingRect (contour, 0) get is a box to live in the smallest rectangle connected domains, part of the black rectangle to fill with white, but this is the case, connected components 6 and 4 are filled into two connected components of white rectangle, which obviously does not meet our requirements, so we must determine if the connected domain is black or white Unicom domain connected domain, the approach is to test the center of the rectangle, if it is black, is that the black connected components connected domain, otherwise the domain of white Unicom, China Unicom for the black white fill field we deal with them, for the white Unicom domain remains unchanged.
相关搜索: bg detect opencv
连通域
(系统自动生成,下载前可以参看下载内容)
下载文件列表
使用opencv去掉二值化图像中黑色面积较小的连通域.txt
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.