def estimate_eggs_from_info(row_slice, mask_shape): """ finds all eggs for particular slice and mask them by ellipse annotated by ant, post and lat in the all info table :param row_slice: :param mask_shape: :return ndarray: ndarray """ pos_ant, pos_lat, pos_post = tl_visu.parse_annot_rectangles(row_slice) list_masks = tl_visu.draw_eggs_rectangle(mask_shape, pos_ant, pos_lat, pos_post) mask_eggs = tl_visu.merge_object_masks(list_masks, overlap_thr=0.5) return mask_eggs
def figure_draw_annot_csv(fig, img, row_slice, subfig_size=FIGURE_SIZE): """ draw from expert annotation stored in info file :param obj fig: :param ndarray img: backround image :param row_slice: line from info file containing annotation :param int subfig_size: :return obj: """ if not fig: norm_size = np.array(img.shape[:2]) / float(np.max(img.shape)) fig, ax = plt.subplots(figsize=(norm_size[::-1] * subfig_size)) ax.imshow(img[:, :, 0], cmap=plt.cm.Greys_r) else: ax = fig.gca() pos_ant, pos_lat, pos_post = tl_visu.parse_annot_rectangles(row_slice) list_masks = tl_visu.draw_eggs_rectangle(img.shape[:2], pos_ant, pos_lat, pos_post) for mask in list_masks: ax.contour(mask, colors=COLOR_ANNOT, linewidths=(3,)) return fig