【发布时间】:2019-05-26 04:21:41
【问题描述】:
这里的问题是这仅用于一张图像,我需要对其进行优化以便可以存储多张图像。 (它们的宽度、高度等)
我不精通python。大约 4 年前我研究过它,但现在我几乎忘记了大部分语法。
def __init__(self, im):
self.image = im
self.height, self.width, self.nbchannels = im.shape
self.size = self.width * self.height
self.maskONEValues = [1,2,4,8,16,32,64,128]
#Mask used to put one ex:1->00000001, 2->00000010 .. associated with OR bitwise
self.maskONE = self.maskONEValues.pop(0) #Will be used to do bitwise operations
self.maskZEROValues = [254,253,251,247,239,223,191,127]
#Mak used to put zero ex:254->11111110, 253->11111101 .. associated with AND bitwise
self.maskZERO = self.maskZEROValues.pop(0)
self.curwidth = 0 # Current width position
self.curheight = 0 # Current height position
self.curchan = 0 # Current channel position
我想将来自文件路径(包含这些图像)的多个图像(它们的宽度、高度等)存储在一个数组中
【问题讨论】:
-
你能描述一下你想要存储在你的数组中的数据吗
-
每张图片的高度、宽度和通道像素
-
通道像素是指构成图像的各个通道(例如 RGB)
-
没错
-
图像文件的扩展名是相同的还是可变的?如果是一样的,那你能说一下扩展名是什么