Skip to content

Feature

IFeature

Bases: IRegion, ABC

Source code in src/officialeye/_api/template/feature.py
class IFeature(IRegion, ABC):

    def __str__(self) -> str:
        return f"Feature '{self.identifier}'"

    @abstractmethod
    def get_mutators(self) -> Iterable[IMutator]:
        """
        Returns:
            A list of mutators from the feature class of the feature, in the order in which they are to be applied.
        """
        raise NotImplementedError()

    def apply_mutators_to_image(self, img: np.ndarray, /) -> np.ndarray:
        """
        Takes an image and applies the mutators defined in the corresponding feature class.

        Arguments:
            img: The image that should be transformed.

        Returns:
            The resulting image.
        """

        for mutator in self.get_mutators():
            img = mutator.mutate(img)

        return img

apply_mutators_to_image(img)

Takes an image and applies the mutators defined in the corresponding feature class.

Parameters:

Name Type Description Default
img ndarray

The image that should be transformed.

required

Returns:

Type Description
ndarray

The resulting image.

Source code in src/officialeye/_api/template/feature.py
def apply_mutators_to_image(self, img: np.ndarray, /) -> np.ndarray:
    """
    Takes an image and applies the mutators defined in the corresponding feature class.

    Arguments:
        img: The image that should be transformed.

    Returns:
        The resulting image.
    """

    for mutator in self.get_mutators():
        img = mutator.mutate(img)

    return img

get_mutators() abstractmethod

Returns:

Type Description
Iterable[IMutator]

A list of mutators from the feature class of the feature, in the order in which they are to be applied.

Source code in src/officialeye/_api/template/feature.py
@abstractmethod
def get_mutators(self) -> Iterable[IMutator]:
    """
    Returns:
        A list of mutators from the feature class of the feature, in the order in which they are to be applied.
    """
    raise NotImplementedError()