def find_font_number_binary_ragions(pic_array):
    '''
    '''
    threshed_pic_array = cv2_helper.threshold_white_with_mean_percent(gray_pic)
    numbers_rectangles = find_numbers_rectangles(threshed_pic_array)
    numbers_rectangles = reversed(numbers_rectangles)

    binary_pic = cv2_helper.transfer_values(threshed_pic_array, {BLACK:0, WHITE:1})
    # numpy.count_nonzero(binary_pic).pp()

    number_binary_ragions = map(lambda c: cv2_helper.get_rect_ragion_with_contour(binary_pic, c),
        numbers_rectangles)

    number_binary_ragions = map(remove_border, number_binary_ragions)

    number_binary_ragions = map(remove_margin, number_binary_ragions)

    number_binary_ragions = map(enlarge, number_binary_ragions)

    map(check_size, number_binary_ragions)

    # number_binary_ragions[0].pp()
    return number_binary_ragions

def main():
    generate_number_images()

if __name__ == '__main__':
    from minitest import *

    # main()

    ORIGINAL_IMAGE_NAME = './images/antiqua.png'
    gray_pic = cv2.imread(ORIGINAL_IMAGE_NAME, 0)
    color_pic = cv2.imread(ORIGINAL_IMAGE_NAME)

    with test("find_numbers_rectangles"):
        threshed_pic_array = cv2_helper.threshold_white_with_mean_percent(gray_pic)
        numbers_rectangles = find_numbers_rectangles(threshed_pic_array)
        numbers_rectangles.size().must_equal(40)

        # cv2_helper.show_contours_in_pic(color_pic,numbers_rectangles)

        # other_pic = cv2.imread('./images/verdana.png', 0)
        # number_binary_ragions = find_font_number_binary_ragions(other_pic)
        # threshed_pic_array = cv2_helper.threshold_white_with_mean_percent(gray_pic)
        # numbers_rectangles = find_numbers_rectangles(threshed_pic_array)
        # numbers_rectangles.size().must_equal(40)
        # cv2_helper.show_contours_in_pic(cv2.imread('./images/verdana.png'),numbers_rectangles)


    with test("find_font_number_binary_ragions"):
        test_file_path = 'test_resources/test.dataset'