mirror of
https://github.com/13hannes11/situr.git
synced 2024-09-03 20:50:58 +02:00
add documentation for transformation
This commit is contained in:
@@ -2,7 +2,10 @@ import abc
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy
|
import scipy
|
||||||
|
|
||||||
|
|
||||||
class Transform:
|
class Transform:
|
||||||
|
"""Abstract class representing a transformatio that can be performed on an image.
|
||||||
|
"""
|
||||||
__metaclass__ = abc.ABCMeta
|
__metaclass__ = abc.ABCMeta
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@@ -12,13 +15,21 @@ class Transform:
|
|||||||
|
|
||||||
|
|
||||||
class IdentityTransform(Transform):
|
class IdentityTransform(Transform):
|
||||||
|
"""A transformation that does not change the image.
|
||||||
|
It inherits from Transform.
|
||||||
|
"""
|
||||||
|
|
||||||
def apply_tranformation(self, img: np.ndarray) -> np.ndarray:
|
def apply_tranformation(self, img: np.ndarray) -> np.ndarray:
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|
||||||
class ScaleRotateTranslateTransform(Transform):
|
class ScaleRotateTranslateTransform(Transform):
|
||||||
def __init__(self, transform_matrix: np.ndarray, scale: int = 1, offset: np.array = np.array([0, 0])):
|
def __init__(self,
|
||||||
"""Constructor for a Transformation that supports rotation, translation and scaling on an image
|
transform_matrix: np.ndarray,
|
||||||
|
scale: int = 1,
|
||||||
|
offset: np.array = np.array([0, 0])):
|
||||||
|
"""Constructor for a Transformation that supports rotation, translation and scaling on an
|
||||||
|
image
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
transform_matrix (np.ndarray): A matrix of shape (2,2)
|
transform_matrix (np.ndarray): A matrix of shape (2,2)
|
||||||
|
|||||||
Reference in New Issue
Block a user