38 #include <visp3/core/vpImageTools.h>
40 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
41 # include <emmintrin.h>
42 # define VISP_HAVE_SSE2 1
104 unsigned char A_star,
106 unsigned char B_star)
116 double factor = (double)(B_star - A_star)/(double)(B - A);
118 for (
unsigned int i=0 ; i < I.
getHeight(); i++)
119 for (
unsigned int j=0 ; j < I.
getWidth(); j++) {
127 I[i][j] = (
unsigned char)(A_star + factor*(v-A));
156 for (
unsigned int b = 0; b < n ; b++)
190 for (
unsigned int b = 0; b < n ; b++)
227 for (
unsigned int b = 0; b < n ; b++)
261 for (
unsigned int b = 0; b < n ; b++)
297 unsigned char *ptr_I1 = I1.
bitmap;
298 unsigned char *ptr_I2 = I2.
bitmap;
299 unsigned char *ptr_Ires = Ires.
bitmap;
300 unsigned int cpt = 0;
304 for (; cpt <= Ires.
getSize() - 16 ; cpt += 16, ptr_I1 += 16, ptr_I2 += 16, ptr_Ires += 16) {
305 const __m128i v1 = _mm_loadu_si128( (
const __m128i*) ptr_I1);
306 const __m128i v2 = _mm_loadu_si128( (
const __m128i*) ptr_I2);
307 const __m128i vres = saturate ? _mm_adds_epu8(v1, v2) : _mm_add_epi8(v1, v2);
309 _mm_storeu_si128( (__m128i*) ptr_Ires, vres );
314 for (; cpt < Ires.
getSize(); cpt++, ++ptr_I1, ++ptr_I2, ++ptr_Ires) {
315 *ptr_Ires = saturate ? vpMath::saturate<unsigned char>( (
short int) *ptr_I1 + (
short int) *ptr_I2 ) : *ptr_I1 + *ptr_I2;
341 unsigned char *ptr_I1 = I1.
bitmap;
342 unsigned char *ptr_I2 = I2.
bitmap;
343 unsigned char *ptr_Ires = Ires.
bitmap;
344 unsigned int cpt = 0;
348 for (; cpt <= Ires.
getSize() - 16 ; cpt += 16, ptr_I1 += 16, ptr_I2 += 16, ptr_Ires += 16) {
349 const __m128i v1 = _mm_loadu_si128( (
const __m128i*) ptr_I1);
350 const __m128i v2 = _mm_loadu_si128( (
const __m128i*) ptr_I2);
351 const __m128i vres = saturate ? _mm_subs_epu8(v1, v2) : _mm_sub_epi8(v1, v2);
353 _mm_storeu_si128( (__m128i*) ptr_Ires, vres );
358 for (; cpt < Ires.
getSize(); cpt++, ++ptr_I1, ++ptr_I2, ++ptr_Ires) {
359 *ptr_Ires = saturate ? vpMath::saturate<unsigned char>( (
short int) *ptr_I1 - (
short int) *ptr_I2 ) : *ptr_I1 - *ptr_I2;
367 float vpImageTools::cubicHermite (
const float A,
const float B,
const float C,
const float D,
const float t) {
368 float a = (-A + 3.0f*B - 3.0f*C + D) / 2.0f;
369 float b = A + 2.0f*C - (5.0f*B + D) / 2.0f;
370 float c = (-A + C) / 2.0f;
373 return a*t*t*t + b*t*t + c*t + d;
376 float vpImageTools::lerp(
const float A,
const float B,
const float t) {
377 return A * (1.0f - t) + B * t;
unsigned int getWidth() const
unsigned char B
Blue component.
Type * bitmap
points toward the bitmap
error that can be emited by ViSP classes.
Error that can be emited by the vpImage class and its derivates.
unsigned char G
Green component.
static Type maximum(const Type &a, const Type &b)
unsigned int getSize() const
unsigned char A
Additionnal component.
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
static Type minimum(const Type &a, const Type &b)
unsigned char R
Red component.
unsigned int getHeight() const