コード例 #1
0
def fill_cornea(edge_image):

    k1 = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 10))
    res1 = cv2.morphologyEx(edge_image, cv2.MORPH_DILATE, k1)
    print("DILATED")
    #Loader.print_image(res1)
    enhance_black = smooth.min_filter(res1, 7)
    print("BLACk")
    #Loader.print_image(enhance_black)
    k2 = cv2.getStructuringElement(cv2.MORPH_RECT, (10, 5))
    res2 = cv2.morphologyEx(enhance_black, cv2.MORPH_ERODE, k2)
    print("eroded")
    #Loader.print_image(res2)
    res3 = smooth.max_filter(res2, 3)
    res3 = smooth.gaussian(res3, 1.5)
    print("dilated")
    #Loader.print_image(res3)

    return res3
コード例 #2
0
def denoising_comparison(input_image, hist: bool = False):
    # NON LOCAL MEAN DENOISING
    nl_means_denoised_img = smooth.denoising_NlMeans(input_image)
    # MEDIAN FILTER DENOISING
    mean_denoised_img = smooth.median_filter(input_image, 9)
    mean_denoised_img = smooth.median_filter(input_image, 9)
    # GAUSSIAN DENOISING
    gaussian_denoised = smooth.gaussian(input_image, 1.5)
    # MINIMUM FILTER
    minimum_denoised = smooth.min_filter(input_image, (5, 5))
    # MAXIMUM FILTER
    maximum_denoised = smooth.max_filter(input_image, (5, 5))

    denoised_imgs = [
        img, gaussian_denoised, mean_denoised_img, nl_means_denoised_img,
        minimum_denoised, maximum_denoised
    ]
    denoised_titles = [
        "Original", "Denoised Gaussian", "Median Filtered", "NL Means Filter",
        "Minimums Filter", "Maximums Filter"
    ]
    Loader.hist_compare(denoised_imgs, denoised_titles, hist)

    return denoised_imgs, denoised_titles
コード例 #3
0
    # Loader.print_image(front)

    for i in np.arange(1, 13):
        img = Loader.load_image("im" + i.__str__() + ".jpeg")
        print("Loaded image " + "im" + i.__str__() + ".jpeg")
        # DENOISING IMAGE
        denoised_img = smooth.median_filter(img, 9)
        denoised_img = smooth.median_filter(denoised_img, 7)

        # thresholding_comparison(denoised_img)
        th_img = thresh.apply_thresholding_algorithm(denoised_img,
                                                     thresh.THRESH_TRIANGLE)
        #Suavizamos los bordes marcados por la segmentacion
        kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (15, 5))
        stretched = cv2.morphologyEx(th_img, cv2.MORPH_ERODE, kernel)
        smoothed_thresholded = smooth.max_filter(stretched, 5)
        #Obtenemos las areas correspondientes a la imagen original, despues del segmentado
        back, front = thresh.get_regions(denoised_img, stretched)

        IMAGE_TYPE_CLASSIFICATION = define_image_properties(
            smoothed_thresholded)
        if IMAGE_TYPE_CLASSIFICATION == "A":
            # RESOLUTION 1
            print("Executing custom resolution, mode 1")
            # EDGE DETECTION
            #eq = Loader.equalization(front.astype("uint8"))
            eq = Loader.bright_and_contrast(front.astype("uint8"), 1.0, 20)
            eq = smooth.gaussian(eq, 1.5)
            #Loader.print_image(eq)
            edges = edg.laplacian_of_gaussian(eq, 2)
            #Loader.print_image(edges)