Esempio n. 1
0
def erode_img(img, file_name, file_folder, show, write):
    for iterations in range(1, 3):
        for erode in range(1, 4, 2):
            kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (erode, erode))
            eroded = cv2.erode(img, kernel, iterations=iterations)
            for rot in range(-2, 3, 2):
                dst = rotate_image(eroded, rot)
                title = 'eroded-r-' + str(rot) + '-e-' + str(erode) + '-i-' + str(iterations)
                if show:
                    show_img(title, dst)
                if write:
                    cv2.imwrite(file_folder + '/' + file_name + title + '.png', dst)
Esempio n. 2
0
def dilate_img(img, file_name, file_folder, show, write):
    for iterations in range(1, 4, 2):
        for dilate in range(1, 4, 2):
            kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (dilate, dilate))
            dilated = cv2.dilate(img, kernel, iterations=iterations)
            for rot in range(-2, 3, 2):
                dst = rotate_image(dilated, rot)
                title = 'dilated-r-' + str(rot) + '-d-' + str(dilate) + '-i-' + str(iterations)
                if show:
                    show_img(title, dst)
                if write:
                    print 'Writing ' + file_folder + '/' + file_name + title + '.png'
                    cv2.imwrite(file_folder + '/' + file_name + title + '.png', dst)