简体   繁体   English

TypeError:“ numpy.float64”对象不可调用,为什么?

[英]TypeError: 'numpy.float64' object is not callable, why?

Why am I getting this error? 为什么会出现此错误? The error seems to be in the line calling 'for i in range' but I cannot see why this would be an error...I have quit the kernel in case something is hiding in i. 该错误似乎在调用'for i in range'的行中,但是我看不到为什么这将是错误...我退出了内核,以防i中隐藏了某些东西。

My code is as follows: 我的代码如下:

import os, sys
import numpy
from matplotlib import pylab, pyplot, cm
from math import pi
from skimage import io


image = numpy.ones([44,44],dtype = float)
imrange = len(image)

#Initialize empty residue map
residue_map = numpy.empty([imrange-2,imrange-2],dtype = float)

#Calculate the residues for each point following formula (1) in He paper
for i in range (1,int(imrange-1)):
    for j in range (1,int(imrange-1)):
        value = (image[i+1][j] - image[i][j]) + (image[i+1][j+1] - 
image[i+1][j]) + (image[i][j+1] - image[i+1][j+1]) + (image[i][j] - image[i][j+1])
        if value/2./pi > 0:
            residue_map[i-1][j-1] = 1.
        elif value/2./pi == 0:
            residue_map[i-1][j-1] = 0.
        else:
            residue_map[i-1][j-1] = -1.

作为python初学者的另一种情况....上面的代码按我定义的范围= numpy.max(image)-numpy.min(image)起作用,然后在循环中再次使用range,因此出现错误!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM