Python 布尔索引与维度0上的索引数组不匹配;维度为2,但相应的布尔维度为18
我试图用Python学习图像处理中的代码,但我有一个错误Python 布尔索引与维度0上的索引数组不匹配;维度为2,但相应的布尔维度为18,python,Python,我试图用Python学习图像处理中的代码,但我有一个错误 bins_num = int(brick_lbp.max() + 1) brick_hist = np.histogram(brick_lbp, normed=True, bins=bins_num, range=(0, bins_num)) lbp_features = [brick_rot_lbp, grass_rot_lbp, wall_rot_lbp] min_score = 1000 # Set a very large be
bins_num = int(brick_lbp.max() + 1)
brick_hist = np.histogram(brick_lbp, normed=True, bins=bins_num, range=(0, bins_num))
lbp_features = [brick_rot_lbp, grass_rot_lbp, wall_rot_lbp]
min_score = 1000 # Set a very large best score value initially
idx = 0 # To keep track of the winner
for feature in lbp_features:
histogram, _ = np.histogram(feature, normed=True, bins=bins_num, range=(0,bins_num))
p = np.asarray(brick_hist)
q = np.asarray(histogram)
filter_idx = np.logical_and(p != 0, q != 0)
score = np.sum(p[filter_idx] * np.diff(p[filter_idx] / q[filter_idx]))
if score < min_score:
min_score = score
winner = idx
idx = idx + 1
bin\u num=int(brick\u lbp.max()+1)
brick\u hist=np.直方图(brick\u lbp,normed=True,bins=bins\u num,range=(0,bins\u num))
lbp_功能=[砖_烂_lbp、草_烂_lbp、墙_烂_lbp]
min_分数=1000#最初设置一个非常大的最佳分数值
idx=0#跟踪获胜者
对于lbp_功能中的功能:
直方图,u=np.直方图(特征,赋范=真,单元数=单元数,范围=(0,单元数))
p=np.asarray(砖历史)
q=np.asarray(柱状图)
filter_idx=np.logical_和(p!=0,q!=0)
分数=np.sum(p[filter\u idx]*np.diff(p[filter\u idx]/q[filter\u idx]))
如果分数<最小分数:
最低分数=分数
获胜者=idx
idx=idx+1
布尔索引与维度0上的索引数组不匹配;维度为2,但相应的布尔维度为18欢迎使用stackoverflow。请更正代码示例格式。名称错误:未定义名称“brick\u lbp”。你能让这个代码重现吗?请添加样本中使用的所有变量。如果您测试这些小代码片段,而不是抛出您想要解决的错误,那么这将是一件好事。帮助你对大家都有帮助。