I’m trying to extract blobs from an image using SimpleBlobDetector. I’m not able to detect blobs on image’s edges.
Here is my code:
SimpleBlobDetector::Params params = SimpleBlobDetector::Params();
params.minThreshold = 0;
params.maxThreshold = 16;
params.filterByArea = true;
params.minArea = 10;
params.maxArea = image.cols*image.rows;
// Filter only by area
// No other min/max parameter is set
params.filterByCircularity = false;
params.filterByConvexity = false;
params.filterByInertia = false;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// Create ROI image
// cropped = img[start_row:end_row, start_col:end_col]
Mat croppedImage = image(Range(roi.y, roi.y + roi.height),
Range(roi.x, roi.x + roi.width));
// Detect blobs
vector<KeyPoint> keyPoints;
detector->detect(image, keyPoints);
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints(image, keyPoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
Here is the source image with blobs highlighted:
As you can see, the two blobs that hit the border are skipped.
How to detect them?
Any different/best approach than using SimpleBlobDetector?