blob(斑点)特征,SimpleBlobDetector(OpenCV案例源码detect_blob.cpp解读)
Blob是指图像中的一块连通区域,Blob分析就是对前景/背景分离后的二值图像,进行连通域提取和标记。
知识点就是SimpleBlobDetector的使用,blob(斑点)筛选条件:斑点颜色、面积、圆度、惯性率、凸度,参数解读链接
#include<opencv2/opencv.hpp> #include <iostream> using namespace std; using namespace cv; int main() { Mat src=imread("D:/sunflower.png"); //*参数设置,以下都是默认参数 SimpleBlobDetector::Params pDefaultBLOB; pDefaultBLOB.thresholdStep = 10; pDefaultBLOB.minThreshold = 50; pDefaultBLOB.maxThreshold = 220; pDefaultBLOB.minRepeatability = 2; pDefaultBLOB.minDistBetweenBlobs = 10; pDefaultBLOB.filterByColor = true; pDefaultBLOB.blobColor = 0; pDefaultBLOB.filterByArea = true; pDefaultBLOB.minArea = 25; pDefaultBLOB.maxArea = 5000; pDefaultBLOB.filterByCircularity = false; pDefaultBLOB.minCircularity = 0.8f; pDefaultBLOB.maxCircularity = (float)3.40282e+038; pDefaultBLOB.filterByInertia = true; pDefaultBLOB.minInertiaRatio = 0.1f; pDefaultBLOB.maxInertiaRatio = (float)3.40282e+038; pDefaultBLOB.filterByConvexity = true; pDefaultBLOB.minConvexity = 0.95f; pDefaultBLOB.maxConvexity = (float)3.40282e+038; //*用参数创建对象 Ptr<SimpleBlobDetector> blob=SimpleBlobDetector::create(pDefaultBLOB); //Ptr<SimpleBlobDetector> blob=SimpleBlobDetector::create();//默认参数创建 //*blob检测 vector<KeyPoint> key_points; blob->detect(src,key_points); Mat outImg; //*绘制结果 drawKeypoints(src,key_points,outImg,Scalar(0,0,255)); imshow("blob",outImg); waitKey(); return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2019-03-12 读图,特征提取——形状