需要帮助从Image中提取对象

时间:2017-07-09 07:27:12

标签: python opencv image-processing image-segmentation

因此,使用K意味着,我已经能够在过滤过程中实现这一目标。但是,我的目标是检测已发布图像中的白点,并将每个白点保存为自己的图像文件。我该怎么做呢?

Image I'm working with

1 个答案:

答案 0 :(得分:3)

  

您可以使用blob detection   在Python中使用OpenCV:

Blob是图像中的一组连接像素,它们共享一些共同属性(例如灰度值)。在您的情况下,光连接区域是斑点,斑点检测的目标是通过以下步骤识别和标记这些区域:

  • 阈值
  • 分组
  • 合并
  • 中心&半径计算
  

python中的示例代码是:

# Standard imports
import cv2
import numpy as np;

# Read image
im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)

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

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

相关问题