def visualize_derivatives(image):
'''
Plot gradient on left and Laplacian on right.
Only tested on 2D 1-channel float imags
'''
dx1,dy1 = np.gradient(image)
gradient = dx1 + 1j*dy1
a1 = np.abs(gradient)
plt.figure(None,(12,6))
plt.subplot(121)
a1 = mean_center(blur(exposure.equalize_hist(unitize(a1)),1))
plt.imshow(a1,
origin='lower',interpolation='nearest',cmap='gray',extent=(0,64,)*2)
plt.title('Gradient Magnitude')
plt.subplot(122)
laplacian = scipy.ndimage.filters.laplace(image)
lhist = mean_center(
blur(exposure.equalize_hist(unitize(laplacian)),1))
plt.imshow(lhist,
origin='lower',interpolation='nearest',cmap='gray',extent=(0,64,)*2)
plt.title('Laplacian')
return gradient, laplacian
评论列表
文章目录