Update to 2.0.0 tree from current Fremantle build
[opencv] / src / cv / cvaccum.cpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                           License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 /
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 //   * Redistribution's of source code must retain the above copyright notice,
21 //     this list of conditions and the following disclaimer.
22 //
23 //   * Redistribution's in binary form must reproduce the above copyright notice,
24 //     this list of conditions and the following disclaimer in the documentation
25 //     and/or other materials provided with the distribution.
26 //
27 //   * The name of the copyright holders may not be used to endorse or promote products
28 //     derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42
43 #include "_cv.h"
44
45 namespace cv
46 {
47
48 inline float sqr(uchar a) { return CV_8TO32F_SQR(a); }
49 inline float sqr(float a) { return a*a; }
50     
51 inline double sqr(double a) { return a*a; }
52     
53 inline Vec3f sqr(const Vec3b& a)
54 {
55     return Vec3f(CV_8TO32F_SQR(a[0]), CV_8TO32F_SQR(a[1]), CV_8TO32F_SQR(a[2]));
56 }
57 inline Vec3f sqr(const Vec3f& a)
58 {
59     return Vec3f(a[0]*a[0], a[1]*a[1], a[2]*a[2]);
60 }
61 inline Vec3d sqr(const Vec3d& a)
62 {
63     return Vec3d(a[0]*a[0], a[1]*a[1], a[2]*a[2]);
64 }   
65 inline float multiply(uchar a, uchar b) { return CV_8TO32F(a)*CV_8TO32F(b); }
66 inline float multiply(float a, float b) { return a*b; }
67 inline double multiply(double a, double b) { return a*b; }    
68 inline Vec3f multiply(const Vec3b& a, const Vec3b& b)
69 {
70     return Vec3f(
71         CV_8TO32F(a[0])*CV_8TO32F(b[0]),
72         CV_8TO32F(a[1])*CV_8TO32F(b[1]),
73         CV_8TO32F(a[2])*CV_8TO32F(b[2]));
74 }
75 inline Vec3f multiply(const Vec3f& a, const Vec3f& b)
76 {
77     return Vec3f(a[0]*b[0], a[1]*b[1], a[2]*b[2]);
78 }
79 inline Vec3d multiply(const Vec3d& a, const Vec3d& b)
80 {
81     return Vec3d(a[0]*b[0], a[1]*b[1], a[2]*b[2]);
82 }
83     
84 inline float addw(uchar a, float alpha, float b, float beta)
85 {
86     return b*beta + CV_8TO32F(a)*alpha;
87 }
88 inline float addw(float a, float alpha, float b, float beta)
89 {
90     return b*beta + a*alpha;
91 }
92 inline double addw(uchar a, double alpha, double b, double beta)
93 {
94     return b*beta + CV_8TO32F(a)*alpha;
95 }
96 inline double addw(float a, double alpha, double b, double beta)
97 {
98     return b*beta + a*alpha;
99 }
100 inline double addw(double a, double alpha, double b, double beta)
101 {
102     return b*beta + a*alpha;
103 }
104     
105 inline Vec3f addw(const Vec3b& a, float alpha, const Vec3f& b, float beta)
106 {
107     return Vec3f(b[0]*beta + CV_8TO32F(a[0])*alpha,
108                  b[1]*beta + CV_8TO32F(a[1])*alpha,
109                  b[2]*beta + CV_8TO32F(a[2])*alpha);
110 }
111 inline Vec3f addw(const Vec3f& a, float alpha, const Vec3f& b, float beta)
112 {
113     return Vec3f(b[0]*beta + a[0]*alpha, b[1]*beta + a[1]*alpha, b[2]*beta + a[2]*alpha);
114 }
115 inline Vec3d addw(const Vec3b& a, double alpha, const Vec3d& b, double beta)
116 {
117     return Vec3d(b[0]*beta + CV_8TO32F(a[0])*alpha,
118                  b[1]*beta + CV_8TO32F(a[1])*alpha,
119                  b[2]*beta + CV_8TO32F(a[2])*alpha);
120 }
121 inline Vec3d addw(const Vec3f& a, double alpha, const Vec3d& b, double beta)
122 {
123     return Vec3d(b[0]*beta + a[0]*alpha, b[1]*beta + a[1]*alpha, b[2]*beta + a[2]*alpha);
124 }
125 inline Vec3d addw(const Vec3d& a, double alpha, const Vec3d& b, double beta)
126 {
127     return Vec3d(b[0]*beta + a[0]*alpha, b[1]*beta + a[1]*alpha, b[2]*beta + a[2]*alpha);
128 }    
129
130 template<typename T, typename AT> void
131 acc_( const Mat& _src, Mat& _dst )
132 {
133     Size size = _src.size();
134     size.width *= _src.channels();
135
136     if( _src.isContinuous() && _dst.isContinuous() )
137     {
138         size.width *= size.height;
139         size.height = 1;
140     }
141
142     int i, j;
143     for( i = 0; i < size.height; i++ )
144     {
145         const T* src = (const T*)(_src.data + _src.step*i);
146         AT* dst = (AT*)(_dst.data + _dst.step*i);
147
148         for( j = 0; j <= size.width - 4; j += 4 )
149         {
150             AT t0 = dst[j] + src[j], t1 = dst[j+1] + src[j+1];
151             dst[j] = t0; dst[j+1] = t1;
152             t0 = dst[j+2] + src[j+2]; t1 = dst[j+3] + src[j+3];
153             dst[j+2] = t0; dst[j+3] = t1;
154         }
155
156         for( ; j < size.width; j++ )
157             dst[j] += src[j];
158     }
159 }
160
161
162 template<typename T, typename AT> void
163 accSqr_( const Mat& _src, Mat& _dst )
164 {
165     Size size = _src.size();
166     size.width *= _src.channels();
167
168     if( _src.isContinuous() && _dst.isContinuous() )
169     {
170         size.width *= size.height;
171         size.height = 1;
172     }
173
174     int i, j;
175     for( i = 0; i < size.height; i++ )
176     {
177         const T* src = (const T*)(_src.data + _src.step*i);
178         AT* dst = (AT*)(_dst.data + _dst.step*i);
179
180         for( j = 0; j <= size.width - 4; j += 4 )
181         {
182             AT t0 = dst[j] + sqr(src[j]), t1 = dst[j+1] + sqr(src[j+1]);
183             dst[j] = t0; dst[j+1] = t1;
184             t0 = dst[j+2] + sqr(src[j+2]); t1 = dst[j+3] + sqr(src[j+3]);
185             dst[j+2] = t0; dst[j+3] = t1;
186         }
187
188         for( ; j < size.width; j++ )
189             dst[j] += sqr(src[j]);
190     }
191 }
192
193
194 template<typename T, typename AT> void
195 accProd_( const Mat& _src1, const Mat& _src2, Mat& _dst )
196 {
197     Size size = _src1.size();
198     size.width *= _src1.channels();
199
200     if( _src1.isContinuous() && _src2.isContinuous() && _dst.isContinuous() )
201     {
202         size.width *= size.height;
203         size.height = 1;
204     }
205
206     int i, j;
207     for( i = 0; i < size.height; i++ )
208     {
209         const T* src1 = (const T*)(_src1.data + _src1.step*i);
210         const T* src2 = (const T*)(_src2.data + _src2.step*i);
211         AT* dst = (AT*)(_dst.data + _dst.step*i);
212
213         for( j = 0; j <= size.width - 4; j += 4 )
214         {
215             AT t0, t1;
216             t0 = dst[j] + multiply(src1[j], src2[j]);
217             t1 = dst[j+1] + multiply(src1[j+1], src2[j+1]);
218             dst[j] = t0; dst[j+1] = t1;
219             t0 = dst[j+2] + multiply(src1[j+2], src2[j+2]);
220             t1 = dst[j+3] + multiply(src1[j+3], src2[j+3]);
221             dst[j+2] = t0; dst[j+3] = t1;
222         }
223
224         for( ; j < size.width; j++ )
225             dst[j] += multiply(src1[j], src2[j]);
226     }
227 }
228
229
230 template<typename T, typename AT> void
231 accW_( const Mat& _src, Mat& _dst, double _alpha )
232 {
233     AT alpha = (AT)_alpha, beta = (AT)(1 - _alpha);
234     Size size = _src.size();
235     size.width *= _src.channels();
236
237     if( _src.isContinuous() && _dst.isContinuous() )
238     {
239         size.width *= size.height;
240         size.height = 1;
241     }
242
243     int i, j;
244     for( i = 0; i < size.height; i++ )
245     {
246         const T* src = (const T*)(_src.data + _src.step*i);
247         AT* dst = (AT*)(_dst.data + _dst.step*i);
248
249         for( j = 0; j <= size.width - 4; j += 4 )
250         {
251             AT t0, t1;
252             t0 = addw(src[j], alpha, dst[j], beta);
253             t1 = addw(src[j+1], alpha, dst[j+1], beta);
254             dst[j] = t0; dst[j+1] = t1;
255             t0 = addw(src[j+2], alpha, dst[j+2], beta);
256             t1 = addw(src[j+3], alpha, dst[j+3], beta);
257             dst[j+2] = t0; dst[j+3] = t1;
258         }
259
260         for( ; j < size.width; j++ )
261             dst[j] = addw(src[j], alpha, dst[j], beta);
262     }
263 }
264
265
266 template<typename T, typename AT> void
267 accMask_( const Mat& _src, Mat& _dst, const Mat& _mask )
268 {
269     Size size = _src.size();
270
271     if( _src.isContinuous() && _dst.isContinuous() && _mask.isContinuous() )
272     {
273         size.width *= size.height;
274         size.height = 1;
275     }
276
277     int i, j;
278     for( i = 0; i < size.height; i++ )
279     {
280         const T* src = (const T*)(_src.data + _src.step*i);
281         AT* dst = (AT*)(_dst.data + _dst.step*i);
282         const uchar* mask = _mask.data + _mask.step*i;
283
284         for( j = 0; j < size.width; j++ )
285             if( mask[j] )
286                 dst[j] += src[j];
287     }
288 }
289
290
291 template<typename T, typename AT> void
292 accSqrMask_( const Mat& _src, Mat& _dst, const Mat& _mask )
293 {
294     Size size = _src.size();
295
296     if( _src.isContinuous() && _dst.isContinuous() && _mask.isContinuous() )
297     {
298         size.width *= size.height;
299         size.height = 1;
300     }
301
302     int i, j;
303     for( i = 0; i < size.height; i++ )
304     {
305         const T* src = (const T*)(_src.data + _src.step*i);
306         AT* dst = (AT*)(_dst.data + _dst.step*i);
307         const uchar* mask = _mask.data + _mask.step*i;
308
309         for( j = 0; j < size.width; j++ )
310             if( mask[j] )
311                 dst[j] += sqr(src[j]);
312     }
313 }
314
315
316 template<typename T, typename AT> void
317 accProdMask_( const Mat& _src1, const Mat& _src2, Mat& _dst, const Mat& _mask )
318 {
319     Size size = _src1.size();
320
321     if( _src1.isContinuous() && _src2.isContinuous() &&
322         _dst.isContinuous() && _mask.isContinuous() )
323     {
324         size.width *= size.height;
325         size.height = 1;
326     }
327
328     int i, j;
329     for( i = 0; i < size.height; i++ )
330     {
331         const T* src1 = (const T*)(_src1.data + _src1.step*i);
332         const T* src2 = (const T*)(_src2.data + _src2.step*i);
333         AT* dst = (AT*)(_dst.data + _dst.step*i);
334         const uchar* mask = _mask.data + _mask.step*i;
335
336         for( j = 0; j < size.width; j++ )
337             if( mask[j] )
338                 dst[j] += multiply(src1[j], src2[j]);
339     }
340 }
341
342
343 template<typename T, typename AT> void
344 accWMask_( const Mat& _src, Mat& _dst, double _alpha, const Mat& _mask )
345 {
346     typedef typename DataType<AT>::channel_type AT1;
347     AT1 alpha = (AT1)_alpha, beta = (AT1)(1 - _alpha);
348     Size size = _src.size();
349
350     if( _src.isContinuous() && _dst.isContinuous() && _mask.isContinuous() )
351     {
352         size.width *= size.height;
353         size.height = 1;
354     }
355
356     int i, j;
357     for( i = 0; i < size.height; i++ )
358     {
359         const T* src = (const T*)(_src.data + _src.step*i);
360         AT* dst = (AT*)(_dst.data + _dst.step*i);
361         const uchar* mask = _mask.data + _mask.step*i;
362
363         for( j = 0; j < size.width; j++ )
364             if( mask[j] )
365                 dst[j] = addw(src[j], alpha, dst[j], beta);
366     }
367 }
368
369
370 typedef void (*AccFunc)(const Mat&, Mat&);
371 typedef void (*AccMaskFunc)(const Mat&, Mat&, const Mat&);
372 typedef void (*AccProdFunc)(const Mat&, const Mat&, Mat&);
373 typedef void (*AccProdMaskFunc)(const Mat&, const Mat&, Mat&, const Mat&);
374 typedef void (*AccWFunc)(const Mat&, Mat&, double);
375 typedef void (*AccWMaskFunc)(const Mat&, Mat&, double, const Mat&);
376
377 void accumulate( const Mat& src, Mat& dst, const Mat& mask )
378 {
379     CV_Assert( dst.size() == src.size() && dst.channels() == src.channels() );
380     
381     if( !mask.data )
382     {
383         AccFunc func = 0;
384         if( src.depth() == CV_8U && dst.depth() == CV_32F )
385             func = acc_<uchar, float>;
386         else if( src.depth() == CV_8U && dst.depth() == CV_64F )
387             func = acc_<uchar, double>;
388         else if( src.depth() == CV_32F && dst.depth() == CV_32F )
389             func = acc_<float, float>;
390         else if( src.depth() == CV_32F && dst.depth() == CV_64F )
391             func = acc_<float, double>;
392         else if( src.depth() == CV_64F && dst.depth() == CV_64F )
393             func = acc_<double, double>;
394         else
395             CV_Error( CV_StsUnsupportedFormat, "" );
396
397         func( src, dst );
398     }
399     else
400     {
401         CV_Assert( mask.size() == src.size() && mask.type() == CV_8UC1 );
402
403         AccMaskFunc func = 0;
404         if( src.type() == CV_8UC1 && dst.type() == CV_32FC1 )
405             func = accMask_<uchar, float>;
406         else if( src.type() == CV_8UC3 && dst.type() == CV_32FC3 )
407             func = accMask_<Vec3b, Vec3f>;
408         else if( src.type() == CV_8UC1 && dst.type() == CV_64FC1 )
409             func = accMask_<uchar, double>;
410         else if( src.type() == CV_8UC3 && dst.type() == CV_64FC3 )
411             func = accMask_<Vec3b, Vec3d>;
412         else if( src.type() == CV_32FC1 && dst.type() == CV_32FC1 )
413             func = accMask_<float, float>;
414         else if( src.type() == CV_32FC3 && dst.type() == CV_32FC3 )
415             func = accMask_<Vec3f, Vec3f>;
416         else if( src.type() == CV_32FC1 && dst.type() == CV_64FC1 )
417             func = accMask_<float, double>;
418         else if( src.type() == CV_32FC3 && dst.type() == CV_64FC3 )
419             func = accMask_<Vec3f, Vec3d>;
420         else if( src.type() == CV_64FC1 && dst.type() == CV_64FC1 )
421             func = accMask_<double, double>;
422         else if( src.type() == CV_64FC3 && dst.type() == CV_64FC3 )
423             func = accMask_<Vec3d, Vec3d>;
424         else
425             CV_Error( CV_StsUnsupportedFormat, "" );
426
427         func( src, dst, mask );
428     }
429 }
430
431
432 void accumulateSquare( const Mat& src, Mat& dst, const Mat& mask )
433 {
434     CV_Assert( dst.size() == src.size() && dst.channels() == src.channels() );
435     
436     if( !mask.data )
437     {
438         AccFunc func = 0;
439         if( src.depth() == CV_8U && dst.depth() == CV_32F )
440             func = accSqr_<uchar, float>;
441         else if( src.depth() == CV_8U && dst.depth() == CV_64F )
442             func = accSqr_<uchar, double>;
443         else if( src.depth() == CV_32F && dst.depth() == CV_32F )
444             func = accSqr_<float, float>;
445         else if( src.depth() == CV_32F && dst.depth() == CV_64F )
446             func = accSqr_<float, double>;
447         else if( src.depth() == CV_64F && dst.depth() == CV_64F )
448             func = accSqr_<double, double>;
449         else
450             CV_Error( CV_StsUnsupportedFormat, "" );
451
452         func( src, dst );
453     }
454     else
455     {
456         CV_Assert( mask.size() == src.size() && mask.type() == CV_8UC1 );
457
458         AccMaskFunc func = 0;
459         if( src.type() == CV_8UC1 && dst.type() == CV_32FC1 )
460             func = accSqrMask_<uchar, float>;
461         else if( src.type() == CV_8UC3 && dst.type() == CV_32FC3 )
462             func = accSqrMask_<Vec3b, Vec3f>;
463         else if( src.type() == CV_8UC1 && dst.type() == CV_64FC1 )
464             func = accSqrMask_<uchar, double>;
465         else if( src.type() == CV_8UC3 && dst.type() == CV_64FC3 )
466             func = accSqrMask_<Vec3b, Vec3d>;
467         else if( src.type() == CV_32FC1 && dst.type() == CV_32FC1 )
468             func = accSqrMask_<float, float>;
469         else if( src.type() == CV_32FC3 && dst.type() == CV_32FC3 )
470             func = accSqrMask_<Vec3f, Vec3f>;
471         else if( src.type() == CV_32FC1 && dst.type() == CV_64FC1 )
472             func = accSqrMask_<float, double>;
473         else if( src.type() == CV_32FC3 && dst.type() == CV_64FC3 )
474             func = accSqrMask_<Vec3f, Vec3d>;
475         else if( src.type() == CV_64FC1 && dst.type() == CV_64FC1 )
476             func = accSqrMask_<double, double>;
477         else if( src.type() == CV_64FC3 && dst.type() == CV_64FC3 )
478             func = accSqrMask_<Vec3d, Vec3d>;
479         else
480             CV_Error( CV_StsUnsupportedFormat, "" );
481
482         func( src, dst, mask );
483     }
484 }
485
486
487 void accumulateProduct( const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask )
488 {
489     CV_Assert( dst.size() == src1.size() && dst.channels() == src1.channels() &&
490                src1.size() == src2.size() && src1.type() == src2.type() );
491     
492     if( !mask.data )
493     {
494         AccProdFunc func = 0;
495         if( src1.depth() == CV_8U && dst.depth() == CV_32F )
496             func = accProd_<uchar, float>;
497         else if( src1.depth() == CV_8U && dst.depth() == CV_64F )
498             func = accProd_<uchar, double>;
499         else if( src1.depth() == CV_32F && dst.depth() == CV_32F )
500             func = accProd_<float, float>;
501         else if( src1.depth() == CV_32F && dst.depth() == CV_64F )
502             func = accProd_<float, double>;
503         else if( src1.depth() == CV_64F && dst.depth() == CV_64F )
504             func = accProd_<double, double>;
505         else
506             CV_Error( CV_StsUnsupportedFormat, "" );
507
508         func( src1, src2, dst );
509     }
510     else
511     {
512         CV_Assert( mask.size() == src1.size() && mask.type() == CV_8UC1 );
513
514         AccProdMaskFunc func = 0;
515         if( src1.type() == CV_8UC1 && dst.type() == CV_32FC1 )
516             func = accProdMask_<uchar, float>;
517         else if( src1.type() == CV_8UC3 && dst.type() == CV_32FC3 )
518             func = accProdMask_<Vec3b, Vec3f>;
519         else if( src1.type() == CV_8UC1 && dst.type() == CV_64FC1 )
520             func = accProdMask_<uchar, double>;
521         else if( src1.type() == CV_8UC3 && dst.type() == CV_64FC3 )
522             func = accProdMask_<Vec3b, Vec3d>;
523         else if( src1.type() == CV_32FC1 && dst.type() == CV_32FC1 )
524             func = accProdMask_<float, float>;
525         else if( src1.type() == CV_32FC3 && dst.type() == CV_32FC3 )
526             func = accProdMask_<Vec3f, Vec3f>;
527         else if( src1.type() == CV_32FC1 && dst.type() == CV_64FC1 )
528             func = accProdMask_<float, double>;
529         else if( src1.type() == CV_32FC3 && dst.type() == CV_64FC3 )
530             func = accProdMask_<Vec3f, Vec3d>;
531         else if( src1.type() == CV_64FC1 && dst.type() == CV_64FC1 )
532             func = accProdMask_<double, double>;
533         else if( src1.type() == CV_64FC3 && dst.type() == CV_64FC3 )
534             func = accProdMask_<Vec3d, Vec3d>;
535         else
536             CV_Error( CV_StsUnsupportedFormat, "" );
537
538         func( src1, src2, dst, mask );
539     }
540 }
541
542
543 void accumulateWeighted( const Mat& src, Mat& dst, double alpha, const Mat& mask )
544 {
545     CV_Assert( dst.size() == src.size() && dst.channels() == src.channels() );
546     
547     if( !mask.data )
548     {
549         AccWFunc func = 0;
550         if( src.depth() == CV_8U && dst.depth() == CV_32F )
551             func = accW_<uchar, float>;
552         else if( src.depth() == CV_8U && dst.depth() == CV_64F )
553             func = accW_<uchar, double>;
554         else if( src.depth() == CV_32F && dst.depth() == CV_32F )
555             func = accW_<float, float>;
556         else if( src.depth() == CV_32F && dst.depth() == CV_64F )
557             func = accW_<float, double>;
558         else if( src.depth() == CV_64F && dst.depth() == CV_64F )
559             func = accW_<double, double>;
560         else
561             CV_Error( CV_StsUnsupportedFormat, "" );
562
563         func( src, dst, alpha );
564     }
565     else
566     {
567         CV_Assert( mask.size() == src.size() && mask.type() == CV_8UC1 );
568
569         AccWMaskFunc func = 0;
570         if( src.type() == CV_8UC1 && dst.type() == CV_32FC1 )
571             func = accWMask_<uchar, float>;
572         else if( src.type() == CV_8UC3 && dst.type() == CV_32FC3 )
573             func = accWMask_<Vec3b, Vec3f>;
574         else if( src.type() == CV_8UC1 && dst.type() == CV_64FC1 )
575             func = accWMask_<uchar, double>;
576         else if( src.type() == CV_8UC3 && dst.type() == CV_64FC3 )
577             func = accWMask_<Vec3b, Vec3d>;
578         else if( src.type() == CV_32FC1 && dst.type() == CV_32FC1 )
579             func = accWMask_<float, float>;
580         else if( src.type() == CV_32FC3 && dst.type() == CV_32FC3 )
581             func = accWMask_<Vec3f, Vec3f>;
582         else if( src.type() == CV_32FC1 && dst.type() == CV_64FC1 )
583             func = accWMask_<float, double>;
584         else if( src.type() == CV_32FC3 && dst.type() == CV_64FC3 )
585             func = accWMask_<Vec3f, Vec3d>;
586         else if( src.type() == CV_64FC1 && dst.type() == CV_64FC1 )
587             func = accWMask_<double, double>;
588         else if( src.type() == CV_64FC3 && dst.type() == CV_64FC3 )
589             func = accWMask_<Vec3d, Vec3d>;
590         else
591             CV_Error( CV_StsUnsupportedFormat, "" );
592
593         func( src, dst, alpha, mask );
594     }
595 }
596
597 }
598
599
600 CV_IMPL void
601 cvAcc( const void* arr, void* sumarr, const void* maskarr )
602 {
603     cv::Mat src = cv::cvarrToMat(arr), dst = cv::cvarrToMat(sumarr), mask;
604     if( maskarr )
605         mask = cv::cvarrToMat(maskarr);
606     cv::accumulate( src, dst, mask );
607 }
608
609 CV_IMPL void
610 cvSquareAcc( const void* arr, void* sumarr, const void* maskarr )
611 {
612     cv::Mat src = cv::cvarrToMat(arr), dst = cv::cvarrToMat(sumarr), mask;
613     if( maskarr )
614         mask = cv::cvarrToMat(maskarr);
615     cv::accumulateSquare( src, dst, mask );
616 }
617
618 CV_IMPL void
619 cvMultiplyAcc( const void* arr1, const void* arr2,
620                void* sumarr, const void* maskarr )
621 {
622     cv::Mat src1 = cv::cvarrToMat(arr1), src2 = cv::cvarrToMat(arr2);
623     cv::Mat dst = cv::cvarrToMat(sumarr), mask;
624     if( maskarr )
625         mask = cv::cvarrToMat(maskarr);
626     cv::accumulateProduct( src1, src2, dst, mask );
627 }
628
629 CV_IMPL void
630 cvRunningAvg( const void* arr, void* sumarr, double alpha, const void* maskarr )
631 {
632     cv::Mat src = cv::cvarrToMat(arr), dst = cv::cvarrToMat(sumarr), mask;
633     if( maskarr )
634         mask = cv::cvarrToMat(maskarr);
635     cv::accumulateWeighted( src, dst, alpha, mask );
636 }
637
638 /* End of file. */