import numpy as np from skimage import io from skimage import feature from skimage.color import rgb2gray from skimage.filters import roberts, sobel def get_log_edges(blobs_log, shape): image = np.zeros(shape) #blobs_log[:, 2] = blobs_log[:, 2] * sqrt(2) for blob in blobs_log: x, y, r = blob image[int(x), int(y)] = 1 return image img = io.imread('yale.png') print("The dimension of the original image is {0}".format(np.shape(img))) io.imshow(img) io.show() # https://scikit-image.org/docs/dev/auto_examples/color_exposure/plot_rgb_to_gray.html grey_img = rgb2gray(img) print("The dimension of the greyscale image is {0}".format(np.shape(grey_img))) io.imshow(grey_img) io.show() # https://scikit-image.org/docs/dev/auto_examples/edges/plot_edge_filter.html sobel_edge = sobel(grey_img) io.imshow(sobel_edge) io.show() robert_cross_edge = roberts(grey_img) io.imshow(robert_cross_edge) io.show() # https://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.blob_log #get_log_edges(feature.blob_log(grey_img), np.shape(grey_img)) #blobs_logs = feature.blob_log(grey_img) #laplacian_of_gaussian_edge = get_log_edges(blobs_logs, np.shape(grey_img)) #io.imshow(laplacian_of_gaussian_edge) #io.show() # https://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.canny canny_edge = feature.canny(grey_img) io.imshow(canny_edge) io.show() # low threshold #canny_edge = feature.canny(grey_img, low_threshold=0.1, high_threshold = 0.9) #io.imshow(canny_edge) #io.show() #canny_edge = feature.canny(grey_img, low_threshold=0.7, high_threshold = 0.9) #io.imshow(canny_edge) #io.show() ## high threshold #canny_edge = feature.canny(grey_img, low_threshold=0.1, high_threshold = 0.2) #io.imshow(canny_edge) #io.show() #canny_edge = feature.canny(grey_img, low_threshold=0.1, high_threshold = 0.9) #io.imshow(canny_edge) #io.show() ## sigma #canny_edge = feature.canny(grey_img, sigma = 0.1) #io.imshow(canny_edge) #io.show() #canny_edge = feature.canny(grey_img, sigma = 3.0) #io.imshow(canny_edge) #io.show()