|
|
|
@ -525,12 +525,55 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
CV_Assert(mask.empty() || src.size == mask.size); |
|
|
|
|
|
|
|
|
|
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MEAN_STDDEV>(src.cols, src.rows), |
|
|
|
|
openvx_meanStdDev(src, _mean, _sdv, mask)) |
|
|
|
|
|
|
|
|
|
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask)); |
|
|
|
|
|
|
|
|
|
int k, cn = src.channels(), depth = src.depth(); |
|
|
|
|
Mat mean_mat, stddev_mat; |
|
|
|
|
|
|
|
|
|
if(_mean.needed()) |
|
|
|
|
{ |
|
|
|
|
if( !_mean.fixedSize() ) |
|
|
|
|
_mean.create(cn, 1, CV_64F, -1, true); |
|
|
|
|
|
|
|
|
|
mean_mat = _mean.getMat(); |
|
|
|
|
int dcn = (int)mean_mat.total(); |
|
|
|
|
CV_Assert( mean_mat.type() == CV_64F && mean_mat.isContinuous() && |
|
|
|
|
(mean_mat.cols == 1 || mean_mat.rows == 1) && dcn >= cn ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (_sdv.needed()) |
|
|
|
|
{ |
|
|
|
|
if( !_sdv.fixedSize() ) |
|
|
|
|
_sdv.create(cn, 1, CV_64F, -1, true); |
|
|
|
|
|
|
|
|
|
stddev_mat = _sdv.getMat(); |
|
|
|
|
int dcn = (int)stddev_mat.total(); |
|
|
|
|
CV_Assert( stddev_mat.type() == CV_64F && stddev_mat.isContinuous() && |
|
|
|
|
(stddev_mat.cols == 1 || stddev_mat.rows == 1) && dcn >= cn ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (src.isContinuous() && mask.isContinuous()) |
|
|
|
|
{ |
|
|
|
|
CALL_HAL(meanStdDev, cv_hal_meanStdDev, src.data, 0, (int)src.total(), 1, src.type(), |
|
|
|
|
_mean.needed() ? mean_mat.ptr<double>() : nullptr, |
|
|
|
|
_sdv.needed() ? stddev_mat.ptr<double>() : nullptr, |
|
|
|
|
mask.data, 0); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (src.dims <= 2) |
|
|
|
|
{ |
|
|
|
|
CALL_HAL(meanStdDev, cv_hal_meanStdDev, src.data, src.step, src.cols, src.rows, src.type(), |
|
|
|
|
_mean.needed() ? mean_mat.ptr<double>() : nullptr, |
|
|
|
|
_sdv.needed() ? stddev_mat.ptr<double>() : nullptr, |
|
|
|
|
mask.data, mask.step); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SumSqrFunc func = getSumSqrFunc(depth); |
|
|
|
|
|
|
|
|
@ -600,20 +643,22 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray |
|
|
|
|
sq[k] = std::sqrt(std::max(sq[k]*scale - s[k]*s[k], 0.)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for( j = 0; j < 2; j++ ) |
|
|
|
|
if (_mean.needed()) |
|
|
|
|
{ |
|
|
|
|
const double* sptr = j == 0 ? s : sq; |
|
|
|
|
_OutputArray _dst = j == 0 ? _mean : _sdv; |
|
|
|
|
if( !_dst.needed() ) |
|
|
|
|
continue; |
|
|
|
|
const double* sptr = s; |
|
|
|
|
int dcn = (int)mean_mat.total(); |
|
|
|
|
double* dptr = mean_mat.ptr<double>(); |
|
|
|
|
for( k = 0; k < cn; k++ ) |
|
|
|
|
dptr[k] = sptr[k]; |
|
|
|
|
for( ; k < dcn; k++ ) |
|
|
|
|
dptr[k] = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( !_dst.fixedSize() ) |
|
|
|
|
_dst.create(cn, 1, CV_64F, -1, true); |
|
|
|
|
Mat dst = _dst.getMat(); |
|
|
|
|
int dcn = (int)dst.total(); |
|
|
|
|
CV_Assert( dst.type() == CV_64F && dst.isContinuous() && |
|
|
|
|
(dst.cols == 1 || dst.rows == 1) && dcn >= cn ); |
|
|
|
|
double* dptr = dst.ptr<double>(); |
|
|
|
|
if (_sdv.needed()) |
|
|
|
|
{ |
|
|
|
|
const double* sptr = sq; |
|
|
|
|
int dcn = (int)stddev_mat.total(); |
|
|
|
|
double* dptr = stddev_mat.ptr<double>(); |
|
|
|
|
for( k = 0; k < cn; k++ ) |
|
|
|
|
dptr[k] = sptr[k]; |
|
|
|
|
for( ; k < dcn; k++ ) |
|
|
|
|