def cbad_post_processing_fn( probs: np.array, sigma: float = 2.5, low_threshold: float = 0.8, high_threshold: float = 0.9, filter_width: float = 0, vertical_maxima: bool = False, output_basename=None) -> Tuple[List[np.ndarray], np.ndarray]: """ :param probs: output of the model (probabilities) in range [0, 255] :param sigma: :param low_threshold: :param high_threshold: :param filter_width: :param output_basename: :param vertical_maxima: :return: contours, mask WARNING : contours IN OPENCV format List[np.ndarray(n_points, 1, (x,y))] """ contours, lines_mask = line_extraction_v1(probs[:, :, 1], sigma, low_threshold, high_threshold, filter_width, vertical_maxima) if output_basename is not None: dump_pickle(output_basename + '.pkl', (contours, lines_mask.shape)) return contours, lines_mask
def cbad_post_processing_fn( probs: np.array, baseline_chanel: int = 1, sigma: float = 2.5, low_threshold: float = 0.8, high_threshold: float = 0.9, filter_width: float = 0, vertical_maxima: bool = False, output_basename=None) -> Tuple[List[np.ndarray], np.ndarray]: """ Given a probability map, returns the contour of lines and the corresponding mask. Saves the results in .pkl file if requested. :param probs: output of the model (probabilities) in range [0, 255] :param baseline_chanel: channel where the baseline class is detected :param sigma: sigma value for gaussian filtering :param low_threshold: hysteresis low threshold :param high_threshold: hysteresis high threshold :param filter_width: percentage of the image width to filter out lines that are close to borders (default 0.0) :param output_basename: name of file to save the intermediaty result as .pkl file. :param vertical_maxima: set to True to use vertical local maxima as candidates for the hysteresis thresholding :return: contours, mask WARNING : contours IN OPENCV format List[np.ndarray(n_points, 1, (x,y))] """ contours, lines_mask = line_extraction_v1(probs[:, :, baseline_chanel], sigma, low_threshold, high_threshold, filter_width, vertical_maxima) if output_basename is not None: dump_pickle(output_basename + '.pkl', (contours, lines_mask.shape)) return contours, lines_mask
def cbad_post_processing_fn(probs: np.array, sigma: float=2.5, low_threshold: float=0.8, high_threshold: float=0.9, filter_width: float=0, output_basename=None): """ :param probs: output of the model (probabilities) in range [0, 255] :param filename: filename of the image processed :param xml_output_dir: directory to export the resulting PAGE XML :param upsampled_shape: shape of the original image :param sigma: :param low_threshold: :param high_threshold: :return: contours, mask WARNING : contours IN OPENCV format List[np.ndarray(n_points, 1, (x,y))] """ contours, lines_mask = line_extraction_v1(probs[:, :, 1], sigma, low_threshold, high_threshold, filter_width) if output_basename is not None: dump_pickle(output_basename+'.pkl', (contours, lines_mask.shape)) return contours, lines_mask