Opencv中SimpleBlobDetector的使用(斑点检测)

来源:互联网 发布:mac做铃声 编辑:程序博客网 时间:2024/05/16 01:27

斑点检测

1、斑点

  • 斑点:是一组连通的像素在图像中共享一些共同的属性(如灰度值、颜色等)

2、opencv中的斑点检测(SimpleBlobDetector)

#include <opencv2/highgui.hpp>#include <opencv2/calib3d.hpp>#include <iostream>using namespace std;using namespace cv;int main(){    Mat img = imread("blob.jpg",IMREAD_GRAYSCALE);    /*    SimpleBlobDetector::Params params;    //阈值控制    params.minThreshold = 10;    params.maxThreshold = 200;    //像素面积大小控制    params.filterByArea = true;    params.minArea = 1000;    //形状(凸)    params.filterByCircularity = false;    params.minCircularity = 0.7;    //形状(凹)    params.filterByConvexity = true;    params.minConvexity = 0.9;    //形状(园)    params.filterByInertia = false;    params.minInertiaRatio = 0.5;    */    Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create();    vector<KeyPoint> keypoints;    detector->detect(img,keypoints);    Mat img_with_keypoints;    drawKeypoints(img,keypoints,img_with_keypoints,Scalar(0,0,255),DrawMatchesFlags::DRAW_RICH_KEYPOINTS);    imshow("keypoints",img_with_keypoints);    waitKey(0);    return 0;}
  • 原图:
    原图

  • 检测结果
    检测结果

3、SimpleBolbDetector参数:
相关参数

  • 像素大小参数:
    形状
  • 凸型参数:
    形状
  • 凹型参数:
    形状
  • 圆型参数:
    形状
以上参数之前相互之间会影响。(参数名称不具有学术性,为了形象,自己取的名称^.^)

参考SATYA MALLICK Ph.D的文章

原创粉丝点击