def dent_detection(img, num, angle):
    accum = np.zeros_like(img)
    ksize = 9
    for theta in np.arange(0, np.pi, np.pi / 4):
        kernel = cv2.getGaborKernel((ksize, ksize), 10, theta, 18, 0.25, 0, ktype=cv2.CV_32F)
        kernel /= 1.5 * kernel.sum()
        fimg = cv2.filter2D(img, cv2.CV_8UC3, kernel)
        np.maximum(accum, fimg, accum)
    #
    # save_image('A2_accum', accum)
    _, thresh = cv2.threshold(accum, 161, 255, cv2.THRESH_BINARY)

    sobel = convolve_sobel(img=accum,
                           threshold=18,
                           sobel_kernel_left_right=True,
                           sobel_kernel_right_left=True,
                           sobel_kernel_top_bottom=True,
                           sobel_kernel_bottom_top=True,
                           sobel_kernel_diagonal_top_left=True,
                           sobel_kernel_diagonal_bottom_left=False,
                           sobel_kernel_diagonal_top_right=True,
                           sobel_kernel_diagonal_bottom_right=False)
    sobel = cv2.convertScaleAbs(sobel)
    #save_image("A2_sobel" + str(num), sobel)

    # pos = np.where(accum < 162)
    # test_image[pos] = 255
    # save_image("A5_test_image" + str(num), test_image)

    test_image = np.zeros_like(sobel)

    pos_y, pos_x = np.where(sobel == 255)
    if pos_x.size != 0:
        if angle > -45:
            #right teeth
            print("right teeth",angle)

            for x in np.nditer(pos_x):
                for y in np.nditer(pos_y):
                    if x < 80:
                        test_image[(y, x)] = sobel[(y, x)]
            save_image('testimage' + str(num), test_image)

        if angle < -45 and angle > -75:
            #left teeth
            print("left teeth" + str(num), angle)

            for x in np.nditer(pos_x):
                for y in np.nditer(pos_y):
                    if x > 20:
                        test_image[(y, x)] = sobel[(y, x)]
            save_image('testimage' + str(num), test_image)

        if angle < -75:
            # front teeth
            test_image = sobel
            save_image('testimage' + str(num), test_image)

    return True
def test_for_lap(image):
	global stack_img

	image = cv2.medianBlur(image,5)
	# cv2.imshow("blur",image)
	# cv2.waitKey(0)
	# cv2.destroyAllWindows()

	# if debug:
	# 	showimage("blur",blur)

	sobel = convolve_sobel(img=image,
                   threshold=30,
                   sobel_kernel_left_right=True,
                   sobel_kernel_right_left=True,
                   sobel_kernel_top_bottom=False,
                   sobel_kernel_bottom_top=False,
                   sobel_kernel_diagonal_top_left=False,
                   sobel_kernel_diagonal_bottom_left=False,
                   sobel_kernel_diagonal_top_right=False,
                   sobel_kernel_diagonal_bottom_right=False)
	sobel = cv2.convertScaleAbs(sobel)

	if debug:
		showimage("sobel",sobel)


	gaus = cv2.GaussianBlur(sobel, (3,3), -1)

	if debug:
		showimage("Gaussian",gaus)

	_,thresh = cv2.threshold(gaus,200,255,cv2.THRESH_BINARY)

	if debug:
		showimage("thresh",thresh)

	stack_img = cv2.bitwise_or(stack_img,thresh)

	if debug:
		showimage("stack image",stack_img)
Exemple #3
0
def flank_dent_detection(img, num):
    accum = np.zeros_like(img)
    test_image = np.zeros_like(img)
    ksize = 9
    for theta in np.arange(0, np.pi, np.pi / 4):
        kernel = cv2.getGaborKernel((ksize, ksize),
                                    10,
                                    theta,
                                    18,
                                    0.25,
                                    0,
                                    ktype=cv2.CV_32F)
        kernel /= 1.5 * kernel.sum()
        fimg = cv2.filter2D(img, cv2.CV_8UC3, kernel)
        np.maximum(accum, fimg, accum)
    #
    showimage('A2_accum', accum)
    _, thresh = cv2.threshold(accum, 161, 255, cv2.THRESH_BINARY)
    showimage("A3_thresh" + str(num), thresh)

    sobel = convolve_sobel(img=accum,
                           threshold=10,
                           sobel_kernel_left_right=True,
                           sobel_kernel_right_left=True,
                           sobel_kernel_top_bottom=True,
                           sobel_kernel_bottom_top=True,
                           sobel_kernel_diagonal_top_left=True,
                           sobel_kernel_diagonal_bottom_left=False,
                           sobel_kernel_diagonal_top_right=True,
                           sobel_kernel_diagonal_bottom_right=False)
    sobel = cv2.convertScaleAbs(sobel)
    showimage("A2_sobel" + str(num), sobel)

    pos = np.where(accum < 162)
    test_image[pos] = 255

    showimage("A5_test_image" + str(num), test_image)

    return test_image
Exemple #4
0
def test_for_lap(image):
    global stack_img

    blur = cv2.medianBlur(image, 3)

    # if debug:
    # 	showimage("blur",blur)

    sobel = convolve_sobel(img=blur,
                           threshold=50,
                           sobel_kernel_left_right=True,
                           sobel_kernel_right_left=True,
                           sobel_kernel_top_bottom=True,
                           sobel_kernel_bottom_top=True,
                           sobel_kernel_diagonal_top_left=False,
                           sobel_kernel_diagonal_bottom_left=False,
                           sobel_kernel_diagonal_top_right=False,
                           sobel_kernel_diagonal_bottom_right=False)
    sobel = cv2.convertScaleAbs(sobel)

    if debug:
        showimage("sobel", sobel)

    gaus = cv2.GaussianBlur(sobel, (15, 15), -1)

    if debug:
        showimage("Gaussian", gaus)

    _, thresh = cv2.threshold(gaus, 200, 255, cv2.THRESH_BINARY)

    if debug:
        showimage("thresh", thresh)

    stack_img = cv2.bitwise_or(stack_img, thresh)

    if debug:
        showimage("stack image", stack_img)