dawsonia.table_detect.scipy_proj#

Module Contents#

Functions#

table_detect_scipy_proj

get position and size for every tables Parameters

get_table_structure

projections_of_label_tables

simply_order

simplify the position of tables to avoid random position. Parameters

sort_insertion

Sort tables according to LL using Insertion Sort algorithm. Parameters

add_edge

Add the vertical or horizontal edges of a table Parameters

_get_position_old

determines the position of the maximums of a projection of an array (on x or y) therefore determine the position of the rows of a table

get_position

Detect peaks or local maxima in proj_x to find positions of the rows in the table.

Data#

logger

__all__

API#

dawsonia.table_detect.scipy_proj.logger#

‘getLogger(…)’

dawsonia.table_detect.scipy_proj.__all__#

(‘table_detect_scipy_proj’, ‘get_table_structure’, ‘projections_of_label_tables’, ‘get_position’, ‘s…

dawsonia.table_detect.scipy_proj.table_detect_scipy_proj(binary_tables: numpy.typing.NDArray[numpy.bool_], size_tables, preproc_cfg: dawsonia.typing.PreprocConfig, original_image) tuple[dawsonia.typing.TablePositions, dawsonia.typing.TableSizes, int]#

get position and size for every tables Parameters

binary_tables : array 2D binary image of an empty one-page table size_tables expected table dimensions only_top_table : boolean if True return only 2 first tables Returns

list_pos3 : list Each element of this list is a list containing the informations of each box of a table. The format of the information is::

   [
        vertical position [int],
        horizontal position [int],
        width [int],
        height [int]
   ]

the position is defined in relation to the position on the whole page
and not in relation to the relative position of the table

l_size3 : list list of size of tables (same order than list_pos3

dawsonia.table_detect.scipy_proj.get_table_structure(expected_size_tables, preproc_cfg, original_image, label_tables, projections_xy, sensibility, l_size3, list_pos3) None#
dawsonia.table_detect.scipy_proj.projections_of_label_tables(label_tables, nb_labels, min_nb_pixels)#
dawsonia.table_detect.scipy_proj.simply_order(tot_p)#

simplify the position of tables to avoid random position. Parameters

tot_p : list list of position of every tables Returns

tot_p : list list of position of every tables this list is ordered

dawsonia.table_detect.scipy_proj.sort_insertion(L, LL)#

Sort tables according to LL using Insertion Sort algorithm. Parameters

L : list same len than LL LL : list contains elements that can be sorted Returns

L : list contains L sorted elements

dawsonia.table_detect.scipy_proj.add_edge(proj: numpy.typing.NDArray) numpy.typing.NDArray#

Add the vertical or horizontal edges of a table Parameters

proj: array 1D horizontal or vertical projection of a binary table Returns

proj : array 1D horizontal or vertical projection of a binary table, edge add with the max value

dawsonia.table_detect.scipy_proj._get_position_old(proj_x: numpy.typing.NDArray) tuple[list[int], list[int]]#

determines the position of the maximums of a projection of an array (on x or y) therefore determine the position of the rows of a table

Parameters

proj_x: array 1D horizontal or vertical projection of a binary table

Returns

x_pos : list of int list of position of the middle between 2 lines. x_len : list of int list of distance between line

dawsonia.table_detect.scipy_proj.get_position(xs: numpy.typing.NDArray) tuple[numpy.typing.NDArray, numpy.typing.NDArray]#

Detect peaks or local maxima in proj_x to find positions of the rows in the table.

Parameters

proj_x: array 1D horizontal or vertical projection of a binary table

Returns

x_pos : array 1D position of the middle between 2 lines. x_len : array 1D distance between line