2D image convolution(二维图像卷积)
2016-04-01 10:33
225 查看
在学习cnn的过程中,对convolution的概念真的很是模糊,本来在学习图像处理的过程中,已对convolution有所了解,它与correlation是有不同的,因为convolution = correlation + filp over in both horizontal + vertical
但在CNN中,明明只是进行了correlation,但却称之为convolution,实在不解
下面, 将图像处理中的convolution重新整理记录
因为网络关于这部分的解释很多,这里直接借用其他 参考
“A convolution is done by multiplying a pixel's and its neighboring pixels color value by a matrix”, 这里的matrix就是convoluiton kernel (usually a small matrix of numbers)
这里假设图像是3*3,kernel也是3*3,实际计算中,有时为了使得卷积结果与原图像一致,会对原图像进行padding操作
原图像x:
具体数值:
表示为x的元素形式
卷积核h:
具体数值:
表示为h的元素的形式:
利用卷积核h对图像x进行卷积操作的具体的过程为:
(1)将h先上下翻转,再左右翻转
二次翻转后的h的具体数值:
二次翻转后的h的以各元素的形式表示:
(2)然后,将二次翻转后的h与x进行correlation运算,即 二次翻转后的h依次覆盖x,同时对应元素相乘并相加
矩阵x:
二次翻转后的h:
(3)输出结果为矩阵y,大小为3*3,y(1,1)的数值如下(即二次翻转后的h覆盖在x的第一个位置所得的值)
y(1,1) = h(3,3) *x(0,0) + h(3,2) *x(0,1) + h(3,1) *x(0,2) +
h(2,3) *x(1,0) + h(2,2) *x(1,1) + h(2,1) *x(1,2) +
h(1,3) *x(2,0) + h(1,2) *x(2,1) + h(1,1) *x(2,2)
其他元素类似......
注:In image
processing, a kernel, convolution matrix, or mask is a small matrix useful
for blurring, sharpening, embossing, edge-detection, and more. This is accomplished by means of convolution between
a kernel and an image.
但在CNN中,明明只是进行了correlation,但却称之为convolution,实在不解
下面, 将图像处理中的convolution重新整理记录
因为网络关于这部分的解释很多,这里直接借用其他 参考
“A convolution is done by multiplying a pixel's and its neighboring pixels color value by a matrix”, 这里的matrix就是convoluiton kernel (usually a small matrix of numbers)
这里假设图像是3*3,kernel也是3*3,实际计算中,有时为了使得卷积结果与原图像一致,会对原图像进行padding操作
原图像x:
具体数值:
0 | 0 | 0 | 0 | 0 |
0 | 1 | 2 | 3 | 0 |
0 | 4 | 5 | 6 | 0 |
0 | 7 | 8 | 9 | 0 |
0 | 0 | 0 | 0 | 0 |
x(0,0) | x(0,1) | x(0,2) | x(0,3) | x(0,4) |
x(1,0) | x(1,1) | x(1,2) | x(1,3) | x(1,4) |
x(2,0) | x(2,1) | x(2,2) | x(2,3) | x(2,4) |
x(3,0) | x(3,1) | x(3,2) | x(3,3) | x(3,4) |
x(4,0) | x(4,1) | x(4,2) | x(4,3) | x(4,4) |
具体数值:
-1 | -2 | -1 |
0 | 0 | 0 |
1 | 2 | 1 |
h(1,1) | h(1,2) | h(1,3) |
h(2,1) | h(2,2) | h(2,3) |
h(3,1) | h(3,2) | h(3,3) |
(1)将h先上下翻转,再左右翻转
二次翻转后的h的具体数值:
1 | 2 | 1 |
0 | 0 | 0 |
-1 | -2 | -1 |
h(3,3) | h(3,2) | h(3,1) |
h(2,3) | h(2,2) | h(2,1) |
h(1,1) | h(1,2) | h(1,1) |
矩阵x:
x(0,0) | x(0,1) | x(0,2) | x(0,3) | x(0,4) |
x(1,0) | x(1,1) | x(1,2) | x(1,3) | x(1,4) |
x(2,0) | x(2,1) | x(2,2) | x(2,3) | x(2,4) |
x(3,0) | x(3,1) | x(3,2) | x(3,3) | x(3,4) |
x(4,0) | x(4,1) | x(4,2) | x(4,3) | x(4,4) |
h(3,3) | h(3,2) | h(3,1) |
h(2,3) | h(2,2) | h(2,1) |
h(1,1) | h(1,2) | h(1,1) |
y(1,1) = h(3,3) *x(0,0) + h(3,2) *x(0,1) + h(3,1) *x(0,2) +
h(2,3) *x(1,0) + h(2,2) *x(1,1) + h(2,1) *x(1,2) +
h(1,3) *x(2,0) + h(1,2) *x(2,1) + h(1,1) *x(2,2)
其他元素类似......
注:In image
processing, a kernel, convolution matrix, or mask is a small matrix useful
for blurring, sharpening, embossing, edge-detection, and more. This is accomplished by means of convolution between
a kernel and an image.
相关文章推荐
- 3*3卷积核实例
- 数据结构 顺序串的各种基本运算
- 当提示找不到某个文件路径的时候
- 深搜+回溯 poj3009 Curling 2.0
- Unity中实现高效Signal-slot模式--高效消息分发
- ./ggsci: error while loading shared libraries: libnnz11.so: cannot open shared object file: No such
- 菜鸟的Android学习笔记(二)
- Flex 布局教程:语法篇
- matlab的二维卷积操作
- 如何分析matlab程序的主要效率问题
- 安装Java
- JDK的帮助文档
- 第一个deeplearning4jproject跑起
- (转)Eclipse 下找不到或无法加载主类的解决办法
- PyCharm使用技巧记录(一)如何查看变量
- 到底该如何入门Keras、Theano呢?(浅谈)
- Keras如何构造简单的CNN网络
- PyCharm如何设置显示行号?
- Python/Keras如何将给定的数据集打乱
- Python如何进行cross validation training