Reputation: 561
I would like to know how it calculates each element of the output (RxCxD) when the input image has shape RxCxD and the filter has shape rxcxD?
PS. I suppose to get output of size RxCx1
Upvotes: 1
Views: 931
Reputation: 46578
It's easier to think about in 2D, but it works the same way in 3D. The single value of output[i, j, k] = np.sum(input[i:i+r, j:j+c, k:k+D] * filter)
The output size will actually be RxCxD, but you probably want to keep only a slice in the third dimension. i.e., what you maybe want is the k = (D-1)//2
slice: convolve(input, filter)[..., (D-1)//2]
since you don't seem to want to shift in the k dimension: i.e., taking the middle of the third dimension gives you the case with complete overlap (no shift).
Upvotes: 1