IndexError: while running generalized hough transform on my data, why?
IndexError: while running generalized hough transform on my data, why?
我正在尝试应用 available generalized hough transform (GHT) on my own data. the program is running very well on the provided sample data, however, for my data once it reaches to this line 它给出了错误:
我的数据已保存到 main function 中的两个 numpy 数组中:
f = h5py.File(img_path,'r') # reading the reference image
refim = f['image'].value
refim = np.asarray(refim)
refim[refim!=1]=0
#im = imread('Input1.png')
f = h5py.File(im_path,'r') # reading the image that should be matched
im = f['image'].value
im = np.asarray(im)
参考图像和测试图像的大小相同 256x256
,参考图像中的对象中心为 [ 83.02902047 127.19376853]
。名称为table
的变量是一个形状为(90,)
的列表,其中每个列表元素的形状为(144,2)
元组,例如一个元素包括[-102.97097952712484, 12.193768525539397]
/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "generalized-hough-demo.py", line 43, in <module>
acc = matchTable(im, table)
File "/home/user/workspace/jupyter_codes/PythonSIFT/Genarlized_Hough_Voting/generalised-hough-transform/match_table.py", line 38, in matchTable
acc[vector[0]+x, vector[1]+y]+=1
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
纠结了两天,非常感谢您的专家意见
此错误消息表明索引应为 only integers
。如您所见,table
是 vectors
的列表,每个 vector
都是您在问题中所述的二维向量。
所以,vector[0]
和 vector[1]
大部分是 float 并且矩阵的索引必须是整数。这就是为什么它将错误指向行 43.
我正在尝试应用 available generalized hough transform (GHT) on my own data. the program is running very well on the provided sample data, however, for my data once it reaches to this line 它给出了错误: 我的数据已保存到 main function 中的两个 numpy 数组中:
f = h5py.File(img_path,'r') # reading the reference image
refim = f['image'].value
refim = np.asarray(refim)
refim[refim!=1]=0
#im = imread('Input1.png')
f = h5py.File(im_path,'r') # reading the image that should be matched
im = f['image'].value
im = np.asarray(im)
参考图像和测试图像的大小相同 256x256
,参考图像中的对象中心为 [ 83.02902047 127.19376853]
。名称为table
的变量是一个形状为(90,)
的列表,其中每个列表元素的形状为(144,2)
元组,例如一个元素包括[-102.97097952712484, 12.193768525539397]
/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "generalized-hough-demo.py", line 43, in <module>
acc = matchTable(im, table)
File "/home/user/workspace/jupyter_codes/PythonSIFT/Genarlized_Hough_Voting/generalised-hough-transform/match_table.py", line 38, in matchTable
acc[vector[0]+x, vector[1]+y]+=1
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
纠结了两天,非常感谢您的专家意见
此错误消息表明索引应为 only integers
。如您所见,table
是 vectors
的列表,每个 vector
都是您在问题中所述的二维向量。
所以,vector[0]
和 vector[1]
大部分是 float 并且矩阵的索引必须是整数。这就是为什么它将错误指向行 43.