MCPcopy Create free account
hub / github.com/creatale/node-dv / mean

Method mean

deps/opencv/modules/core/src/stat.cpp:562–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562cv::Scalar cv::mean( InputArray _src, InputArray _mask )
563{
564 Mat src = _src.getMat(), mask = _mask.getMat();
565 CV_Assert( mask.empty() || mask.type() == CV_8U );
566
567 int k, cn = src.channels(), depth = src.depth();
568
569#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
570 size_t total_size = src.total();
571 int rows = src.size[0], cols = (int)(total_size/rows);
572 if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
573 {
574 IppiSize sz = { cols, rows };
575 int type = src.type();
576 if( !mask.empty() )
577 {
578 typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *);
579 ippiMaskMeanFuncC1 ippFuncC1 =
580 type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
581 type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
582 type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
583 0;
584 if( ippFuncC1 )
585 {
586 Ipp64f res;
587 if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &res) >= 0 )
588 {
589 return Scalar(res);
590 }
591 }
592 typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *);
593 ippiMaskMeanFuncC3 ippFuncC3 =
594 type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
595 type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
596 type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
597 0;
598 if( ippFuncC3 )
599 {
600 Ipp64f res1, res2, res3;
601 if( ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &res1) >= 0 &&
602 ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &res2) >= 0 &&
603 ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &res3) >= 0 )
604 {
605 return Scalar(res1, res2, res3);
606 }
607 }
608 }
609 else
610 {
611 typedef IppStatus (CV_STDCALL* ippiMeanFunc)(const void*, int, IppiSize, double *, int);
612 ippiMeanFunc ippFunc =
613 type == CV_8UC1 ? (ippiMeanFunc)ippiMean_8u_C1R :
614 type == CV_8UC3 ? (ippiMeanFunc)ippiMean_8u_C3R :
615 type == CV_8UC4 ? (ippiMeanFunc)ippiMean_8u_C4R :
616 type == CV_16UC1 ? (ippiMeanFunc)ippiMean_16u_C1R :
617 type == CV_16UC3 ? (ippiMeanFunc)ippiMean_16u_C3R :
618 type == CV_16UC4 ? (ippiMeanFunc)ippiMean_16u_C4R :
619 type == CV_16SC1 ? (ippiMeanFunc)ippiMean_16s_C1R :

Callers

nothing calls this directly

Calls 11

getSumFuncFunction · 0.85
minFunction · 0.70
getMatMethod · 0.45
emptyMethod · 0.45
typeMethod · 0.45
channelsMethod · 0.45
depthMethod · 0.45
totalMethod · 0.45
isContinuousMethod · 0.45
allocateMethod · 0.45
elemSizeMethod · 0.45

Tested by

no test coverage detected