28 if (size.x == -1 && size.y == -1)
33 std::cerr <<
"bad copy: " << in.
size() <<
" " << out.
size() <<
" " << size <<
" " << begin <<
" " << dst << std::endl;
42 const S* from = &in[begin];
52 template <class T, bool pod = Internal::is_POD<T>::is_pod>
struct ZeroPixel {
54 for (
unsigned int c=0; c<Pixel::Component<T>::count; c++)
60 static void zero(T& t) { memset(&t,0,
sizeof(T)); }
63 template <class T, bool pod = Internal::is_POD<T>::is_pod>
struct ZeroPixels {
64 static void zero(T* pixels,
int count) {
67 std::fill(pixels+1, pixels+count, *pixels);
73 static void zero(T* pixels,
int count) {
74 memset(pixels, 0,
sizeof(T)*count);
93 for (
int r=0;r<I.
size().
y-1; r++)
106 for(
int n=0; n < w; n++)
107 for(
int x=0; x < im.
size().
x; x++)
110 im[im.
size().
y-1-n][x] = pix;
113 for(
int y=w; y < im.
size().
y - w; y++)
114 for(
int n=0; n < w; n++)
117 im[y][im.
size().
x - 1 - n] = pix;
128 template <
class A,
class B>
inline void differences(
const A* a,
const A* b, B* diff,
size_t count)
131 *(diff++) = (B)*(a++) - (B)*(b++);
137 template <
class A,
class B,
class C>
inline void add_multiple_of_sum(
const A* a,
const A* b,
const C& c, B* out,
size_t count)
140 *(out++) += (*(a++) + *(b++)) * c;
146 template <
class A,
class B,
class C>
inline void assign_multiple(
const A* a,
const B& c, C* out,
size_t count)
149 *(out++) = static_cast<C>(*(a++) * c);
155 template <
class T>
double inner_product(
const T* a,
const T* b,
size_t count) {
158 dot += *(a++) * *(b++);
173 template <
class T1,
class T2>
inline void square(
const T1* in, T2* out,
size_t count)
176 *(out++) = static_cast<T2>(*in * *in);
181 template <
class T1,
class T2>
inline void subtract_square(
const T1* in, T2* out,
size_t count)
184 *(out++) -= static_cast<T2>(*in * *in);
197 template<
int bytes>
bool is_aligned(
const void* ptr);
198 template<>
inline bool is_aligned<8>(
const void* ptr) {
return ((reinterpret_cast<size_t>(ptr)) & 0x7) == 0; }
199 template<>
inline bool is_aligned<16>(
const void* ptr) {
return ((reinterpret_cast<size_t>(ptr)) & 0xF) == 0; }
204 return is_aligned<A>(ptr) ? 0 : (A-((reinterpret_cast<size_t>(ptr)) & (A-1)))/
sizeof(T);
208 void differences(
const short* a,
const short* b,
short* diff,
unsigned int size);
211 void differences(
const float* a,
const float* b,
float* diff,
size_t size);
212 void add_multiple_of_sum(
const float* a,
const float* b,
const float& c,
float* out,
size_t count);
213 void assign_multiple(
const float* a,
const float& c,
float* out,
size_t count);
214 double inner_product(
const float* a,
const float* b,
size_t count);
216 void square(
const float* in,
float* out,
size_t count);
219 void differences(
const int32_t* a,
const int32_t* b, int32_t* diff,
size_t size);
220 void differences(
const double* a,
const double* b,
double* diff,
size_t size);
221 void add_multiple_of_sum(
const double* a,
const double* b,
const double& c,
double* out,
size_t count);
222 void assign_multiple(
const double* a,
const double& c,
double* out,
size_t count);
223 double inner_product(
const double* a,
const double* b,
size_t count);
int totalsize() const
What is the total number of elements in the image (i.e. size().x * size().y), including padding...
bool is_aligned< 16 >(const void *ptr)
static R sum_squared_differences(const T *a, const T *b, size_t count)
bool is_aligned< 8 >(const void *ptr)
bool is_aligned(const void *ptr)
Check if the pointer is aligned to the specified byte granularity.
double sum_squared_differences(const T *a, const T *b, size_t count)
void copy(const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1,-1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())
size_t steps_to_align(const T *ptr)
Compute the number of pointer increments necessary to yield alignment of A bytes. ...
void zeroPixels(T *pixels, int count)
void square(const T1 *in, T2 *out, size_t count)
void zeroBorders(BasicImage< T > &I)
Set the one-pixel border (top, bottom, sides) of an image to zero values.
ImageRef size() const
What is the size of this image?
const T * data() const
Returns the raw image data.
double inner_product(const T *a, const T *b, size_t count)
void add_multiple_of_sum(const A *a, const A *b, const C &c, B *out, size_t count)
void assign_multiple(const A *a, const B &c, C *out, size_t count)
static void zero(T *pixels, int count)
void differences(const A *a, const A *b, B *diff, size_t count)
void fillBorders(SubImage< T > &im, const T pix, int w=1)
bool in_image(const ImageRef &ir) const
static void zero(T *pixels, int count)
void subtract_square(const T1 *in, T2 *out, size_t count)
static void convert(const From *from, To *to, size_t count)