相关疑难解决方法(0)

使用python和numpy的2d卷积

我试图使用numpy在python中执行2d卷积

我有一个2d数组,如下所示,行内核为H_r,列为H_c

data = np.zeros((nr, nc), dtype=np.float32)

#fill array with some data here then convolve

for r in range(nr):
    data[r,:] = np.convolve(data[r,:], H_r, 'same')

for c in range(nc):
    data[:,c] = np.convolve(data[:,c], H_c, 'same')

data = data.astype(np.uint8);
Run Code Online (Sandbox Code Playgroud)

它不会产生我期望的输出,这段代码看起来不错,我认为问题在于从float32到8bit的转换.什么是最好的方法来做到这一点

谢谢

python numpy convolution

14
推荐指数
3
解决办法
4万
查看次数

标签 统计

convolution ×1

numpy ×1

python ×1