Beispiel #1
0
 def _deflate(self, tile: bytes) -> np.ndarray:
     """Internal method to decompress DEFLATE image bytes and convert to numpy array"""
     decoded = self._reshape(
         np.frombuffer(imagecodecs.zlib_decode(tile), self.dtype)
     )
     self._unpredict(decoded)
     return np.rollaxis(decoded, 2, 0)
Beispiel #2
0
 def _decompress_mask(self, tile: bytes) -> np.ndarray:
     """Internal method to decompress a binary mask and rescale to uint8"""
     decoded = np.frombuffer(imagecodecs.zlib_decode(tile), np.dtype("uint8"))
     mask = (
         np.unpackbits(decoded).reshape(self.TileHeight.value, self.TileWidth.value)
         * 255
     )
     return mask
Beispiel #3
0
 def decode(self, buf, out=None):
     return imagecodecs.zlib_decode(buf, out=_flat(out))