【发布时间】:2018-02-07 00:08:45
【问题描述】:
我有一组从图像中检测到的轮廓/斑点。 问题是一些斑点在斑点检测和平滑期间是分裂的。 我尝试使用以下代码。
Mat outlines=Mat::zeros(m3.size(),CV_8UC3);
findContours(m3,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE,Point(0,0));
//Approximate Contours
std::vector<std::vector<cv::Point> > contours_poly( contours.size() );
for( int i = 0; i < contours.size(); i++ ) {
approxPolyDP(cv::Mat(contours[i]), contours_poly[i], 5, true );
std::vector<cv::Point> hull;
cv::convexHull(cv::Mat(contours_poly[i]),hull);
cv::Mat hull_points(hull);
cv::RotatedRect rotated_bounding_rect = minAreaRect(hull_points);
Point2f vertices[4];
if(rotated_bounding_rect.size.area()==0){
continue;
}
rotated_bounding_rect.points(vertices);
for (int i = 0; i < 4; ++i)
{
cv::line(outlines, vertices[i], vertices[(i + 1) % 4], cv::Scalar(0, 255, 0), 1, CV_AA);
}
}
问题在于,即使使用approxPolyDP 方法检测并连接这些轮廓,它也会导致一些小斑点消失,即使它们单独存在并且附近没有任何其他斑点。
我想要的是那些非常接近要加入的斑点,或者至少应该从我的轮廓列表中删除其中一个,其余的都应该保留。
下面是最初和最终的图像,这将使我的问题更清楚。
初始图片:
http://sdrv.ms/1bp8x89
最终图片:
http://sdrv.ms/1bp8tp5
正如我们在最终图像中看到的那样,即使某些 blob 没有正确连接,图像右侧的小 blob 也会丢失。
此外,这种技术需要几秒钟才能处理一帧。给定一个视频,这种技术变得非常低效。
请提出一些补救措施。
【问题讨论】:
-
你还记得那些图片链接是什么吗?因为就像关于 SO 的一般警告说明:链接变成 404,而这些正是这样做的,这让今天找到它的访问者有些沮丧,因为帖子的细节显然丢失了。
-
不幸的是,这些现在都丢失了。我相信那时图像无法附加到 SO。