小编Est*_*her的帖子

python中的图像分割

我有图片 形状图像

我正在寻找 python 解决方案,根据图像中的轮廓将该图像中的形状分解成更小的部分。

我在 OpenCV 中研究了 Canny 和 findContours 的解决方案,但它们都不适合我。

编辑:

使用的代码:

使用 Canny 方法

import cv2 import numpy as np

img = cv2.imread('area_of_blob_maxcontrast_white.jpg') edges = cv2.Canny(img, 100, 200)
cv2.imwrite('area_of_blob_maxcontrast_white_edges.jpg',edges)
Run Code Online (Sandbox Code Playgroud)

使用 findContours 方法

import numpy as np 
import argparse 
import cv2

image = cv2.imread('area_of_blob_maxcontrast_white.png')

lower = np.array([0, 0, 0]) upper = np.array([15, 15, 15]) shapeMask = cv2.inRange(image, lower, upper)

(_,cnts, _) = cv2.findContours(shapeMask.copy(), cv2.RETR_EXTERNAL,
                            cv2.CHAIN_APPROX_SIMPLE) print "I found %d black shapes" % (len(cnts)) cv2.imshow("Mask", shapeMask)

for c in cnts: …
Run Code Online (Sandbox Code Playgroud)

python opencv image-segmentation

4
推荐指数
1
解决办法
4300
查看次数

标签 统计

image-segmentation ×1

opencv ×1

python ×1