def nesting_inspection(org, grey, compos, ffl_block):
    '''
    Inspect all big compos through block division by flood-fill
    :param ffl_block: gradient threshold for flood-fill
    :return: nesting compos
    '''
    nesting_compos = []
    for i, compo in enumerate(compos):
        if compo.height > 50:
            replace = False
            clip_org = compo.compo_clipping(org)
            clip_grey = compo.compo_clipping(grey)
            n_compos = blk.block_division(clip_grey,
                                          org,
                                          grad_thresh=ffl_block,
                                          show=False)
            Compo.cvt_compos_relative_pos(n_compos, compo.bbox.col_min,
                                          compo.bbox.row_min)

            for n_compo in n_compos:
                if n_compo.redundant:
                    compos[i] = n_compo
                    replace = True
                    break
            if not replace:
                nesting_compos += n_compos
    return nesting_compos
Exemple #2
0
def nesting_inspection(org, grey, compos):
    nesting_compos = []
    for i, compo in enumerate(compos):
        if compo.height > 50:
            replace = False
            clip_org = compo.compo_clipping(org)
            clip_grey = compo.compo_clipping(grey)
            n_compos = blk.block_division(clip_grey, org, show=False)
            Compo.cvt_compos_relative_pos(n_compos, compo.bbox.col_min,
                                          compo.bbox.row_min)

            for n_compo in n_compos:
                if n_compo.redundant:
                    compos[i] = n_compo
                    replace = True
                    break

            if not replace:
                nesting_compos += n_compos
            # cv2.imshow('clip', clip_org)
            # cv2.waitKey()
    return nesting_compos
Exemple #3
0
def processing_block(org, binary, blocks, block_pad):
    image_shape = org.shape
    uicompos_all = []
    for block in blocks:
        # *** Step 2.1 *** check: examine if the block is valid layout block
        if block.block_is_top_or_bottom_bar(image_shape,
                                            C.THRESHOLD_TOP_BOTTOM_BAR):
            continue
        if block.block_is_uicompo(image_shape, C.THRESHOLD_COMPO_MAX_SCALE):
            uicompos_all.append(block)

        # *** Step 2.2 *** binary map processing: erase children block -> clipping -> remove lines(opt)
        binary_copy = binary.copy()
        for i in block.children:
            blocks[i].block_erase_from_bin(binary_copy, block_pad)
        block_clip_bin = block.compo_clipping(binary_copy)
        # det.line_removal(block_clip_bin, show=True)

        # *** Step 2.3 *** component extraction: detect components in block binmap -> convert position to relative
        uicompos = det.component_detection(block_clip_bin)
        Compo.cvt_compos_relative_pos(uicompos, block.bbox.col_min,
                                      block.bbox.row_min)
        uicompos_all += uicompos
    return uicompos_all