基礎的な質問になるかと思いますが、scipyのconvolve2dの処理についてお聞きしたいです。
import numpy as np
from scipy.signal import convolve2d
def convolve():
image = np.random.randint(0,4,(4,4))
filter = np.array([[0, 0, 0], [1, 0, 0], [0, 0, 0]])
feature_map = convolve2d(image, filter, mode='valid')
print("image:")
print(image)
print("filter:")
print(filter)
print("conv:")
print(feature_map)
convolve()
上記のコードを実行した結果、
image:
[[3 3 1 0]
[3 2 1 1]
[1 1 1 0]
[1 2 1 3]]
filter:
[[0 0 0]
[1 0 0]
[0 0 0]]
conv:
[[1 1]
[1 0]]
このようになりました。
畳み込みを行うと、今回の'image','filter'の場合、
結果は、
[[3 2]
[1 1]]
となると思うのですが、convolve2dではどのような処理で
このような結果になっているのでしょうか。
それとも畳み込みの認識を間違えていますでしょうか。
よろしければ、ご回答よろしくお願い致します。