python---之scipy.ndimage.measurements.label
scipy.ndimage.measurements.label(input, structure=None, output=None)
input:輸入一個數組,數組中非0值被認為是目標區域,0值是背景區域
structure:可以用 scipy.ndimage.generate_binary_structure函數來規定連通域圖像的維度和連通域所需要的鄰域
output:If output is a data type, it specifies the type of the resulting labeled feature array If output is an array-like object, then output will be updated with the labeled features from this function. This function can operate in-place, by passing output=input. Note that the output must be able to store the largest label, or this function will raise an Exception.
?
輸出:
label:一個被已經分好連通域的label圖像:
num_feartures:統計一共有多少種連通分量的數量,例如數字5代表一共有5種,ID分別是1,2,3,4,5
當我使用前面的structure函數時,structure定義了連通分量的空間距離到底是幾鄰域的,下面的定義了8鄰域,所以在8鄰域內部的都被歸為1類連通分量,所以連通分量就由上面的4減少為2了:
如下:
總結
以上是生活随笔為你收集整理的python---之scipy.ndimage.measurements.label的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是网站死链?如何查询网站死链?网站死
- 下一篇: 以教育行业为例,教产品经理如何做行业分析