forked from continental/image-statistics-matching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs_converter.py
25 lines (18 loc) · 827 Bytes
/
cs_converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""This module defines the ColorSpaceConverter interface"""
import abc
from typing import NamedTuple, Tuple
import numpy as np
ChannelRange = NamedTuple('ChannelRange', [('min', float), ('max', float)])
class ColorSpaceConverter(abc.ABC):
""" the ColorSpaceConverter interface declares operations common to all
color space conversion algorithms """
@abc.abstractmethod
def convert(self, image: np.ndarray) -> np.ndarray:
""" converts image from source to target color space """
@abc.abstractmethod
def convert_back(self, image: np.ndarray) -> np.ndarray:
""" converts image from target color space back
to source color space """
@abc.abstractmethod
def target_channel_ranges(self) -> Tuple[ChannelRange, ...]:
""" returns the ranges of the color space """