34 #include <visp3/core/vpConfig.h>
36 #if defined(VISP_HAVE_SIMDLIB)
37 #include <Simd/SimdLib.h>
38 #include <visp3/core/vpGaussianFilter.h>
39 #include <visp3/core/vpImageConvert.h>
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
43 class vpGaussianFilter::Impl
46 Impl(
unsigned int width,
unsigned int height,
float sigma,
bool deinterleave)
47 : m_funcPtrGray(nullptr), m_funcPtrRGBa(nullptr), m_deinterleave(deinterleave)
49 const float epsilon = 0.001f;
51 const size_t channels_1 = 1;
52 m_funcPtrGray = SimdGaussianBlurInit(width, height, channels_1, &sigma, &epsilon);
54 const size_t channels_4 = 4;
55 m_funcPtrRGBa = SimdGaussianBlurInit(width, height, channels_4, &sigma, &epsilon);
58 m_red.resize(height, width);
59 m_green.resize(height, width);
60 m_blue.resize(height, width);
62 m_redBlurred.resize(height, width);
63 m_greenBlurred.resize(height, width);
64 m_blueBlurred.resize(height, width);
71 SimdRelease(m_funcPtrGray);
75 SimdRelease(m_funcPtrRGBa);
88 if (!m_deinterleave) {
89 const unsigned int rgba_size = 4;
90 SimdGaussianBlurRun(m_funcPtrRGBa,
reinterpret_cast<unsigned char *
>(I.
bitmap), I.
getWidth() * rgba_size,
91 reinterpret_cast<unsigned char *
>(I_blur.
bitmap), I_blur.
getWidth() * rgba_size);
95 SimdGaussianBlurRun(m_funcPtrGray, m_red.bitmap, m_red.getWidth(), m_redBlurred.bitmap, m_redBlurred.getWidth());
96 SimdGaussianBlurRun(m_funcPtrGray, m_green.bitmap, m_green.getWidth(), m_greenBlurred.bitmap,
97 m_greenBlurred.getWidth());
98 SimdGaussianBlurRun(m_funcPtrGray, m_blue.bitmap, m_blue.getWidth(), m_blueBlurred.bitmap,
99 m_blueBlurred.getWidth());
129 : m_impl(new Impl(width, height, sigma, deinterleave))
142 m_impl->apply(I, I_blur);
153 #elif !defined(VISP_BUILD_SHARED_LIBS)
155 void dummy_vpGaussianFilter() { };
vpGaussianFilter(unsigned int width, unsigned int height, float sigma, bool deinterleave=false)
virtual ~vpGaussianFilter()
void apply(const vpImage< unsigned char > &I, vpImage< unsigned char > &I_blur)
static void merge(const vpImage< unsigned char > *R, const vpImage< unsigned char > *G, const vpImage< unsigned char > *B, const vpImage< unsigned char > *a, vpImage< vpRGBa > &RGBa)
static void split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=nullptr)
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Type * bitmap
points toward the bitmap
unsigned int getHeight() const