edge_benchmark.py 文件源码

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

项目:lazyprogrammer 作者: inhwane 项目源码 文件源码
def convolve_flatten(X):
    # input will be (32, 32, 3, N)
    # output will be (N, 32*32)
    N = X.shape[-1]
    flat = np.zeros((N, 32*32))
    for i in xrange(N):
        #flat[i] = X[:,:,:,i].reshape(3072)
        bw = X[:,:,:,i].mean(axis=2) # make it grayscale
        Gx = convolve2d(bw, Hx, mode='same')
        Gy = convolve2d(bw, Hy, mode='same')
        G = np.sqrt(Gx*Gx + Gy*Gy)
        G /= G.max() # normalize it
        flat[i] = G.reshape(32*32)
    return flat
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号