Ejemplo n.º 1
0
class SERSequence(object):
    def __init__(self, file):
        self.file = open(file, 'rb')
        self.header = SERHeader(self.file.read(SERHeader.SIZE))
        print(self.header)

    def images(self):
        return self.header.frames

    def image(self, index):
        b = self.header.frame_bytes()
        self.file.seek(SERHeader.SIZE + index * b)
        data = self.file.read(b)
        return np.array(
            array.array('B' if self.header.depth == 8 else 'H',
                        data)).reshape(self.header.height, self.header.width)

    def write(self, newfile, images):
        header = copy.deepcopy(self.header)
        header.frames = len(images)
        f = open(newfile, 'wb')
        f.write(header.pack())
        for image in images:
            f.write(self.image(image['index']))
        f.close()
Ejemplo n.º 2
0
class SERSequence(object):
    def __init__(self, file):
        self.file = open(file, 'rb')
        self.header = SERHeader(self.file.read(SERHeader.SIZE))
        print(self.header)
    def images(self):
        return self.header.frames
    
    def image(self, index):
        b = self.header.frame_bytes()
        self.file.seek(SERHeader.SIZE + index*b)
        data = self.file.read(b)
        return np.array(array.array('B' if self.header.depth == 8 else 'H', data)).reshape(self.header.height, self.header.width)
    
    def write(self, newfile, images):
        header = copy.deepcopy(self.header)
        header.frames = len(images)
        f = open(newfile, 'wb')
        f.write(header.pack())
        for image in images:
            f.write(self.image(image['index']))
        f.close()
Ejemplo n.º 3
0
 def __init__(self, file):
     self.file = open(file, 'rb')
     self.header = SERHeader(self.file.read(SERHeader.SIZE))
     print(self.header)
Ejemplo n.º 4
0
 def __init__(self, file):
     self.file = open(file, 'rb')
     self.header = SERHeader(self.file.read(SERHeader.SIZE))
     print(self.header)