简体   繁体   English

创建高斯窗的一维二阶导数

[英]Creating a 1D Second derivative of gaussian Window

In MATLAB I need to generate a second derivative of a gaussian window to apply to a vector representing the height of a curve. 在MATLAB中,我需要生成高斯窗口的二阶导数以应用于代表曲线高度的向量。 I need the second derivative in order to determine the locations of the inflection points and maxima along the curve. 我需要二阶导数以确定沿曲线的拐点和最大值的位置。 The vector representing the curve may be quite noise hence the use of the gaussian window. 代表曲线的向量可能是相当大的噪声,因此使用了高斯窗口。 What is the best way to generate this window? 生成此窗口的最佳方法是什么? Is it best to use the gausswin function to generate the gaussian window then take the second derivative of that? 最好使用gausswin函数生成高斯窗口,然后取其二阶导数吗? Or to generate the window manually using the equation for the second derivative of the gaussian? 还是使用高斯二阶导数的公式手动生成窗口? Or even is it best to apply the gaussian window to the data, then take the second derivative of it all? 甚至最好是将高斯窗口应用于数据,然后取所有数据的二阶导数? (I know these last two are mathematically the same, however with the discrete data points I do not know which will be more accurate) (我知道这最后两个在数学上是相同的,但是对于离散数据点,我不知道哪个会更准确)

The maximum length of the height vector is going to be around 100-200 elements. 高度向量的最大长度将约为100-200个元素。

Thanks Chris 谢谢克里斯

I would create a linear filter composed of the weights generated by the second derivative of a Gaussian function and convolve this with your vector. 我将创建一个由高斯函数的二阶导数生成的权重组成的线性滤波器,并将其与向量进行卷积。

The weights of a second derivative of a Gaussian are given by: 高斯二阶导数的权重由下式给出:

高斯的二阶导数

Where: 哪里:

  • Tau is the time shift for the filter. Tau是过滤器的时移。 If you are generating weights for a discrete filter of length T with an odd number of samples, set tau to zero and allow t to vary from [-T/2,T/2] 如果您要为具有奇数个样本的长度为T的离散滤波器生成权重,请将tau设置为零,并允许t从[-T / 2,T / 2]变化
  • sigma - varies the scale of your operator. sigma-改变您的运营商规模。 Set sigma to a value somewhere between T/6. 将sigma设置为T / 6之间的某个值。 If you are concerned about long filter length then this can be reduced to T/4 如果您担心滤波器的长度过长,则可以将其减小为T / 4
  • C is the normalising factor. C是归一化因子。 This can be derived algebraically but in practice I always do this numerically after calculating the filter weights. 这可以通过代数推导得出,但实际上,我总是在计算滤波器权重之后进行数字计算。 For unity gain when smoothing periodic signals, I will set C = 1 / sum(G''). 为了使周期信号平滑时的单位增益,我将设置C = 1 / sum(G'')。

In terms of your comment on the equivalence of smoothing first and taking a derivative later, I would say it is more involved than that. 关于您对先平滑然后再取导数的等效性的评论,我想说的要比这更复杂。 As which derivative operator would you use in the second step? 作为第二步中将使用哪个导数运算符? A simple central difference would not yield the same results. 一个简单的中心差异将不会产生相同的结果。

You can get an equivalent (but approximate) response to a second derivative of a Gaussian by filtering the data with two Gaussians of different scales and then taking the point-wise differences between the two resulting vectors. 通过使用两个不同比例的高斯滤波数据,然后取两个结果向量之间的逐点差异,您可以获得对高斯二阶导数的等效(但近似)响应。 See Difference of Gaussians for that approach. 有关该方法,请参见高斯差异

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM