Matlab - 信号噪声消除

发布于 2024-11-27 00:06:37 字数 401 浏览 3 评论 0原文

我有一个数据向量,其中包含 -20 20 范围内的整数。

下面是一个包含值的图:

输入图像描述这里

这是矢量数据中 96 个元素的示例。从上图可以看出,大多数元素位于 -2, 2 区间内。

我想消除数据中的噪音。我想消除低振幅峰值,并保留高振幅峰值,即像索引 74 处的峰值。

基本上,我只是想增加高振幅峰值和低振幅峰值之间的对比度,如果它是可以消除低振幅峰值。

你能建议我一种方法吗?

我尝试过mapstd函数,但问题是它也标准化了高振幅峰值。

我正在考虑使用小波变换工具箱,但我不知道如何从小波分解系数重建数据。

你能给我推荐一种方法吗?

I have a vector of data, which contains integers in the range -20 20.

Bellow is a plot with the values:

enter image description here

This is a sample of 96 elements from the vector data. The majority of the elements are situated in the interval -2, 2, as can be seen from the above plot.

I want to eliminate the noise from the data. I want to eliminate the low amplitude peaks, and keep the high amplitude peak, namely, peaks like the one at index 74.

Basically, I just want to increase the contrast between the high amplitude peaks and low amplitude peaks, and if it would be possible to eliminate the low amplitude peaks.

Could you please suggest me a way of doing this?

I have tried mapstd function, but the problem is that it also normalizes that high amplitude peak.

I was thinking at using the wavelet transform toolbox, but I don't know exact how to reconstruct the data from the wavelet decomposition coefficients.

Can you recommend me a way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

攒眉千度 2024-12-04 00:06:37

检测异常值的一种方法是使用三标准差规则。一个例子:

%# some random data resembling yours
x = randn(100,1);
x(75) = -14;
subplot(211), plot(x)

%# tone down the noisy points
mu = mean(x); sd = std(x); Z = 3;
idx = ( abs(x-mu) > Z*sd );         %# outliers
x(idx) = Z*sd .* sign(x(idx));      %# cap values at 3*STD(X)
subplot(212), plot(x)

在此处输入图像描述


编辑:

看来我误解了这里的目标。如果你想做相反的事情,也许是这样的:

%# some random data resembling yours
x = randn(100,1);
x(75) = -14; x(25) = 20;
subplot(211), plot(x)

%# zero out everything but the high peaks
mu = mean(x); sd = std(x); Z = 3;
x( abs(x-mu) < Z*sd ) = 0;
subplot(212), plot(x)

在此处输入图像描述

One approach to detect outliers is to use the three standard deviation rule. An example:

%# some random data resembling yours
x = randn(100,1);
x(75) = -14;
subplot(211), plot(x)

%# tone down the noisy points
mu = mean(x); sd = std(x); Z = 3;
idx = ( abs(x-mu) > Z*sd );         %# outliers
x(idx) = Z*sd .* sign(x(idx));      %# cap values at 3*STD(X)
subplot(212), plot(x)

enter image description here


EDIT:

It seems I misunderstood the goal here. If you want to do the opposite, maybe something like this instead:

%# some random data resembling yours
x = randn(100,1);
x(75) = -14; x(25) = 20;
subplot(211), plot(x)

%# zero out everything but the high peaks
mu = mean(x); sd = std(x); Z = 3;
x( abs(x-mu) < Z*sd ) = 0;
subplot(212), plot(x)

enter image description here

几度春秋 2024-12-04 00:06:37

如果它仅用于演示目的,并且您实际上不会将这些缩放值用于任何用途,我有时喜欢通过以下方式增加对比度:

% your data is in variable 'a'
plot(a.*abs(a)/max(abs(a)))

编辑:因为我们要发布图像,所以这是我的(之前/之后) :
在此处输入图像描述

If it's for demonstrative purposes only, and you're not actually going to be using these scaled values for anything, I sometimes like to increase contrast in the following way:

% your data is in variable 'a'
plot(a.*abs(a)/max(abs(a)))

edit: since we're posting images, here's mine (before/after):
enter image description here

伪心 2024-12-04 00:06:37

您可以尝试分割窗口过滤器。如果 x 是您当前的样本,则过滤器将类似于:

k = [L L L L L L 0 0 0 x 0 0 0 R R R R R R]

对于每个样本 x,您对左侧 (L) 的周围样本带和右侧的周围样本带进行平均。如果您的样本呈阳性和阴性(就像您的一样),您应该获取腹肌。价值第一。然后将样本 x 除以这些周围样本的平均值。

y[n] = x[n] / mean(abs(x([L R])))

每次执行此操作时,峰值都会增强,噪声会变平。您可以执行多次以增加效果。它对这些带宽度的选择有些敏感,但可以工作。例如:

before

两遍:

“之后”

You might try a split window filter. If x is your current sample, the filter would look something like:

k = [L L L L L L 0 0 0 x 0 0 0 R R R R R R]

For each sample x, you average a band of surrounding samples on the left (L) and a band of surrounding samples on the right. If your samples are positive and negative (as yours are) you should take the abs. value first. You then divide the sample x by the average value of these surrounding samples.

y[n] = x[n] / mean(abs(x([L R])))

Each time you do this the peaks are accentuated and the noise is flattened. You can do more than one pass to increase the effect. It is somewhat sensitive to the selection of the widths of these bands, but can work. For example:

before

Two passes:

after

ゃ人海孤独症 2024-12-04 00:06:37

您实际需要的是某种压缩来缩放数据,即:-2 到 2 之间的值按某个因子缩放,其他所有值按另一个因子缩放。完成这样的事情的一种粗略方法是将所有小值设置为零,即

x = randn(1,100)/2; x(50) = 20; x(25) = -15; % just generating some data
threshold = 2;
smallValues = (abs(x) <= threshold);
y = x;
y(smallValues) = 0;
figure; 
plot(x,'DisplayName','x'); hold on; 
plot(y,'r','DisplayName','y'); 
legend show;

请不要认为这是一个非常非线性的操作(例如,当您想要值为 2.1 和 1.9 的峰值时,它们将产生非常不同的行为:将被删除,另一个将被保留)。因此,对于显示,这可能就是您所需要的,对于进一步处理,它可能取决于您想要做什么。

在此处输入图像描述

What you actually need is some kind of compression to scale your data, that is: values between -2 and 2 are scale by a certain factor and everything else is scaled by another factor. A crude way to accomplish such a thing, is by putting all small values to zero, i.e.

x = randn(1,100)/2; x(50) = 20; x(25) = -15; % just generating some data
threshold = 2;
smallValues = (abs(x) <= threshold);
y = x;
y(smallValues) = 0;
figure; 
plot(x,'DisplayName','x'); hold on; 
plot(y,'r','DisplayName','y'); 
legend show;

Please do not that this is a very nonlinear operation (e.g. when you have wanted peaks valued at 2.1 and 1.9, they will produce very different behavior: one will be removed, the other will be kept). So for displaying, this might be all you need, for further processing it might depend on what you are trying to do.

enter image description here

太阳哥哥 2024-12-04 00:06:37

为了消除低幅度峰值,您将把所有低幅度信号等同于噪声并忽略。

如果你有任何先验知识,就使用它。

如果您的信号是 a,则

a(abs(a)<X) = 0

其中 X 是噪声的最大预期大小。

如果您想变得更奇特,并“即时”找到这个,请使用 3 的 kmeans。它位于统计工具箱中,此处:

http://www.mathworks.com/help/toolbox/stats/kmeans.html

或者,您可以对绝对值使用 Otsu 方法数据,并使用符号返回。

请注意,这些以及我在该线程上看到的所有其他技术都假设您正在进行后期处理。如果您实时进行此处理,事情就必须改变。

To eliminate the low amplitude peaks, you're going to equate all the low amplitude signal to noise and ignore.

If you have any apriori knowledge, just use it.

if your signal is a, then

a(abs(a)<X) = 0

where X is the max expected size of your noise.

If you want to get fancy, and find this "on the fly" then, use kmeans of 3. It's in the statistics toolbox, here:

http://www.mathworks.com/help/toolbox/stats/kmeans.html

Alternatively, you can use Otsu's method on the absolute values of the data, and use the sign back.

Note, these and every other technique I've seen on this thread is assuming you are doing post processing. If you are doing this processing in real time, things will have to change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文