从cv2开始,我想要的是给对象一个种子,就像在某个坐标窗口中那样,让他连接所有可能在初始坐标框之外但与之接触的像素。 我从一些小测试开始,以了解连接的组件:
im=cv2.imread('test.png', 0)
ret, thresh = cv2.threshold(im, 254, 255, cv2.THRESH_BINARY)
output = cv2.connectedComponentsWithStats(thresh, 4, cv2.CV_32S)
那么
^{pr2}$这两个输出数组,到目前为止还不错,然后我想看到实际的输出图像,它引用了文档https://docs.opencv.org/3.0-beta/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#connectedcomponentsconnectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S)
和{
output = cv2.connectedComponents(thresh,"out_test.png" ,4, cv2.CV_32S)
这给了我这个问题中的错误。我也试着:
cv2.imwrite(dest_dir+"out_test.png", output)
得到了这个错误:
TypeError: img is not a numerical tuple
当我不想计算blob(对象)、它们的大小或其他任何我只想让它们从我给出的原始感兴趣的区域增长时,我如何实际地可视化输出呢。在
如果您想让白色斑点变大,可以使用Morphological Transformations
在使用之前一定要了解函数的作用
cv2.connectedComponents
@ausk答案应该对你有用
import cv2
在终端中打开python之后
示例
help(cv2.connectedComponents)
希望这有帮助
^{pr2}$^{pr2}$
相关问题 更多 >
编程相关推荐