Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromopencv/opencv

Commit67fe2ba

Browse files
asmorkalovRostislav Vasilikhin
authored and
Rostislav Vasilikhin
committed
Merge pull requestopencv#25789 from asmorkalov:as/HAL_meanStdDev_tails
Fill mean and stdDev tails with zeros for HAL branch in meanStdDevopencv#25789as it's done for other branches.See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [ ] There is a reference to the original bug report and related work- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [ ] The feature is well documented and sample code can be built with the project CMake
1 parentdad8af6 commit67fe2ba

File tree

1 file changed

+62
-12
lines changed

1 file changed

+62
-12
lines changed

‎modules/core/src/mean.dispatch.cpp‎

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,64 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray
525525

526526
Mat src = _src.getMat(), mask = _mask.getMat();
527527

528+
CV_Assert(mask.empty() || src.size == mask.size);
529+
528530
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MEAN_STDDEV>(src.cols, src.rows),
529531
openvx_meanStdDev(src, _mean, _sdv, mask))
530532

531533
CV_IPP_RUN(IPP_VERSION_X100 >=700,ipp_meanStdDev(src, _mean, _sdv, mask));
532534

533535
int k, cn = src.channels(), depth = src.depth();
536+
Mat mean_mat, stddev_mat;
537+
538+
if(_mean.needed())
539+
{
540+
if( !_mean.fixedSize() )
541+
_mean.create(cn,1, CV_64F, -1,true);
542+
543+
mean_mat = _mean.getMat();
544+
int dcn = (int)mean_mat.total();
545+
CV_Assert( mean_mat.type() == CV_64F && mean_mat.isContinuous() &&
546+
(mean_mat.cols ==1 || mean_mat.rows ==1) && dcn >= cn );
547+
548+
double* dptr = mean_mat.ptr<double>();
549+
for(k = cn ; k < dcn; k++ )
550+
dptr[k] =0;
551+
}
552+
553+
if (_sdv.needed())
554+
{
555+
if( !_sdv.fixedSize() )
556+
_sdv.create(cn,1, CV_64F, -1,true);
557+
558+
stddev_mat = _sdv.getMat();
559+
int dcn = (int)stddev_mat.total();
560+
CV_Assert( stddev_mat.type() == CV_64F && stddev_mat.isContinuous() &&
561+
(stddev_mat.cols ==1 || stddev_mat.rows ==1) && dcn >= cn );
562+
563+
double* dptr = stddev_mat.ptr<double>();
564+
for(k = cn ; k < dcn; k++ )
565+
dptr[k] =0;
566+
567+
}
568+
569+
if (src.isContinuous() && mask.isContinuous())
570+
{
571+
CALL_HAL(meanStdDev, cv_hal_meanStdDev, src.data,0, (int)src.total(),1, src.type(),
572+
_mean.needed() ? mean_mat.ptr<double>() :nullptr,
573+
_sdv.needed() ? stddev_mat.ptr<double>() :nullptr,
574+
mask.data,0);
575+
}
576+
else
577+
{
578+
if (src.dims <=2)
579+
{
580+
CALL_HAL(meanStdDev, cv_hal_meanStdDev, src.data, src.step, src.cols, src.rows, src.type(),
581+
_mean.needed() ? mean_mat.ptr<double>() :nullptr,
582+
_sdv.needed() ? stddev_mat.ptr<double>() :nullptr,
583+
mask.data, mask.step);
584+
}
585+
}
534586

535587
SumSqrFunc func =getSumSqrFunc(depth);
536588

@@ -600,20 +652,18 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray
600652
sq[k] =std::sqrt(std::max(sq[k]*scale - s[k]*s[k],0.));
601653
}
602654

603-
for( j =0; j <2; j++)
655+
if (_mean.needed())
604656
{
605-
constdouble* sptr = j ==0 ? s : sq;
606-
_OutputArray _dst = j ==0 ? _mean : _sdv;
607-
if( !_dst.needed() )
608-
continue;
657+
constdouble* sptr = s;
658+
double* dptr = mean_mat.ptr<double>();
659+
for( k =0; k < cn; k++ )
660+
dptr[k] = sptr[k];
661+
}
609662

610-
if( !_dst.fixedSize() )
611-
_dst.create(cn,1, CV_64F, -1,true);
612-
Mat dst = _dst.getMat();
613-
int dcn = (int)dst.total();
614-
CV_Assert( dst.type() == CV_64F && dst.isContinuous() &&
615-
(dst.cols ==1 || dst.rows ==1) && dcn >= cn );
616-
double* dptr = dst.ptr<double>();
663+
if (_sdv.needed())
664+
{
665+
constdouble* sptr = sq;
666+
double* dptr = stddev_mat.ptr<double>();
617667
for( k =0; k < cn; k++ )
618668
dptr[k] = sptr[k];
619669
for( ; k < dcn; k++ )

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp