def __next__(self):
tmp = self.fdata.read(self.nrows*self.ncols)
if tmp == "": raise StopIteration
#image = np.array(struct.unpack("{0}B", tmp), dtype=np.byte). \
# reshape((self.nrows, self.ncols))
# notice we shall normalize the input
image = np.array(struct.unpack("{0}B".format(self.nrows*self.ncols), tmp), dtype=np.float32) / 256.0
#print np.max(image), np.min(image)
return image
评论列表
文章目录