zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    Hibernate检索策略与检索方式
    获取分组后的TOP 1和TOP N记录
    Oracle 高级排序函数 和 高级分组函数
    Java中的字符串常量池
    代码的完整性:打印1到最大的n位数
    代码的完整性:数值的整数次方
    递归和循环:矩形覆盖
    位运算:二进制中1的个数
    递归和循环:变态跳台阶
    递归和循环:跳台阶
  • 原文地址:https://www.cnblogs.com/xixixing/p/12468235.html
Copyright © 2011-2022 走看看