Test Gaussian filter.
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_SIMDLIB) && defined(VISP_HAVE_CATCH2) && (VISP_HAVE_DATASET_VERSION >= 0x030400)
#include <catch_amalgamated.hpp>
#include <visp3/core/vpGaussianFilter.h>
#include <visp3/core/vpImageTools.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Test vpGaussianFilter (unsigned char)")
{
std::vector<float> sigmas = { 0.5f, 2.0f, 5.0f, 7.0f };
for (auto sigma : sigmas) {
gaussianFilter.
apply(I, I_blurred);
char buffer[FILENAME_MAX];
snprintf(buffer, FILENAME_MAX, filepath_ref.c_str(), sigma);
const std::string filename = buffer;
std::cout <<
"sigma: " << sigma <<
" ; I_diff_dbl: " << I_diff_dbl.
getMeanValue() << std::endl;
const double threshold = 1.5;
}
}
TEST_CASE("Test vpGaussianFilter (vpRGBa)")
{
std::vector<float> sigmas = { 0.5f, 2.0f, 5.0f, 7.0f };
for (auto sigma : sigmas) {
gaussianFilter.apply(I, I_blurred);
char buffer[FILENAME_MAX];
snprintf(buffer, FILENAME_MAX, filepath_ref.c_str(), sigma);
const std::string filename = buffer;
std::cout <<
"sigma: " << sigma <<
" ; I_diff_R_dbl: " << I_diff_R_dbl.
getMeanValue()
<<
" ; I_diff_B_dbl: " << I_diff_B_dbl.
getMeanValue() << std::endl;
const double threshold = 1.5;
}
}
TEST_CASE("Test vpGaussianFilter (vpRGBa + deinterleave)")
{
std::vector<float> sigmas = { 0.5f, 2.0f, 5.0f, 7.0f };
for (auto sigma : sigmas) {
const bool deinterleave = true;
gaussianFilter.apply(I, I_blurred);
char buffer[FILENAME_MAX];
snprintf(buffer, FILENAME_MAX, filepath_ref.c_str(), sigma);
const std::string filename = buffer;
std::cout <<
"sigma: " << sigma <<
" ; I_diff_R_dbl: " << I_diff_R_dbl.
getMeanValue()
<<
" ; I_diff_B_dbl: " << I_diff_B_dbl.
getMeanValue() << std::endl;
const double threshold = 1.5;
}
}
int main(int argc, char *argv[])
{
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
return numFailed;
}
#else
int main() { return EXIT_SUCCESS; }
#endif
void apply(const vpImage< unsigned char > &I, vpImage< unsigned char > &I_blur)
static void split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=nullptr)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const
double getMeanValue(const vpImage< bool > *p_mask=nullptr, unsigned int *nbValidPoints=nullptr) const
Return the mean value of the bitmap.