| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- # LICENSE HEADER MANAGED BY add-license-header
- #
- # Copyright 2018 Kornia Team
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- from __future__ import annotations
- from dataclasses import dataclass
- from enum import Enum
- from kornia.core import Tensor
- @dataclass(frozen=True)
- class ImageSize:
- r"""Data class to represent image shape.
- Args:
- height: image height.
- width: image width.
- Example:
- >>> size = ImageSize(3, 4)
- >>> size.height
- 3
- >>> size.width
- 4
- """
- height: int | Tensor
- width: int | Tensor
- class ColorSpace(Enum):
- r"""Enum that represents the color space of an image."""
- UNKNOWN = 0 # for now, in case of multi band images
- GRAY = 1
- RGB = 2
- BGR = 3
- @dataclass(frozen=True)
- class PixelFormat:
- r"""Data class to represent the pixel format of an image.
- Args:
- color_space: color space.
- bit_depth: the number of bits per channel.
- Example:
- >>> pixel_format = PixelFormat(ColorSpace.RGB, 8)
- >>> pixel_format.color_space
- <ColorSpace.RGB: 2>
- >>> pixel_format.bit_depth
- 8
- """
- color_space: ColorSpace
- bit_depth: int
- class ChannelsOrder(Enum):
- r"""Enum that represents the channels order of an image."""
- CHANNELS_FIRST = 0
- CHANNELS_LAST = 1
- @dataclass(frozen=True)
- class ImageLayout:
- """Data class to represent the layout of an image.
- Args:
- image_size: image size.
- channels: number of channels.
- channels_order: channels order.
- Example:
- >>> layout = ImageLayout(ImageSize(3, 4), 3, ChannelsOrder.CHANNELS_LAST)
- >>> layout.image_size
- ImageSize(height=3, width=4)
- >>> layout.channels
- 3
- >>> layout.channels_order
- <ChannelsOrder.CHANNELS_LAST: 1>
- """
- image_size: ImageSize
- channels: int
- channels_order: ChannelsOrder
- # TODO: define CompressedImage
|