一种基于形状库的目标检测器。
small-particle-detection的Python项目详细描述
要求
spade只在python 3.5中测试过,但应该可以在旧版本中使用。 唯一严格的要求是包装numpy。 为了充分利用铁锹,我们建议安装 scikit图片包和完整的scipy生态系统。
用法
在python脚本中
您可以使用pip安装包。其主要功能是 铲式探测模块。它需要图像、形状库和 阈值作为输入。典型用法如下
fromskimage.ioimportimread,imshowfromskimage.filtersimportthreshold_otsufromskimage.colorimportlabel2rgbfromnumpyimportpercentileimportmatplotlib.pyplotaspltfromspade.detection_2dimportspade2dfromspade.shapes.examplesimportpotatoids5x5_smallest4px# Load the example image.image=imread("example_2d.png")# Separate cell image from background, using by Otsu's thresholding method.cell=image>threshold_otsu(image)# Focus on brightest pixels onlypotential_centers=image>percentile(image[cell],99)# Detect particles.particles=spade2d(image=image,shapes_library=potatoids5x5_smallest4px,threshold=20,potential_centers=potential_centers,mask=cell)# Show detected particles as overlay on our original image.imshow(label2rgb(particles,image,bg_label=0))plt.show()
有关详细信息,请参见source dist的example文件夹中的示例 信息。注意,spade不需要matplotlib和skipage。 去工作。
从命令行
还提供了一个命令行界面,可以如下使用:
python -m spade.cli INPUT_IMAGE THRESHOLD -o /path/to/output_image.png
使用-h启动此命令以获取有关其用法的详细信息。
许可证
铁锹放在CeCILL-2.1 licence下面。