def preprocess_edges(self):
# Calculate the sobel edge features
denom = 3 * 255.
grey = np.sum(self.image/denom, axis=2, keepdims=False, dtype=np.float32)
sobel_x = scipy.ndimage.sobel(grey, axis=0)
sobel_y = scipy.ndimage.sobel(grey, axis=1)
self.edge_angles = np.arctan2(sobel_y, sobel_x) # Counterclockwise
self.edge_magnitues = (sobel_x ** 2 + sobel_y ** 2) ** .5
assert(self.edge_angles.dtype == np.float32)
assert(self.edge_magnitues.dtype == np.float32)
if False:
plt.figure("EDGES")
plt.subplot(1,2,1)
plt.imshow(self.edge_magnitues, interpolation='nearest')
plt.title("MAG")
plt.subplot(1,2,2)
plt.imshow(self.edge_angles, interpolation='nearest')
plt.title("ANG")
plt.show()
评论列表
文章目录