我有一张图像,我将其转换为numpy数组,然后使用scipy库对中值进行了过滤,将ndarray的所有元素都更改为零。
from PIL import Image
import numpy as np
from scipy.signal import medfilt
train = np.array(Image.open("26.jpg").getdata() ,dtype=float).reshape(176, 208, 1)
s = np.sum(train, axis =0)
print(s)
train = medfilt(train, kernel_size= 3)
s1 = np.sum(train, axis =0)
print(s1)
由于这个问题,我无法进行进一步的图像处理。
答案 0 :(得分:1)
medfilt
有效地将边界零填充。由于尺寸为1,因此在这个方向上,每个像素都夹在两个零之间,这胜过所有东西。
尝试省略三维空间
train = np.array(Image.open("26.jpg").getdata() ,dtype=float).reshape(176, 208)
你应该没事。
如果需要,可以在过滤后添加它。