python类guvectorize()的实例源码

kernels.py 文件源码 项目:formation_python2017 作者: gouarin 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def convolve_laplacien2_gu(image, index, out_image):
    nx, ny = image.shape
    for j in range(1,ny-1):
        out_image[j-1] = np.abs(4*image[index[0],j]-image[index[0]-1,j]-image[index[0]+1,j]
                                                   -image[index[0],j-1]-image[index[0],j+1])

#@numba.guvectorize(['(float64[:,:], int64[:], int64[:], float64[:])'], '(nx, ny),(),()->()', target='parallel', nopython=True)
#def convolve_laplacien2_gu(image, i, j, out_image):
#    nx, ny = image.shape
#    out_image[0] = np.abs(4*image[i[0],j[0]]-image[i[0]-1,j[0]]-image[i[0]+1,j[0]]
#                                            -image[i[0],j[0]-1]-image[i[0],j[0]+1])

#@numba.jit
#def convolve_laplacien2(image):
#    height, width = image.shape
#    out_image = np.empty((height-2,width-2))
#    i = np.arange(1, height-1)[:, np.newaxis]
#    j = np.arange(1, width-1)[np.newaxis, :]
#    convolve_laplacien2_gu(image, i, j, out_image)
#    # On renormalise l'image :
#    valmax = np.max(out_image)
#    valmax = max(1.,valmax)+1.E-9
#    out_image *= 1./valmax
#    return out_image


问题


面经


文章

微信
公众号

扫码关注公众号