3

I want to get some descriptors for each white area on image to filter that areas and operate with them separately. How can I do it?

I have read How to use OpenCV SimpleBlobDetector and http://www.learnopencv.com/blob-detection-using-opencv-python-c/ but still can't get any result with my simple image.

enter image description here

Here is my code in python

img = cv2.imread("map.jpg", cv2.IMREAD_GRAYSCALE)
params = cv2.SimpleBlobDetector_Params()
params.blobColor = 255
params.filterByColor = True
params.minArea = 16
params.filterByArea = True
detector = cv2.SimpleBlobDetector_create(params)
keypoints = detector.detect(255 - img)
len(keypoints)
# 0

OpenCV 3.1.0

Image is grayscaled.

UPD: Code updated following comment by @api55

Community
  • 1
  • 1

2 Answers2

1

I want to get some descriptors for each white area on image to filter that areas and operate with them separately. How can I do it?

My goal could be reached with sklearn.measure.label. This function returns a numpy array with the same shape and labels for each connected area.

But anyway it is still not clear why SimpleBlobDetector from OpenCV doesn't work.

  • Try skimage blob detection. http://scikit-image.org/docs/dev/auto_examples/features_detection/plot_blob.html. – Chandra Oct 25 '16 at 13:12
0

I was having the same problem. I had to remove the fiterbyarea parameter:

params.filterByArea = False
Guido
  • 634
  • 1
  • 8
  • 19