Source code for src.data_handlers.encoding_orders

"""
Author: Ismael Seidel (ismael.seidel@ufsc.br) 
Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC)

Description:
    This module contains encoding orders. The encoding order is important when converting a light field in to a 
    pseudo-temporal sequence.
"""

from typing import Callable, List, Tuple, Union

ScanFunctionType = Callable[[int, int, int, int, int, int], Union[List[Tuple[int, int]], List[int]]]


[docs] def get_serpentine_scan_list( n_views_width: int, n_views_height: int, initial_width: int = 0, initial_height: int = 0, step_width: int = 1, step_height: int = 1, ) -> List[Tuple[int, int]]: """Generates a serpentine scan order for Light Field views. :param n_views_width: Number of views in width :type n_views_width: int :param n_views_height: Number of views in height :type n_views_height: int :param initial_width: Initial horizontal offset, defaults to 0 :type initial_width: int, optional :param initial_height: Initial vertical offset, defaults to 0 :type initial_height: int, optional :param step_width: Step size in width, defaults to 1 :type step_width: int, optional :param step_height: Step size in height, defaults to 1 :type step_height: int, optional :return: List of tuples representing the scan order :rtype: List[Tuple[int, int]] """ serpentine_list: List[Tuple[int, int]] = [] for i in range(initial_height, n_views_height - initial_height, 2 * step_height): for j in range(initial_width, n_views_width - initial_width, step_width): serpentine_list.append((j, i)) if i + 1 < n_views_height - initial_height: for j in reversed( range(initial_width, n_views_width - initial_width, step_width) ): serpentine_list.append((j, i + step_height)) return serpentine_list
[docs] def get_raster_scan_list( n_views_width: int, n_views_height: int, initial_width: int = 0, initial_height: int = 0, step_width: int = 1, step_height: int = 1, ) -> List[Tuple[int, int]]: """Generates a raster scan order for Light Field views. :param n_views_width: Number of views in width :type n_views_width: int :param n_views_height: Number of views in height :type n_views_height: int :param initial_width: Initial horizontal offset, defaults to 0 :type initial_width: int, optional :param initial_height: Initial vertical offset, defaults to 0 :type initial_height: int, optional :param step_width: Step size in width, defaults to 1 :type step_width: int, optional :param step_height: Step size in height, defaults to 1 :type step_height: int, optional :return: List of tuples representing the scan order :rtype: List[Tuple[int, int]] """ raster_list: List[Tuple[int, int]] = [] for i in range(initial_height, n_views_height - initial_height, step_height): for j in range(initial_width, n_views_width - initial_width, step_width): raster_list.append((j, i)) return raster_list
[docs] def get_right_to_left_scan_list( n_views_width: int, n_views_height: int, initial_width: int = 0, initial_height: int = 0, step_width: int = 1, step_height: int = 1, ) -> List[Tuple[int, int]]: """Generates a right-to-left scan order for Light Field views. :param n_views_width: Number of views in width :type n_views_width: int :param n_views_height: Number of views in height :type n_views_height: int :param initial_width: Initial horizontal offset, defaults to 0 :type initial_width: int, optional :param initial_height: Initial vertical offset, defaults to 0 :type initial_height: int, optional :param step_width: Step size in width, defaults to 1 :type step_width: int, optional :param step_height: Step size in height, defaults to 1 :type step_height: int, optional :return: List of tuples representing the scan order :rtype: List[Tuple[int, int]] """ raster_list: List[Tuple[int, int]] = [] for i in range(initial_height, n_views_height - initial_height, step_height): for j in range(n_views_width - 1 - initial_width, initial_width - 1, -step_width): raster_list.append((j, i)) return raster_list
[docs] def get_raster_bottom_to_top_scan_list( n_views_width: int, n_views_height: int, initial_width: int = 0, initial_height: int = 0, step_width: int = 1, step_height: int = 1, ): """Generates a raster scan order from bottom to top for Light Field views. :param n_views_width: Number of views in width :type n_views_width: int :param n_views_height: Number of views in height :type n_views_height: int :param initial_width: Initial horizontal offset, defaults to 0 :type initial_width: int, optional :param initial_height: Initial vertical offset, defaults to 0 :type initial_height: int, optional :param step_width: Step size in width, defaults to 1 :type step_width: int, optional :param step_height: Step size in height, defaults to 1 :type step_height: int, optional :return: List of tuples representing the scan order :rtype: List[Tuple[int, int]] """ raster_list: List[Tuple[int, int]] = [] for i in range(n_views_height - 1 - initial_height, initial_height - 1, -step_height): for j in range(initial_width, n_views_width - initial_width, step_width): raster_list.append((j, i)) return raster_list
[docs] def get_right_to_left_bottom_to_top_scan_list( n_views_width: int, n_views_height: int, initial_width: int = 0, initial_height: int = 0, step_width: int = 1, step_height: int = 1, ): """Generates a right-to-left, bottom-to-top scan order for Light Field views. :param n_views_width: Number of views in width :type n_views_width: int :param n_views_height: Number of views in height :type n_views_height: int :param initial_width: Initial horizontal offset, defaults to 0 :type initial_width: int, optional :param initial_height: Initial vertical offset, defaults to 0 :type initial_height: int, optional :param step_width: Step size in width, defaults to 1 :type step_width: int, optional :param step_height: Step size in height, defaults to 1 :type step_height: int, optional :return: List of tuples representing the scan order :rtype: List[Tuple[int, int]] """ raster_list: List[Tuple[int, int]] = [] for i in range(n_views_height - 1 - initial_height, initial_height - 1, -step_height): for j in range(n_views_width - 1 - initial_width, initial_width - 1, -step_width): raster_list.append((j, i)) return raster_list