Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 基于大结构元的图像特征检测_Python_Image Processing_Numpy_Python 3.x_Scipy - Fatal编程技术网

Python 基于大结构元的图像特征检测

Python 基于大结构元的图像特征检测,python,image-processing,numpy,python-3.x,scipy,Python,Image Processing,Numpy,Python 3.x,Scipy,我试图从图像中提取一些特征,但每个提取的特征都非常小。提取较大特征的最简单方法似乎是使用较大的结构元素,但以下代码在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 # ||

我试图从图像中提取一些特征,但每个提取的特征都非常小。提取较大特征的最简单方法似乎是使用较大的结构元素,但以下代码在
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])


ndimage.label
函数的参数
structure
用于确定输入的连接性。当您将输入表示为矩形矩阵时,此连接性通常考虑点周围的4个或8个邻居
p
。Scipy遵循此约定,并将接受的结构限制在此类情况下,因此,当任何大于
3x3
的内容传递给函数时,它会引发错误


如果你真的想做这样的事情,首先你需要非常清楚地定义你想要描述的连通性。然后你需要实现它。一种更简单的方法是首先放大输入,然后标记它。这将有效地提供更大的功能,这些功能将被标记为更大的
结构
参数。

我想使用类似于
ndimage.iterate_结构(struct,2)
生成的结构的连接。这样,如果两个特征由一个像素分隔,则认为它们是相同的特征。放大是否具有与使用更大结构完全相同的效果?如果使用基本正方形进行放大,这两个由一个像素分隔的特征将合并。因此,它们将被标记为单个特征。
RuntimeError: structure dimensions must be equal to 3