0

我需要找到一些通用 C++ 库,它采用反向 fft 输出(fftw_complex 格式,即两个双精度)并将这些数据转换为图像文件,例如 png。我可以瀑布 dffts 来获取 2d 数据(并使用 10log10(re re+im im) 来获取每个频率分量的幅度),但我不知道哪个图像库可以工作。

我确实曾经使用过一个名为 zimage 的旧程序,但它似乎不再可用。我的 Ubuntu 9.10 系统上没有 MATLAB(但我有 Octave)

Octave 可以生成瀑布图像吗?我还需要将频谱图转换为 wav 声音文件。

有任何想法吗??

4

2 回答 2

2

最容易创建的图像格式是 PNM。您可以将其打印为文本文件,然后使用大多数图形程序进行转换。以下是来自维基百科页面的示例:

P2 24 7 15
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

将该文本保存在名为“feep.pgm”的文件中,您就会明白我的意思。

http://en.wikipedia.org/wiki/Netpbm_format

您必须将 10log10 信息缩放为像素值。

于 2010-09-16T07:15:27.800 回答
0

OpenCV是一个可以处理 PNG 文件以及多种其他格式的库。它应该可以在您的 Ubuntu 9.10 系统上使用apt get libcv-dev(根据记忆,您可能需要仔细检查包名称)。

/*
 * compile with:
 *
 * g++ -Wall -ggdb -I. -I/usr/include/opencv -L /usr/lib -lm -lcv -lhighgui -lcvaux filename.cpp -o filename.out
 */

#include <cv.h>    
#include <highgui.h>

/*
 * Your image dimensions.
 */
int width;
int height;

CvSize size = cvSize(width, height);

/*
 * Create 3-channel image, unsigned 8-bit per channel.
 */
IplImage *image = cvCreateImage(size, IPL_DEPTH_8U, 3);

for (int i = 0; i < width; ++i)
for (int j = 0; j < height; ++j)
{
    unsigned int r;
    unsigned int g;
    unsigned int b;

    /*
     * Keep in mind that OpenCV stores things in BGR order.
     */
    CvScalar bgr = cvScalar(b, g, r);
    cvSet2D(image, i, j, bgr);
}

cvSaveImage("filename.png", image);
cvReleaseImage(&image);
于 2010-11-24T02:52:23.260 回答