/*! \brief Helper function to write out a collection of pixels as a bmp file. */ inline void writeBMPFile(const std::string& filename, const std::vector<uint8_t>& image, size_t width, size_t height, size_t components = 4) { std::ofstream bmpFile(filename.c_str(), std::fstream::binary); bmpFile << detail::bitmap_information_header(width, height); if (components < 3) M_throw() << "Cannot write out bitmaps with less than three components"; size_t rowpadding = ((width * 3 + 3) & 0xFFFC) - width * 3; for (size_t y(0); y < height; ++y) { for (size_t x(0); x < width; ++x) { detail::write(bmpFile, image[components * (y * width + x) + 0]); detail::write(bmpFile, image[components * (y * width + x) + 1]); detail::write(bmpFile, image[components * (y * width + x) + 2]); } for (size_t xpad(0); xpad < rowpadding; ++xpad) detail::write(bmpFile, int8_t(0)); } }
inline void rfft(const DEVector<float>::Type &x, CDEVector<float>::Type &X, int fftsize) { // zero pad to fftsize DEVector<float>::Type xpad(fftsize); std::fill_n(xpad.data(), fftsize, 0); xpad(_(1,x.length())) = x; // calc FFTs fftwf_plan p1; X.resize(fftsize/2+1); p1 = fftwf_plan_dft_r2c_1d(fftsize, &xpad(1), reinterpret_cast<fftwf_complex*>( &X(1) ), FFTW_ESTIMATE); fftwf_execute(p1); fftwf_destroy_plan(p1); }