cutcutcodec.core.io.read_image.ContainerInputImage

class cutcutcodec.core.io.read_image.ContainerInputImage(filename: str | bytes | Path)[source]

Decode an image.

Attributes

filenamepathlib.Path

The path to the physical file that contains the extracted image stream (readonly).

Examples

>>> from cutcutcodec.core.io.read_image import ContainerInputImage
>>> (stream,) = ContainerInputImage.default().out_streams
>>> stream.snapshot(0, (12, 12))[..., 3]
tensor([[  0,   0,   9, 113, 204, 247, 247, 203, 113,  10,   0,   0],
        [  0,  30, 208, 255, 255, 255, 255, 255, 255, 208,  30,   0],
        [  9, 208, 255, 255, 255, 255, 255, 255, 255, 255, 208,   9],
        [113, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 113],
        [204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 203],
        [247, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246],
        [247, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246],
        [204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 203],
        [113, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 113],
        [  9, 208, 255, 255, 255, 255, 255, 255, 255, 255, 208,   9],
        [  0,  30, 208, 255, 255, 255, 255, 255, 255, 208,  30,   0],
        [  0,   0,   9, 113, 203, 246, 246, 203, 113,   9,   0,   0]],
       dtype=torch.uint8)
>>>

Initialise and create the class.

Parameters

filenamepathlike

Path to the file to be decoded.

Raises

cutcutcodec.core.exceptions.DecodeError

If it fail to extract any multimedia stream from the provided file.

classmethod default()[source]

Provide a minimalist example of an instance of this node.

property filename: Path

Return the path to the physical file that contains the extracted image stream.