Ask Your Question
0

simple blob Detection

asked 2016-07-23 13:09:10 -0500

riya1405 gravatar image

Hi, I am trying to detect simple blobs in an image but while running code, I get the image without any keypoints plotted. Why am I not able to detect the blobs?

import cv2
import numpy as np;
im = cv2.imread('blob1.jpeg', cv2.IMREAD_GRAYSCALE)

# Setup SimpleBlobDetector parameters.
params = cv2.SimpleBlobDetector_Params()

# Change thresholds
params.minThreshold = 50
params.maxThreshold = 150
# Filter by Area.
params.filterByArea = True
params.minArea = 150
detector = cv2.SimpleBlobDetector_create(params)

# Detect blobs.
keypoints = detector.detect(im)

# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures
# the size of the circle corresponds to the size of blob

im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (255,0,0), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

# Show blobs
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
cv2.destroyAllWindows()

image description

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-24 05:22:56 -0500

berak gravatar image

unfortunately, the "Simple" blobDetector is actually a quite complex thing.

please either set all values in the Params, or at least check if the default values make sense ,

e.g. if filterByColor=true , it won't find any in a grayscale image.

edit flag offensive delete link more

Comments

If I don't use parameters at all, then it is supposed to give me all the blobs that are detected right?

riya1405 gravatar imageriya1405 ( 2016-07-24 11:20:21 -0500 )edit

no, not correct. if you don't use parametersat all, the defaultvalues from the cpp file will be used, which might (or rather might not) make sense in your case

berak gravatar imageberak ( 2016-07-24 11:24:07 -0500 )edit

So what should I do to detect these blobs?

riya1405 gravatar imageriya1405 ( 2016-07-24 11:26:31 -0500 )edit

I don't want to use contours on this one. I'm trying to detect cars in an image, so this is the basic blob test.

riya1405 gravatar imageriya1405 ( 2016-07-24 11:33:07 -0500 )edit
1

"I don't want to use contours on this one."

but it's using contours under the hood. (maybe you're better off then, using them directly.)

" I'm trying to detect cars in an image"

cars are no circular blobs. imho, this is the wrong tool then.

berak gravatar imageberak ( 2016-07-25 01:23:39 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-23 13:09:10 -0500

Seen: 7,748 times

Last updated: Jul 24 '16