2D image convolution

在学习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:

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)

卷积核h:

-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)

具体的过程为:

将h先上下翻转,再左右翻转,然后,与x进行correlation运算

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)

输出结果y:3*3

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 kernelconvolution 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.

时间: 2024-11-12 20:52:05

2D image convolution的相关文章

Understanding Convolution in Deep Learning

Understanding Convolution in Deep Learning Convolution is probably the most important concept in deep learning right now. It was convolution and convolutional nets that catapulted deep learning to the forefront of almost any machine learning task the

TensorflowTutorial_二维数据构造简单CNN

使用二维数据构造简单卷积神经网络 觉得有用的话,欢迎一起讨论相互学习~Follow Me 图像和一些时序数据集都可以用二维数据的形式表现,我们此次使用随机分布的二位数据构造一个简单的CNN-网络卷积-最大池化-全连接 参考代码 # Implementing Different Layers # --------------------------------------- # # We will illustrate how to use different types # of layers

Convolution Network及其变种(反卷积、扩展卷积、因果卷积、图卷积)

今天,主要和大家分享一下最近研究的卷积网络和它的一些变种. 首先,介绍一下基础的卷积网络. 通过PPT上的这个经典的动态图片可以很好的理解卷积的过程.图中蓝色的大矩阵是我们的输入,黄色的小矩阵是卷积核(kernel,filter),旁边的小矩阵是卷积后的输入,通常称为feature map. 从动态图中,我们可以很明白的看出卷积实际上就是加权叠加. 同时,从这个动态图可以很明显的看出,输出的维度小于输入的维度.如果我们需要输出的维度和输入的维度相等,这就需要填充(padding). 现在我们来看

【转载】Caffe (Convolution Architecture For Feature Extraction)

Caffe (Convolution Architecture For Feature Extraction)作为深度学习CNN一个非常火的框架,对于初学者来说,搭建Linux下的Caffe平台是学习深度学习关键的一步,其过程也比较繁琐,回想起当初折腾的那几天,遂总结一下Ubuntu14.04的配置过程,方便以后新手能在此少走弯路. 1. 安装build-essentials 安装开发所需要的一些基本包 sudo apt-get install build-essential 2. 安装NVID

Deep Learning 十_深度学习UFLDL教程:Convolution and Pooling_exercise(斯坦福大学深度学习教程)

前言 理论知识:UFLDL教程和http://www.cnblogs.com/tornadomeet/archive/2013/04/09/3009830.html 实验环境:win7, matlab2015b,16G内存,2T机械硬盘 实验内容:Exercise:Convolution and Pooling.从2000张64*64的RGB图片(它是the STL10 Dataset的一个子集)中提取特征作为训练数据集,训练softmax分类器,然后从3200张64*64的RGB图片(它是th

【DeepLearning】Exercise:Convolution and Pooling

Exercise:Convolution and Pooling 习题链接:Exercise:Convolution and Pooling cnnExercise.m %% CS294A/CS294W Convolutional Neural Networks Exercise % Instructions % ------------ % % This file contains code that helps you get started on the % convolutional n

Convolution & Pooling exercise

convolution First, we want to compute σ(Wx(r,c) + b) for all valid (r,c) (valid meaning that the entire 8x8 patch is contained within the image; this is as opposed to a full convolution, which allows the patch to extend outside the image, with the ar

Deeplearning - Overview of Convolution Neural Network

Finally pass all the Deeplearning.ai courses in March! I highly recommend it! If you already know the basic then you may be interested in course 4 & 5, which shows many interesting cases in CNN and RNN. Altough I do think that 1 & 2 is better stru

译:Local Spectral Graph Convolution for Point Set Feature Learning-用于点集特征学习的局部谱图卷积

标题:Local Spectral Graph Convolution for Point Set Feature Learning 作者:Chu Wang, Babak Samari, Kaleem Siddiqi 译者:Elliott Zheng 来源:ECCV 2018 Abstract 点云的特征学习已经显示出巨大的希望,引入了有效且可推广的深度学习框架,例如pointnet ++. 然而,到目前为止,点特征已经以独立和孤立的方式被抽象,忽略了相邻点的相对布局及其特征.在本文中,我们建议