我正在尝试从图像中提取一些特征,但每个提取的特征都非常小。提取更大特征的最简单方法似乎是使用更大的结构元素,但以下代码在ITER > 1
.
from scipy import ndimage,misc
lena=misc.lena().astype(float64)
lena/=ndimage.maximum(lena)
lena=lena>0.54# convert to binary image
# =====================
ITER=1 # || FAILS WHEN ITER > 1 ||
# =====================
struct=ndimage.generate_binary_structure(2,1)
struct=ndimage.iterate_structure(struct,ITER)
lena_label,n =ndimage.label(lena,struct)
slices=ndimage.find_objects(lena_label)
images=[lena[sl] for sl in slices]
imshow(images[0])
.
RuntimeError: structure dimensions must be equal to 3