img_clean = draw.draw_bounding_box(org,
                                   corners_img,
                                   color=(255, 255, 255),
                                   line=-1)
if is_ocr:
    draw_bounding, word = ocr.text_detection(org, img_clean)
else:
    draw_bounding = org
img_clean = draw.draw_bounding_box(img_clean,
                                   corners_compo,
                                   color=(255, 255, 255),
                                   line=-1)

# *** Step 6 *** post-processing: remove img elements from original image and segment into smaller size
if is_segment:
    seg.segment_img(img_clean, 600, 'output/segment')
# draw results
draw_bounding = draw.draw_bounding_box_class(
    draw_bounding, corners_block, ['block' for i in range(len(corners_block))])
draw_bounding = draw.draw_bounding_box_class(
    draw_bounding, corners_img, ['img' for j in range(len(corners_img))])
draw_bounding = draw.draw_bounding_box_class(
    draw_bounding, corners_compo, ['compo' for j in range(len(corners_compo))])
draw_boundary = draw.draw_boundary(boundary_rec, org.shape)
# save results
if is_save:
    cv2.imwrite('output/org.png', org)
    cv2.imwrite('output/labeled.png', draw_bounding)
    cv2.imwrite('output/boundary.png', draw_boundary)
    cv2.imwrite('output/gradient.png', binary)
    cv2.imwrite('output/clean.png', img_clean)
        binary, C.THRESHOLD_MIN_OBJ_AREA, C.THRESHOLD_MIN_REC_PARAMETER,
        C.THRESHOLD_MIN_REC_EVENNESS, C.THRESHOLD_MAX_LINE_THICKNESS,
        C.THRESHOLD_MIN_LIN_LENGTH, C.THRESHOLD_MAX_IMG_DENT_RATIO)
    # get corner of boundaries -> img or block check
    corners_rec = det.get_corner(boundary_rec)
    corners_block, corners_img = det.block_or_img(
        binary, corners_rec, C.THRESHOLD_MAX_BLOCK_BORDER_THICKNESS,
        C.THRESHOLD_MAX_BLOCK_CROSS_POINT)
    # refine img component
    corners_img = det.img_refine2(corners_img, C.THRESHOLD_MAX_IMG_EDGE_RATIO,
                                  C.THRESHOLD_MUST_IMG_HEIGHT,
                                  C.THRESHOLD_MUST_IMG_WIDTH)

    # *** Step 3 *** post-processing: remove img elements from original image and segment into smaller size
    img_clean = draw.draw_bounding_box(corners_img, org, (255, 255, 255), -1)
    seg.segment_img(img_clean, 600, out_img_segment, 0)
    # draw results
    draw_bounding = draw.draw_bounding_box(corners_block, org, (0, 255, 0))
    draw_bounding = draw.draw_bounding_box(corners_img, draw_bounding,
                                           (0, 0, 255))
    # draw_boundary = draw.draw_boundary(boundary_rec, org.shape)
    # save results
    if is_save:
        cv2.imwrite(out_img_draw, draw_bounding)
        cv2.imwrite(out_img_gradient, binary)
        cv2.imwrite(out_img_clean, img_clean)
        file.save_corners(out_label, corners_block, 'div')
        file.save_corners(out_label, corners_img, 'img', False)

    end = file.timer(start)
    print('Save ' + index + '\n')