如何计算blob使用Open CV的循环程度 - SimpleBlobDetector()?

时间:2017-10-30 17:45:44

标签: python python-3.x opencv image-processing

我有两张痣图像。一个是相对圆的,但另一个不是。我想知道痣的圆形是多么圆-1,不是圆形,0是椭圆形,1是圆形。我首先将原始图像转换为二进制文件,然后尝试使用下面的代码。代码围绕圆形痣绘制一个圆圈,但没有提供惯性信息。非睾丸痣甚至不被检测为斑点。我不正确地理解这个概念吗?我该如何解决这个问题?

circular non-edited mole Circular edited Mole non circular non-edited mole Non-Circular edit Mole

# Standard imports
import cv2
import numpy as np

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

# Change thresholds
params.minThreshold = 10;
params.maxThreshold = 200;

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

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

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

# Filter by Inertia
params.filterByInertia = True
params.minInertiaRatio = 0.01

# Create a detector with the parameters
detector = cv2.SimpleBlobDetector_create(params)

# Read image
im = cv2.imread("mole_torezo.png", cv2.IMREAD_GRAYSCALE)

# 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)

感谢Blob Detection Using OpenCV ( Python, C++ )代码

0 个答案:

没有答案