Open CV (Python) - Abnormal spot detection for brain tumors

I'm trying to identify brain tumors with blob detection in Open CV, but so far Open CV only detects tiny circles in MRI of the brain, but is never the tumor itself.

Here's the code:

import cv2
from cv2 import SimpleBlobDetector_create, SimpleBlobDetector_Params
import numpy as np

# Read image
def blobber(filename):
    im = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)

    # Set up the detector with default parameters.
    detector = cv2.SimpleBlobDetector_create()

    params = cv2.SimpleBlobDetector_Params()

    # Filter by Area.
    params.filterByArea = True
    params.minArea = 50

    # Filter by Circularity
    params.filterByCircularity = True
    params.minCircularity = 0

    # Filter by Convexity
    params.filterByConvexity = True
    params.minConvexity = 0.1

    # Create a detector with the parameters
    ver = (cv2.__version__).split('.')
    if int(ver[0]) < 3 :
        detector = cv2.SimpleBlobDetector(params)
    else : 
        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([]),(0,0,255),cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

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

      

Here's what happens when I feed a program with a b / w contrasting brain image (I contrasted the brain so that the tumor appears in black and the rest of the brain is mostly white):

A tumor is not a perfect circle by any means, but it is undoubtedly the largest "blob" in the brain. An open CV cannot pick it up, I suspect, because it has a black outer shell and a white core.

Only when I select a more distinct tumor, without the large white inner core, can it pick up the tumor.

Any advice? I need to clear these droplets (once they work accurately) from the original images and use their cue points to restore the entire 3D brain tumor from JUST 2D tumor in each fragment. I'm a little far from this step, but this block detector problem is an important link between 2D and 3D. Appreciate all the help!

+3


source to share


1 answer


probaply the biggest blob is the skull itself. if you distract the biggest blob and keep the next big thing use outline as appearance



0


source







All Articles