【问题标题】:Generate bounding boxes from elevation map/watershed transform从高程图/分水岭变换生成边界框
【发布时间】:2019-02-12 09:22:29
【问题描述】:

我正在使用 scikit-image 对我拥有的一些图像进行图像分割,我指的是这个教程 (https://scikit-image.org/docs/dev/user_guide/tutorial_segmentation.html)

我正在使用描述的高程图方法,虽然在应用分水岭算法后我无法获得正确的结果,但高程图本身似乎足以满足我的目的。

我在绘制高程图时得到这个输出:

现在我想获取该对象边界框的坐标。我如何实现这一目标?我查看了 http://scikit-image.org/docs/dev/auto_examples/edges/plot_contours.html 但我无法弄清楚如何为 find_contours 选择第二个参数?

【问题讨论】:

    标签: image-processing scikit-image


    【解决方案1】:

    这对你有用吗?

    from skimage import filters
    from scipy import ndimage as ndi
    
    threshold = filters.threshold_otsu(elevation_map)
    binary = (elevation_map > threshold).astype(int)
    bounding_box = ndi.find_objects(binary)[0]
    

    【讨论】:

    • 谢谢。我得到两个元组,找不到关于数字格式的文档。
    • 你应该得到两个切片,它们对应于提取边界框所需的切片。即如果你这样做image[bounding_box],你会得到鞋子回来。如果你想要实际值,bounding_box[0].startbounding_box[0].stop 告诉你开始行和结束行,而bounding_box[1].startbounding_box[1].stop 告诉你开始列和结束列。
    猜你喜欢
    • 2015-12-24
    • 2020-02-13
    • 2015-11-10
    • 2014-09-12
    • 1970-01-01
    • 1970-01-01
    • 2010-12-26
    • 2011-01-05
    • 2012-10-28
    相关资源
    最近更新 更多