@staticmethod
def get_offset(position: float, target_size: float, image_size: float):
    """Calculates a offset which contains the position
        in a range from offset to offset + target_size.

        Args:
            position (float): the centered position, if possible
                Specified as factor of the image size,
                so it should be an element of [0, 1].
            target_size (int): the image size of the wanted result
            image_size (int): the image size

        Returns:
            int: the offset
        """
    return int(min(max(0, position * image_size - target_size / 2), 
        image_size - target_size))
