encoders.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:HTM_experiments 作者: ctrl-z-9000-times 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号