Improving Simple Blob Detection

asked 2018-11-05 14:38:01 -0600

Stephane gravatar image

I am using a simple blob detection to detect the moles in the input image below: image description

And the output image is:

image description

My problem is that not all the moles are detected. How do I improve the simple blob detection to detect all the moles? Would there be a better way to go about this instead?

  #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov  5 12:48:48 2018

@author: 2020shatgiskessell
"""
import cv2
import numpy as np

#IN LATER VERSIONS MAKE SURE IMAGE IS ALWAYS BINARIZED OR GRAYSCALE!!
img = cv2.imread("/Users/2020shatgiskessell/Desktop/New_Mole_Detector/Test_Images/mole2.jpg")

#use blob detectiom
def identify_moles (image):
    #create blob detector and pass image through
    detector = cv2.SimpleBlobDetector_create()
    keypoints = d
    etector.detect(image)
    #draw blobs
    blank = np.zeros((1,1))
    blobs = cv2.drawKeypoints(image, keypoints, blank, (0,255,255), cv2.DRAW_MATCHES_FLAGS_DEFAULT) 
    return blobs

image_with_blobs = identify_moles(img)

cv2.imshow('identified moles', image_with_blobs)    
cv2.waitKey(0)
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

Comments

@Stephane have you tried adding parameters and varying them for SimpleBlobDetector ?

ameypar94 gravatar imageameypar94 ( 2018-11-05 14:55:48 -0600 )edit

@ameyparanjape I have tried varying the parameters, however, I continuously get the same results. When I change the minConvexity to 0, the SimpleBlobDetector becomes slightly more accurate but not by an adequate amount (it only recognizes one more mole)

Stephane gravatar imageStephane ( 2018-11-05 15:22:38 -0600 )edit

@Stephane I think tuning minArea, min/maxThreshold should improve current result.

ameypar94 gravatar imageameypar94 ( 2018-11-05 15:29:43 -0600 )edit

Change this:

keypoints = d
    etector.detect(image)

to

keypoints = detector.detect(image)
supra56 gravatar imagesupra56 ( 2018-11-07 04:08:58 -0600 )edit