[Review] What "Convolution" means mathematically?

## Preface
In this article, I would like to talk about the meaning of convolutional operation in CNN. I DO expect that you have certain understanding of CNN already.

## References
畳み込みとは何か？ http://www.ice.tohtech.ac.jp/~nakagawa/laplacetrans/convolution1.htm
畳み込みによる画像処理とは？ https://www.clg.niigata-u.ac.jp/~medimg/practice_medical_imaging/imgproc_scion/4filter/index.htm
Cross-Correlation: http://mathworld.wolfram.com/Cross-Correlation.html
Cross-Correlation vs Convolution: https://www.youtube.com/watch?v=C3EEy8adxvc

## Signal and Image
Generally speaking, we can say that signals build the foundation of any images. As you can see below. we can map the luminance of image on 3D region.
And the signal is able to be projected onto 2/3D region as well.

<img width="308" alt="Screen Shot 2018-05-02 at 15.26.06.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/14f3790f-87fc-19ad-bc33-38bf5b014c57.png">
[Reference](https://www.jstage.jst.go.jp/article/itej/67/1/67_36/_pdf)

Also, images are compositions of integers in each pixel.
<img width="373" alt="Screen Shot 2018-05-02 at 15.30.45.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/dbd99dc6-ea0b-7c94-898c-c2481bce49fb.png">
[Reference](https://qiita.com/icoxfog417/items/adbbf445d357c924b8fc)

Hence, we can borrow some arithmetic operations from signal processing to here, image processing.
And one of the most obvious one is convolution, which I aim at describing in this article.
Before facing the actual math operation, however, I would like to confirm the similarity of the meaning of the convolution process in signal processing and image processing.

### Convolution in signal processing (Conceptual Explanation)
In signal processing, we are using continuous version of convolutional approach as below.
<img width="222" alt="Screen Shot 2018-05-02 at 15.34.53.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/6ed76f85-ca88-a806-7a95-e7814a03889a.png">
[reference](http://mathtrain.jp/tatami)
By this approach, we could blend two functions $f(t)$ and $g(x-t)$.
![main-qimg-cb81d3dfbe146b84ebf717ec12722f32.png](https://qiita-image-store.s3.amazonaws.com/0/240801/f72246bb-7bfc-5cd0-9292-8479356e4e25.png)
[reference](https://www.quora.com/What-is-the-physical-significance-of-convolution)

good reference in japanese: http://www.yukisako.xyz/entry/tatamikomi

### Convolution in image processing
In image processing, as we can imagine, the image is basically discrete area.
Discrete area means, it has edges. Hence in image processing, we normally use discrete version of convolution process as below.

<img width="143" alt="Screen Shot 2018-05-02 at 15.40.07.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/412c7574-972e-dbcd-f43c-f686ab4ce34e.png">
[reference](http://mathtrain.jp/tatami)

With this approach, we can blend the image(feature map) and the weight matrix(filter). So that, the output of this math operation is partially trimmed feature map. And as you know, we apply this to each colour channel, like yellow, blue and red and so on. So the output of convolutional layer becomes the trimmed feature map in each colour channel. Note that due to the weight share rule in CNN, feature maps in channels will look similar.

So far we have seen the relationship between image processing and signal processing. But if we investigate more about convolution process, we will encounter the cross-correlation. Which is similar operation of convolution.

Cross-Correlation
<img width="421" alt="Screen Shot 2018-05-02 at 16.11.42.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/2a48a464-0719-6598-6b3f-9006603e6abc.png">

Convolution
<img width="406" alt="Screen Shot 2018-05-02 at 16.12.10.png" src="https://qiita-image-store.s3.amazonaws.com/0/240801/75ca8a4d-c438-9931-9481-756330841448.png">

The brightest video I have confirmed ever: https://www.youtube.com/watch?v=MQm6ZP1F6ms

So what they do is fundamentally analogous. But the order to traverse is completely opposite.

## Conclusion
By convolution operation, a image is multiplied a weight matrix with regard to each area containing pixels. And this gives us the smoothed version of images.  

Thank you.