小结:

1、卷积广泛存在与物理设备、计算机程序的smoothing平滑、sharpening锐化过程;

空间卷积可应用在图像处理中:函数f(原图像)经过滤器函数g形成新函数f-g(平滑化或锐利化的新图像)。

卷积可应用在物理设备、计算程序,对数据进行平滑化或锐利化。

空间卷积也应用于图像处理中的边缘检测、特征提取、动作提取、图形匹配等。

http://graphics.stanford.edu/courses/cs178/applets/convolution.html

Convolution of 1D functions

On the left side of the applet is a 1D function ("signal"). This is f. You can draw on the function to change it, but leave it alone for now. Beneath this is a menu of 1D filters. This is g. If you select "custom" you can also draw on the filter function, but leave that game for later. At the bottom is the result of convolving f by g. Click on a few of the filters. Notice that "big rect" blurs f more than "rect", but it leaves kinks here and there. Notice also that "gaussian" blurs less than "big rect" but doesn't leave kinks.

Both functions (f and g) are drawn as if they were functions of a continuous variable x, so it would appear that this visualization is showing convolution of continuous functions (first equation above). In practice the two functions are sampled finely and represented using 1D arrays. These numbers are connected using lines when they are drawn, giving the appearance of continuous functions. The convolution actually being performed in the applet's script is of two discrete functions (second equation above).

Whether we treat the convolution as continuous or discrete, its interpretation is the same: for each position x in the output function, we shift the filter function g left or right until it is centered at that position, we flip it left-to-right, we multiply every point on f by the corresponding point on our shifted g, and we add (or integrate) these products together. The left-to-right flipping is because, for obscure reasons, the equation for convolution is defined as g[x-k], not g[x+k] (using the 2nd equation as an example).

An alternative way to think about convolution

If this procedure is a bit hard to wrap your head around, here's an equivalent way to describe it that may be easier to visualize: at each position x in the output function, we place a copy of the filter g, centered left-to-right around that position, flipped left-to-right, and scaled up or down according to the value of the signal f at that position. After laying down these copies, if we add them all together at each x, we get the right answer!

To see this alternative way of understanding convolution in action, click on "animate", then "big rect". The animation starts with the original signal f, then places copies of the filter g at positions along f, stretching them vertically according to the height of f at that position, then adds these copies together to make the thick output curve. Although the animation only shows a couple dozen copies of the filter, in reality there would need to be one copy for every position x. In addition, for this procedure to work the sum of copies must be divided by the area under the filter function, a processing called normalization. Otherwise, the output would be higher or lower than the input, rather than simply being smoothed or sharpened. For all the filters except "custom", normalization is performed for you just before drawing the thick output curve. For the "custom" filter, see below.

Once you understand how this works, try the "sharpen" or "shift" filters. The sharpen filter replaces each value of f with a weighted sum of its immediate neighbors, but subtracting off the values of neighbors a bit further away. The effect of these subtractions is to exaggerate features in the original signal. The "Sharpen" filter in Photoshop does this; so do certain layers of neurons in your retina. The shift filter replaces each value of f with a value of f taken from a neighbor some distance to the right. (Yes, to the right, even though the spike in the filter is on the left side. Remember that convolution flips the filter function left-to-right before applying it.)

Finally, click on "custom" and try drawing your own filter. If the area under your filter is more or less than 1.0, the output function will jump up or down, respectively. To avoid this, click on "normalize". This will scale your filter up or down until its area is exactly 1.0. By the way, if you animate the application of your custom filter, the scaled copies will only touch the corresponding point on the original function if your custom filter reached y=1.0 at its x=0 position. Regardless, if your filter is normalized, the output function will be of the right height.

Convolution of 2D functions

On the right side of the applet we extend these ideas to two-dimensional discrete functions, in particular ordinary photographic images. The original 2D signal is at top, the 2D filter is in the middle, depicted as an array of numbers, and the output is at the bottom. Click on the different filter functions and observe the result. The only difference between "sharpen" and "edges" is a change of the middle filter value from 9.00 to 8.00. However, this change is crucial, as you can see. In particular, the sum of all non-zero filter values in "edges" is zero. Therefore, for positions in the original signal that are smooth (like the background), the output of the convolution is zero (i.e. black). The filter "hand shake" approximates what happens in a long-exposure photograph, in this case if the camera's aim wanders from upper-left to lower-right during the exposure.

Finally, click on "identity", which sets the middle filter tap (as positions in a filter are sometimes called) to 1.0 and the rest to 0.0. It should come as no surprise that this merely makes a copy of the original signal. Now click on "custom", then click on individual taps and enter new values for them. As you enter each value, the convolution is recomputed. Try creating a smoothing filter, or a sharpening filtering. Or starting with "identity", change the middle tap to 0.5, or 2.0. Does the image scale down or up in intensity? The applet is clipping outputs at 0.0 (black) and 255.0 (white), so if you try to scale intensites up, the image will simply saturate - like a camera if your exposure were too long. Try putting 1.0's in the upper-left corner and the lower right corner, setting everything else to 0.0. Do you get a double image? As with the custom 1D filter, if your filter values don't sum to 1.0, you might need to press "normalize". Unless you're doing edge finding, in which case they should sum to 0.0.


Questions or Comments? Please e-mail us.
© 2010;
Marc Levoy

Last update:

March 1, 2012 12:59:44 AM

Return to index of applets

Spatial convolution的更多相关文章

  1. SCNN车道线检测--(SCNN)Spatial As Deep: Spatial CNN for Traffic Scene Understanding(论文解读)

    Spatial As Deep: Spatial CNN for Traffic Scene Understanding 收录:AAAI2018 (AAAI Conference on Artific ...

  2. 论文笔记—Flattened convolution neural networks for feedforward acceleration

    1. 论文思想 一维滤过器.将三维卷积分解成三个一维卷积.convolution across channels(lateral), vertical and horizontal direction ...

  3. 从图(Graph)到图卷积(Graph Convolution):漫谈图神经网络模型 (二)

    本文属于图神经网络的系列文章,文章目录如下: 从图(Graph)到图卷积(Graph Convolution):漫谈图神经网络模型 (一) 从图(Graph)到图卷积(Graph Convolutio ...

  4. “卷积神经网络(Convolutional Neural Network,CNN)”之问

    目录 Q1:CNN 中的全连接层为什么可以看作是使用卷积核遍历整个输入区域的卷积操作? Q2:1×1 的卷积核(filter)怎么理解? Q3:什么是感受野(Receptive field)? Q4: ...

  5. 论文笔记——Factorized Convolutional Neural Networks

    1. 论文思想 将3D卷积分解为spatial convolution in each channel and linear projection across channels. (spatial ...

  6. [Network Architecture]Xception 论文笔记(转)

    文章来源 论文:Xception: Deep Learning with Depthwise Separable Convolutions 论文链接:https://arxiv.org/abs/161 ...

  7. 函数的光滑化或正则化 卷积 应用 两个统计独立变量X与Y的和的概率密度函数是X与Y的概率密度函数的卷积

    http://graphics.stanford.edu/courses/cs178/applets/convolution.html Convolution is an operation on t ...

  8. Graph Embedding Review:Graph Neural Network(GNN)综述

    作者简介: 吴天龙  香侬科技researcher 公众号(suanfarensheng) 导言 图(graph)是一个非常常用的数据结构,现实世界中很多很多任务可以描述为图问题,比如社交网络,蛋白体 ...

  9. 实战级Stand-Alone Self-Attention in CV,快加入到你的trick包吧 | NeurIPS 2019

    论文提出stand-alone self-attention layer,并且构建了full attention model,验证了content-based的相互关系能够作为视觉模型特征提取的主要基 ...

随机推荐

  1. poj 2524 Ubiquitous Religions 一简单并查集

    Ubiquitous Religions   Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 22389   Accepted ...

  2. C++static关键字用法

    一.static的作用有三种:限制变量或函数作用域.保持变量内容的持久.默认初始化为0 1.被static关键字修饰的全局函数或者变量具有文件作用域,即只在当前文件中可见. 2.被static修饰的变 ...

  3. python学习笔记(9)--Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法

    Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法 这篇文章主要介绍了Python UnicodeEncodeErro ...

  4. Linux网络编程wait()和waitpid()的讲解

    本文讲的是关于wait和waitpid两者的区别与联系.为避免僵尸进程的产生,无论我们什么时候创建子进程时,主进程都需要等待子进程返回,以便对子进程进行清理.为此,我们在服务器程序中添加SIGCHLD ...

  5. RP2837 OUT1-OUT2 对应关系 2路DO

    RP2837 OUT1-OUT2 对应关系: OUT1  AD2   PD22  继电器1 OUT2  AD4   PD24     继电器2 root@sama5d3-linux:~ echo 11 ...

  6. oracle查询数据库最大连接数等信息

    .当前的数据库连接数 select count(*) from v$process where program='ORACLE.EXE(SHAD)'; .数据库允许的最大连接数 select valu ...

  7. IE9 BUG overflow :auto 底部空白解决方案

    今天去升级了到IE9,运行项目的时候发现,我的div显示滚动条时候,用js动态加载进去的内容在光标移动的时候,底部自动被撑大留着空白, IE8 Chrome这些以前都试过 没发现这个问题 研究了好久 ...

  8. 采样方法(Sampling Methods)

    1.基本采样算法(Basic Sampling Algorithms) 1.1.标准概率分布(Standard distributions) 1.2.拒绝采样(Rejection sampling) ...

  9. noip2014滚粗记

    滚粗了..伤心. day0:和baba一起去,但是整天都是下雨啊好不爽,鞋子都湿了啊好不爽,注定是要滚粗?在火车站等了1h后上动车走人...在此期间我还天真的认为火车站的wifi可以被我给破解然后上网 ...

  10. 【BZOJ】1625: [Usaco2007 Dec]宝石手镯(01背包)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1625 太水了. #include <cstdio> #include <cstri ...