Esempio n. 1
0
def downsized_hough(originals, images):
    downsized = functions.process_several(
        originals,
        function=reshape.standard_resize,
        new_width=200.0,
        return_ratio=False
    )  # breaking because now returning ratio from std. resize
    processed_downsized = functions.process_several(
        downsized, function=functions.downsized_text_edging)
    rotated_images = functions.draw_several(
        processed_downsized,
        drawing_images=downsized,
        function=prob_hough_rotation)  # downsize -> process -> Hough
    return rotated_images
Esempio n. 2
0
def hough_fullsized(images):
    processed = functions.process_several(images,
                                          function=functions.text_edging)
    rotated_images = functions.draw_several(processed,
                                            drawing_images=originals,
                                            function=prob_hough_rotation)
    return rotated_images
Esempio n. 3
0
def hough_downsized(originals, images):
    downsized = functions.process_several(originals,
                                          function=reshape.standard_resize)
    processed = functions.process_several(images,
                                          function=functions.text_edging)
    downsized_processed = functions.process_several(
        processed,
        function=reshape.standard_resize,
        new_width=200.0,
        return_ratio=False)
    # rotated_images = functions.draw_several(downsized_processed, drawing_images = downsized_processed, function = prob_hough_rotation)
    rotated_images = functions.draw_several2(
        downsized_processed,
        drawing_images=downsized_processed,
        function=prob_hough)
    functions.plot_images(rotated_images)
    return rotated_images
Esempio n. 4
0
def downsized_canny_dilated(image):
    downsized, ratio = functions.standard_resize(image)
    edged, titles = canny(downsized)
    originals = utility.image_array(downsized, array_length = len(edged))
    
    kernel = np.ones((5,5),np.uint8) # original was 15x15. 5x5 is working well right now. 
    dilated = functions.process_several(images = edged, function = cv2.dilate, kernel = kernel)
    detected = functions.draw_several(images = dilated, drawing_images = originals, function = demo.vanilla_box_drawing)

    functions.plot_images(dilated, titles)
    functions.plot_images(detected,titles)
Esempio n. 5
0
def downsized_canny_CI(image):
    downsized, ratio = functions.standard_resize(image, new_width = 250.0)
    # edged, titles = canny_thresh(downsized)
    edged, titles = canny(downsized)
    originals = utility.image_array(downsized, array_length = len(edged))
    closed_inverted = functions.process_several(images = edged, function = functions.closed_inversion)
    # detected = functions.process_several(images = closed_inverted, function = demo.vanilla_boxing)
    detected = functions.draw_several(images = closed_inverted, drawing_images = originals, function = demo.vanilla_box_drawing)

    functions.plot_images(edged,titles)
    # functions.plot_images(closed_inverted, titles)
    functions.plot_images(detected,titles)
Esempio n. 6
0
def canny_comparison(image):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    blurred = cv2.GaussianBlur(gray, (5, 5), 0)
    canny = cv2.Canny(blurred, threshold1 = 0, threshold2 = 40, apertureSize=3)
    l2_canny = cv2.Canny(blurred, threshold1 = 0, threshold2 = 80, apertureSize=3 , L2gradient=False) 
    # l2_canny = cv2.Canny(blurred, threshold1 = 0, threshold2 = 80, apertureSize=3)
    canny2 = cv2.Canny(blurred, threshold1 = 0, threshold2 = 100, apertureSize=3)
    l2_canny2 = cv2.Canny(blurred, threshold1 = 0, threshold2 = 160, apertureSize=3 , L2gradient=False) 
    canny3 = cv2.Canny(blurred, threshold1 = 75, threshold2 = 200, apertureSize=3, L2gradient=False)
    canny4 = cv2.Canny(blurred, threshold1 = 0, threshold2 = 200, apertureSize=3)
    kernel = np.ones((5,5),np.uint8) # original was 15x15. 5x5 is working well right now. 
    dilated_canny = cv2.dilate(canny, kernel, iterations=1) 
    edged = [gray, canny, l2_canny, canny2, l2_canny2, canny3, canny4]
    dilated = functions.process_several(images = edged, function = cv2.dilate, kernel = kernel)
    # dilated_l2 = cv2.dilate(l2_canny, kernel, iterations=1)
    # functions.plot_images([gray, dilated_canny, dilated_l2, canny2, l2_canny2])
    functions.plot_images(dilated)
Esempio n. 7
0
    # files = ["pics/forms/E-Ticketing.png", "pics/indoor_720.jpg", "pics/forms/sample4_2.jpg"]

    # files = utility.filenames_at_path("/media/thor/LEXAR/sampleDataset/input_sample", ".jpg") # hough threshold of 30 is best here
    # files = utility.filenames_at_path("/home/thor/code/sr_project/pics/forms", ".jpg")

    originals, images = utility.image_reading(files[:20])

    for image in images:
        detection(image.copy())
        # text_region_method(image.copy())
        # downsized_text_blobbing(image.copy())

    originals, images = utility.image_reading(files)
    # results = functions.process_several(images, function = pipeline)
    # results = functions.process_several(images, function = downsized_text_blobbing)
    results = functions.process_several(images, function=text_region_method)
    functions.plot_images(results, files)
    # text_region_method2(image)
    # text_region_method(image)
    # downsized_text_blobbing(image)

    # canny_comparison(image)
    # dilation_canny(image)
    # rotate(image, 20)
    # occlusion_demo(image)
    # original_demo(image)

    hull_attempt(image)

    # alternate_rect_attempt(image)
Esempio n. 8
0
    
def morph_comparison(image):
    return 2


if __name__ == '__main__':
    # image = cv2.imread(sys.argv[1])
    # orig = image.copy()

    # image = functions.standard_resize(image, new_width = 1000.0)
    # edged = functions.text_edging(image)
    # edged = functions.page_edging(image)
    # downsized, _ = functions.standard_resize(edged, new_width = 100.0)
    # functions.plot_images([downsized])
    # downsized, _ = functions.standard_resize(image, new_width = 100.0)
    # canny_comparison(downsized)

    files = ["pics/demo/IMAG0603.jpg", "pics/demo/IMAG0604.jpg", "pics/demo/IMAG0605.jpg", "pics/demo/IMAG0606.jpg", "pics/demo/IMAG0607.jpg", "pics/demo/IMAG0608.jpg", "pics/demo/IMAG0611.jpg", "pics/demo/IMAG0612.jpg"]
    # files = ["pics/forms/sample5.jpg", "pics/forms/sample2.jpg", "pics/forms/sample3.jpg", "pics/forms/sample4_4.jpg", "pics/forms/sample9.jpg", "pics/forms/sample11.jpg", "pics/forms/sample8.jpg", "pics/forms/sample12.jpg"]
    # files = ["pics/forms/sample5.jpg", "pics/forms/sample2.jpg", "pics/forms/sample4_4.jpg", "pics/forms/sample11.jpg", "pics/forms/sample12.jpg", "pics/forms/sample10.jpg"]

    originals, images = utility.image_reading(files)

    # res = functions.process_several(images,downsized_canny)
    # res = functions.process_several(images,downsized_canny_finetune)
    # res = functions.process_several(images,downsized_canny_dilated)
    res = functions.process_several(images,downsized_canny_CI)
    # res = functions.process_several(images,downsized_canny_detection)
    # result = functions.process_several()