Java中的信号处理库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/636686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 17:15:47  来源:igfitidea点击:

Signal processing library in Java?

javasignal-processingnumerical-analysis

提问by dfrankow

I'd like to compute power spectral density of time series; do some bandpass, lowpass, and highpass filtering; maybe some other basic stuff.

我想计算时间序列的功率谱密度;做一些带通、低通和高通滤波;也许其他一些基本的东西。

Is there a nice open-source Java library to do this?

有没有一个很好的开源 Java 库来做到这一点?

I've hunted a bit without success (e.g., Googling "power spectral density java" or "signal processing java" and clicking through links, looking in Apache Commons, Sourceforge, java.net, etc.).

我搜索了一些但没有成功(例如,谷歌搜索“功率谱密度 java”或“信号处理 java”并点击链接,查看 Apache Commons、Sourceforge、java.net 等)。

There are lots of applets, books, tutorials, commercial products, etc., that don't meet my needs.

有很多小程序、书籍、教程、商业产品等,不能满足我的需求。

Update: I found org.apache.commons.math.transformfor Fourier transforms. This doesn't implement power spectral density, bandpass, etc., but it is something.

更新:我找到了org.apache.commons.math.transform进行傅立叶变换。这并没有实现功率谱密度、带通等,但它是一些东西。

回答by John Ellinwood

It looks pretty sparse. Try Signalgoor jeinor the Intel Signal Processing Library, although I think the last one is just a JNI wrapper.

它看起来很稀疏。尝试SignalgojeinIntel Signal Processing Library,尽管我认为最后一个只是 JNI 包装器。

I saw a lot of those applets you were talking about. I think you may be able to get the JARs for them and use the class APIs inside. May have to use eclipse and jad to decompile and figure out what they do, though, due to lack of documentation. Try the source on this pagefor example.

我看到了很多你说的那些小程序。我认为您可以为它们获取 JAR 并在其中使用类 API。但是,由于缺乏文档,可能必须使用 eclipse 和 jad 来反编译并弄清楚它们的作用。例如,尝试此页面上的源代码。

回答by Bill the Lizard

I found the book Java Digital Signal Processingand its example source code. You might look through the code to see if it fits your needs.

我找到了Java Digital Signal Processing及其示例源代码这本书。您可以查看代码以查看它是否符合您的需求。

You can also check out DSP Laboratory.

您还可以查看DSP 实验室

As duffymo and basszero mentioned in the comments, there have been changes to Java since the publication of Java DSP that may impact some of the code examples. In particular, the (relatively) new Concurrency Utilties packagemight prove useful.

正如 duffymo 和 basszero 在评论中提到的,自 Java DSP 发布以来,Java 发生了一些变化,可能会影响一些代码示例。特别是,(相对)新的Concurrency Utilties 包可能会很有用。

回答by dfrankow

I found another resource, although it's not a library: http://www.dickbaldwin.com/tocdsp.htm. It's just a basic discussion of signal processing and Fourier transform, with some Java examples. See for example tutorials 1478, 1482, 1486. Not sure what the license on the code is.

我找到了另一个资源,虽然它不是图书馆:http: //www.dickbaldwin.com/tocdsp.htm。这只是对信号处理和傅立叶变换的基本讨论,并附有一些 Java 示例。参见示例教程 1478、1482、1486。不确定代码上的许可证是什么。

回答by Trevor Boyd Smith

My first suggestion is to not do your DSP implementation in Java. My second suggestion would be to roll your own simple DSP implementations yourself in Java.

我的第一个建议是不要用 Java 实现 DSP。我的第二个建议是自己在 Java 中推出自己的简单 DSP 实现。



Why not to use Java:

为什么不使用Java:

I have lots of experience writing DSP code over the last 10+ years... and almost none of the DSP code is in Java... so forgive me when I am hesitant to read about someone who wants to implement DSP in Java.

在过去的 10 多年里,我有很多编写 DSP 代码的经验……而且几乎没有一个 DSP 代码是用 Java 编写的……所以当我犹豫读到想用 Java 实现 DSP 的人时,请原谅我。

If you are going to be doing non-trivial DSPthen you shouldn't be using Java. The reason that DSP is so painful to implement in Java is because all the good DSP implementations use low level memory management tricks, pointers (crazy amounts of pointers), large raw data arrays, etc.

如果您打算进行非平凡的 DSP,那么您不应该使用 Java。用 Java 实现 DSP 如此痛苦的原因是,所有好的 DSP 实现都使用低级内存管理技巧、指针(疯狂数量的指针)、大型原始数据数组等。

Why to use Java:

为什么要使用Java:

If you are doing simple DSPstuff roll your own Java implementation. Simple DSP things like PSD and filtering are both relatively easy to implement (easy implementation but they won't be fast) because there is soo many implementation examples and well documented theory online.

如果您正在做简单的 DSP 工作,请滚动您自己的 Java 实现。PSD 和滤波等简单的 DSP 东西都相对容易实现(容易实现但不会很快),因为网上有太多的实现示例和详细记录的理论。

In my case I implemented a PSD function in Java once because I was graphing the PSD in a Java GUI so it was easiest to just take the performance hit in Java and have the PSD computed in the java GUI and then plot it.

就我而言,我曾经在 Java 中实现了一个 PSD 函数,因为我是在 Java GUI 中绘制 PSD 的图形,因此最简单的方法是在 Java 中获取性能影响并在 Java GUI 中计算 PSD,然后将其绘制出来。



How to implement a PSD:

如何实现PSD:

The PSD is usually just the magnitude of the FFT displayed in dB. There are many examples from academic, commercial and open-source showing how to compute the magnitude of the FFT in dB. For example Apache has a Java implementation that gives you the FFToutput and then you just need to convert to magnitude and dB. Anything after the FFT should be tailored to what you need/want.

PSD 通常只是以 dB 为单位显示的 FFT 幅度。有许多来自学术、商业和开源的示例展示了如何以 dB 为单位计算 FFT 的幅度。例如,Apache 有一个 Java 实现,可以为您提供 FFT输出,然后您只需要转换为幅度和 dB。FFT 之后的任何内容都应根据您的需要/想要的内容量身定制。



How to implement lowpass, bandpass filtering:

如何实现低通、带通滤波:

The easiest implementation (not the most computationally efficient) would in my opinion be using an FIR filter and doing time domain convolution.

在我看来,最简单的实现(不是计算效率最高的)是使用 FIR 滤波器并进行时域卷积。

Convolution is very easy to implement it is two nested for loops and there are literally millions of example code on the net.

卷积很容易实现,它是两个嵌套的 for 循环,网上有数百万个示例代码。

The FIR filter will be the tricky part if you don't know anything about filter design. The easiest method would be to use Matlab to generate your FIR filter and then copy the coefficents into java. I suggest using firpmord() and firpm() from Matlab. Shoot for -30 to -50 dB attenuation in the stopband and 3 dB ripple in the passband.

如果您对滤波器设计一无所知,FIR 滤波器将是棘手的部分。最简单的方法是使用 Matlab 生成 FIR 滤波器,然后将系数复制到 java 中。我建议使用来自 Matlab 的 firpmord() 和 firpm()。争取阻带中的 -30 至 -50 dB 衰减和通带中的 3 dB 纹波。

回答by Christian d'Heureuse

I have written a collection of some Java DSP classes, e.g. IIR filters:

我编写了一些 Java DSP 类的集合,例如 IIR 过滤器:

Java DSP collection

Java DSP 合集