1 Star 0 Fork 16

jjzhang166/NumCpp

forked from Gitee 极速下载/NumCpp 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example03.cpp 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
Tobias Knopp 提交于 2013-08-04 01:18 +08:00 . rewrite of numcpp
#include <numcpp.h>
using namespace numcpp;
int main()
{
// create Shepp Logan phantom (type Array<double>)
auto x = phantom(256);
// calculate the absolute value of the FFT of x
// the eval call is necessary as abs is an expression template
auto y = eval(log(abs(fftshift(fft(x)))));
// export x and y to image files (pdf/png) using different colormaps
export_image( x, "shepp_logan_phantom.pdf", colormaps::winter);
export_image( y, "shepp_logan_phantom_fft.png");
// export x and y into the same hdf5 file
auto file = h5create("shepp_logan_phantom.h5");
h5write( x, file, "/shepp_logan" );
h5write( y, file, "/shepp_logan_fft" );
h5close(file);
// export x into a simple binary file
tofile( x, "shepp_logan_phantom.dat");
}
/*!
@page example03 Data and Image Export Example
Example showing the data and image export capabilities of NumCpp.
NumCpp uses the Cairo graphics library for exporting arrays as images.
@code
#include <numcpp.h>
using namespace numcpp;
int main()
{
// create Shepp Logan phantom (type Array<double>)
auto x = phantom(256);
// calculate the absolute value of the FFT of x
// the eval call is necessary as abs is an expression template
auto y = eval(log(abs(fftshift(fft(x)))));
// export x and y to image files (pdf/png) using different colormaps
export_image( x, "shepp_logan_phantom.pdf", colormaps::winter);
export_image( y, "shepp_logan_phantom_fft.png");
// export x and y into the same hdf5 file
auto file = h5create("shepp_logan_phantom.h5");
h5write( x, file, "/shepp_logan" );
h5write( y, file, "/shepp_logan_fft" );
h5close(file);
// export x into a simple binary file
tofile( x, "shepp_logan_phantom.dat");
}
@endcode
The generate PDF file contain the following images:
@image html exampleExport.png
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/jjzhang166/numcpp.git
git@gitee.com:jjzhang166/numcpp.git
jjzhang166
numcpp
NumCpp
master

搜索帮助