
216
付録 演習の解答
できました。回帰曲線も含む、完全な図
6B
です。
A.5
解答:画像の畳み込み
以下は「
4.7.6
演習:画像の畳み込み」の解答です。
from scipy import signal
x = np.random.random((50, 50))
y = np.ones((5, 5))
L = x.shape[0] + y.shape[0] - 1
Px = L - x.shape[0]
Py = L - y.shape[0]
xx = np.pad(x, ((0, Px), (0, Px)), mode='constant')
yy = np.pad(y, ((0, Py), (0, Py)), mode='constant')
zz = np.fft.ifft2(np.fft.fft2(xx) * np.fft.fft2(yy)).real
print('Resulting shape:', zz.shape, ' <-- Why?')
z = signal.convolve2d(x, y)
print('Results are equal?', np.allclose(zz, z))
平均値=7.86
入次数分布
図
A-3
図
3-18
に回帰直線を追加