图像处理中的平均掩模和拉普拉斯掩模
在给定的应用程序中,我对输入图像应用平均掩模以减少噪声,然后应用拉普拉斯掩模来增强小细节。有人知道如果我在Matlab中颠倒这些操作的顺序是否会得到相同的结果?
in a given application I apply an averaging mask to input images to reduce noise, and then a Laplacian mask to enhance small details. Anyone knows if I Would get the same results if I reverse the order of these operations in Matlab?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
与拉普拉斯核进行卷积类似于使用有关强度变化的二阶导数信息。由于该导数对噪声敏感,因此我们通常在应用拉普拉斯滤波器之前使用高斯平滑图像。
这是一个 MATLAB 示例,类似于 @belisarius 发布:
Convolving with a Laplacian kernel is similar to using second derivative information about the intensity changes. Since this derivative is sensitive to noise, we often smooth the image with a Gaussian before applying the Laplacian filter.
Here's a MATLAB example similar to what @belisarius posted:
假设您有两个滤镜
F1
和F2
,以及一个图像I
。如果您将图像通过两个过滤器,您将得到一个定义为“此处我使用
*
来表示 卷积。根据卷积的关联规则,这是相同的。
使用交换性,我们可以说,
当然,这是在数学的连续域中,在机器上执行这些操作意味着会出现舍入错误,并且可能会丢失一些数据。您还应该考虑您的过滤器是否是 FIR,否则考虑数字过滤的整个概念当卷积开始崩溃时,你的过滤器不能真正按照你想要的方式运行。
编辑
离散卷积定义为
因此在数据边缘添加零不会改变数学意义上的任何内容。
正如一些人指出的那样,您会在数字上得到不同的答案,但每当我们处理计算实际数据时,这是预期的。这些变化应该很小,并且仅限于卷积输出的低能量分量(即:边缘)。
考虑卷积运算的工作原理也很重要。对长度为
X
和长度Y
的两组数据进行卷积将得到长度为X+Y-1
的答案。 MATLAB 和 Mathematica 等程序在幕后发生了一些神奇的事情,可以为您提供长度为X
或Y
的答案。因此,对于@belisarius 的帖子,我们似乎确实在说同样的事情。
Lets say you have two filters
F1
andF2
, and an imageI
. If you pass your image through the two filters, you would get a response that was defined asWhere here I am using
*
to represent convolution.By the associative rule of convolution, this is the same as.
using commutativity, we can say that
Of course, this is in the nice continuous domain of math, doing these things on a machine means there will be rounding errors and some data may be lost. You also should think about if your filters are FIR, otherwise the whole concept of thinking about digital filtering as convolution sorta starts to break down as your filter can't really behave the way you wanted it to.
EDIT
The discrete convolution is defined as
so adding zeros at the edges of you data doesn't change anything in a mathematical sense.
As some people have pointed out, you will get different answers numerically, but this is expected whenever we deal with computing actual data. These variations should be small and limited to the low energy components of the output of the convolution (i.e: the edges).
It is also important to consider how the convolution operation is working. Convolving two sets of data of length
X
and lengthY
will result in an answer that isX+Y-1
in length. There is some behind the scenes magic going on for programs like MATLAB and Mathematica to give you an answer that is of lengthX
orY
.So in regards to @belisarius' post, it would seem we are really saying the same thing.
从数字上看,结果并不相同,但图像看起来非常相似。
Mathematica 中的示例:
编辑
作为对 @thron 在其关于线性滤波器和填充的换向的回答中评论的回答,只需考虑以下操作。
虽然没有填充的高斯和拉普拉斯滤波器的换向是正确的:
使用填充做同样的事情,会导致边缘处的差异:
Numerically the results are not the same, but the images look pretty similar.
Example in Mathematica:
Edit
As an answer to @thron comment in his answer about commutation of linear filters and padding, just consider the following operations.
While commutation of a Gaussian and Laplacian filter without padding is true:
Doing the same with padding, result in a difference at the edges: