Go to the documentation of this file.
24 #include <mrpt/examples_config.h>
25 string myDataDir(MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"img_convolution_fft/"));
38 throw std::runtime_error(
"Cannot load test image!");
41 "Computing %ux%u image convolution ...", (
unsigned)img.
getWidth(),
51 for (
int nTimes = 0; nTimes < N; nTimes++)
70 printf(
"\nMax real:%f Min real:%f\n", i1.maxCoeff(), i1.minCoeff());
79 for (y = 0; y < ly; y++)
80 for (x = 0; x < lx; x++)
82 float r1 = I1_R(y, x);
83 float r2 = I2_R(y, x);
84 float i1 = I1_I(y, x);
85 float i2 = I2_I(y, x);
87 I2_R(y, x) = r1 * r2 - i1 * i2;
88 I2_I(y, x) = r2 * i1 + r1 * i2;
95 meanTime += tictac.
Tac();
96 printf(
" Done,%.06fms\n", tictac.
Tac() * 1000.0f);
100 printf(
"Mean time: %.06fms\n", 1000.0f * meanTime / N);
106 winR.showImage(imgR);
124 catch (
const std::exception& e)
131 printf(
"Untyped exception!!");
size_t getWidth() const override
Returns the width of the image in pixels.
void idft2_complex(const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_real, CMatrixFloat &out_imag)
Compute the 2D inverse Discrete Fourier Transform (DFT).
A high-performance stopwatch, with typical resolution of nanoseconds.
void loadFromTextFile(std::istream &f)
Loads a vector/matrix from a text file, compatible with MATLAB text format.
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
void TestImageConvolutionFFT()
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Scalar maxCoeff() const
Maximum value in the matrix/vector.
double Tac() noexcept
Stops the stopwatch.
This class is a "CSerializable" wrapper for "CMatrixFloat".
void setFromMatrix(const MAT &m, bool matrix_is_normalized=true)
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,...
void getAsMatrix(mrpt::math::CMatrixFloat &outMatrix, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1, bool normalize_01=true) const
Returns the image as a matrix with pixel grayscale values in the range [0,1].
T round2up(T val)
Round up to the nearest power of two of a given number.
void Tic() noexcept
Starts the stopwatch.
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
Classes for creating GUI windows for 2D and 3D visualization.
A class for storing images as grayscale or RGB bitmaps.
Scalar minCoeff() const
Minimum value in the matrix/vector.
size_t getHeight() const override
Returns the height of the image in pixels.
void dft2_complex(const CMatrixFloat &in_real, const CMatrixFloat &in_imag, CMatrixFloat &out_real, CMatrixFloat &out_imag)
Compute the 2D Discrete Fourier Transform (DFT) of a complex matrix, returning the real and imaginary...
This base provides a set of functions for maths stuff.
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
bool loadFromFile(const std::string &fileName, int isColor=-1)
Load image from a file, whose format is determined from the extension (internally uses OpenCV).
Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020 | |