[英]How to grow bright pixels in grey region? OpenCV C++
My answer is somewhat less helpful than my usual efforts, but it is hard to get up enthusiasm for questions with so little effort... 我的回答比平时的努力没有多大帮助,但是很难用这么少的努力来激发问题的热情。
You can solve your issue by using OpenCV findContours()
- documentation here . 您可以通过使用OpenCV的解决您的问题
findContours()
的文档- 在这里 。 You will need to be sure to use the retrieval mode CV_RETR_TREE
. 您将需要确保使用检索模式
CV_RETR_TREE
。
You then need to write a loop, iterating through all the contours found. 然后,您需要编写一个循环,遍历找到的所有轮廓。 In the loop, you need to look for a contour that:
在循环中,您需要寻找一个轮廓:
white
and, white
并且 grey
. grey
。 There is a decent explanation of how the hierarchy works here . 关于层次结构的工作原理, 这里有一个不错的解释。
Mat im = imread("ask.png", 0);
Mat mat;
mat = im==255;
findContours( mat, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
for( size_t i = 0; i< contours.size(); i++ )
{
floodFill(mat, contours[i].at(0), 255, 0, Scalar(128), Scalar(255), FLOODFILL_FIXED_RANGE);
}
mat = mat==255; // output image
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.