我有以下代码:
import numpy as np
from scipy import misc
import B as b
class A():
def __init__(self):
self.__array = np.empty((4,4), dtype=object)
def __create_subimages(self):
i = 0
j = 0
k = 0
l = 0
position = 0
while i != self.__rows_quotient * self.__rows:
sub_image = b.B(self.__image[i:i + self.__rows_quotient, j:j + self.__cols_quotient], position)
np.append(self.__array, sub_image)
if j == self.__cols_quotient * (self.__cols - 1):
j = 0
i += self.__rows_quotient
else:
j += self.__cols_quotient
if l == len(self.__subimages[0]) - 1:
l = 0
k += 1
else:
l += 1
position += 1
misc.imshow(self.__subimages[0][0].get_image())
另一个班级:
class B():
def __init__(self, image, position):
self.__image = image
self.__position = position
def get_image(self):
return self.__image
所以我尝试将对象B
存储到numpy数组__subimages
,然后在get_image
中显示我带有B
的内容的图像} class
但是,我收到以下错误输出:
misc.imshow(self.__subimages[0][0].get_image())
AttributeError: 'NoneType' object has no attribute 'get_image'
为什么是Nontype?它应该是一个B
对象,它有一个返回数组的方法。
请帮助:(