mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge branch 4.x
This commit is contained in:
@@ -313,7 +313,6 @@ Ptr<FilterEngine> createBoxFilter(int srcType, int dstType, Size ksize,
|
||||
CV_CPU_DISPATCH_MODES_ALL);
|
||||
}
|
||||
|
||||
|
||||
#if 0 //defined(HAVE_IPP)
|
||||
static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool normalize, int borderType)
|
||||
{
|
||||
|
||||
@@ -378,7 +378,6 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
CALL_HAL(sobel, cv_hal_sobel, src.ptr(), src.step, dst.ptr(), dst.step, src.cols, src.rows, sdepth, ddepth, cn,
|
||||
ofs.x, ofs.y, wsz.width - src.cols - ofs.x, wsz.height - src.rows - ofs.y, dx, dy, ksize, scale, delta, borderType&~BORDER_ISOLATED);
|
||||
|
||||
|
||||
//CV_IPP_RUN_FAST(ipp_Deriv(src, dst, dx, dy, ksize, scale, delta, borderType));
|
||||
|
||||
sepFilter2D(src, dst, ddepth, kx, ky, Point(-1, -1), delta, borderType );
|
||||
|
||||
@@ -592,7 +592,6 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
|
||||
// For smaller filter kernels, there is a special kernel that is more
|
||||
// efficient than the general one.
|
||||
UMat kernalDataUMat;
|
||||
if (device.isIntel() && (device.type() & ocl::Device::TYPE_GPU) &&
|
||||
((ksize.width < 5 && ksize.height < 5) ||
|
||||
(ksize.width == 5 && ksize.height == 5 && cn == 1)))
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#ifndef OPENCV_IMGPROC_FILTER_HPP
|
||||
#define OPENCV_IMGPROC_FILTER_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -283,7 +283,7 @@ floodFillGrad_CnIR( Mat& image, Mat& msk,
|
||||
Diff diff, ConnectedComp* region, int flags,
|
||||
std::vector<FFillSegment>* buffer )
|
||||
{
|
||||
size_t step = image.step, maskStep = msk.step;
|
||||
auto step = static_cast<std::ptrdiff_t>(image.step), maskStep = static_cast<std::ptrdiff_t>(msk.step);
|
||||
uchar* pImage = image.ptr();
|
||||
_Tp* img = (_Tp*)(pImage + step*seed.y);
|
||||
uchar* pMask = msk.ptr() + maskStep + sizeof(_MTp);
|
||||
|
||||
@@ -957,7 +957,7 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
sum += S[0]*w[8] + S[cn]*w[9] + S[cn*2]*w[10] + S[cn*3]*w[11];
|
||||
S += sstep;
|
||||
sum += S[0]*w[12] + S[cn]*w[13] + S[cn*2]*w[14] + S[cn*3]*w[15];
|
||||
S += 1 - sstep*3;
|
||||
S -= sstep * 3 - 1;
|
||||
D[k] = castOp(sum);
|
||||
}
|
||||
}
|
||||
@@ -990,9 +990,9 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
for(int i = 0; i < 4; i++, w += 4 )
|
||||
{
|
||||
int yi = y[i];
|
||||
const T* S = S0 + yi*sstep;
|
||||
if( yi < 0 )
|
||||
continue;
|
||||
const T* S = S0 + yi*sstep;
|
||||
if( x[0] >= 0 )
|
||||
sum += (S[x[0]] - cv)*w[0];
|
||||
if( x[1] >= 0 )
|
||||
@@ -1050,9 +1050,9 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
const int off_x = isRelative ? (_offset.x+dx) : 0;
|
||||
int sx = XY[dx*2]-3+off_x, sy = XY[dx*2+1]-3+off_y;
|
||||
const AT* w = wtab + FXY[dx]*64;
|
||||
const T* S = S0 + sy*sstep + sx*cn;
|
||||
if( (unsigned)sx < width1 && (unsigned)sy < height1 )
|
||||
{
|
||||
const T* S = S0 + sy*sstep + sx*cn;
|
||||
for(int k = 0; k < cn; k++ )
|
||||
{
|
||||
WT sum = 0;
|
||||
@@ -1093,9 +1093,9 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
for(int i = 0; i < 8; i++, w += 8 )
|
||||
{
|
||||
int yi = y[i];
|
||||
const T* S1 = S0 + yi*sstep;
|
||||
if( yi < 0 )
|
||||
continue;
|
||||
const T* S1 = S0 + yi*sstep;
|
||||
if( x[0] >= 0 )
|
||||
sum += (S1[x[0]] - cv)*w[0];
|
||||
if( x[1] >= 0 )
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
||||
@@ -340,9 +340,10 @@ double cv::contourArea( InputArray _contour, bool oriented )
|
||||
namespace cv
|
||||
{
|
||||
|
||||
static inline Point2f getOfs(int i, float eps)
|
||||
static inline Point2f getOfs(float eps)
|
||||
{
|
||||
return Point2f(((i & 1)*2 - 1)*eps, ((i & 2) - 1)*eps);
|
||||
RNG& rng = theRNG();
|
||||
return Point2f(rng.uniform(-eps, eps), rng.uniform(-eps, eps));
|
||||
}
|
||||
|
||||
static RotatedRect fitEllipseNoDirect( InputArray _points )
|
||||
@@ -419,7 +420,7 @@ static RotatedRect fitEllipseNoDirect( InputArray _points )
|
||||
float eps = (float)(s/(n*2)*1e-3);
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
Point2f p = ptsf_copy[i] + getOfs(i, eps);
|
||||
const Point2f p = ptsf_copy[i] + getOfs(eps);
|
||||
ptsf_copy[i] = p;
|
||||
}
|
||||
|
||||
@@ -515,6 +516,7 @@ cv::RotatedRect cv::fitEllipseAMS( InputArray _points )
|
||||
Mat points = _points.getMat();
|
||||
int i, n = points.checkVector(2);
|
||||
int depth = points.depth();
|
||||
float eps = 0;
|
||||
CV_Assert( n >= 0 && (depth == CV_32F || depth == CV_32S));
|
||||
|
||||
RotatedRect box;
|
||||
@@ -552,57 +554,70 @@ cv::RotatedRect cv::fitEllipseAMS( InputArray _points )
|
||||
}
|
||||
double scale = 100./(s > FLT_EPSILON ? s : (double)FLT_EPSILON);
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
// first, try the original pointset.
|
||||
// if it's singular, try to shift the points a bit
|
||||
int iter = 0;
|
||||
for( iter = 0; iter < 2; iter++ )
|
||||
{
|
||||
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
|
||||
double px = (p.x - c.x)*scale, py = (p.y - c.y)*scale;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
|
||||
const Point2f delta = getOfs(eps);
|
||||
const double px = (p.x + delta.x - c.x)*scale, py = (p.y + delta.y - c.y)*scale;
|
||||
|
||||
A.at<double>(i,0) = px*px;
|
||||
A.at<double>(i,1) = px*py;
|
||||
A.at<double>(i,2) = py*py;
|
||||
A.at<double>(i,3) = px;
|
||||
A.at<double>(i,4) = py;
|
||||
A.at<double>(i,5) = 1.0;
|
||||
A.at<double>(i,0) = px*px;
|
||||
A.at<double>(i,1) = px*py;
|
||||
A.at<double>(i,2) = py*py;
|
||||
A.at<double>(i,3) = px;
|
||||
A.at<double>(i,4) = py;
|
||||
A.at<double>(i,5) = 1.0;
|
||||
}
|
||||
cv::mulTransposed( A, DM, true, noArray(), 1.0, -1 );
|
||||
DM *= (1.0/n);
|
||||
double dnm = ( DM(2,5)*(DM(0,5) + DM(2,5)) - (DM(1,5)*DM(1,5)) );
|
||||
double ddm = (4.*(DM(0,5) + DM(2,5))*( (DM(0,5)*DM(2,5)) - (DM(1,5)*DM(1,5))));
|
||||
double ddmm = (2.*(DM(0,5) + DM(2,5))*( (DM(0,5)*DM(2,5)) - (DM(1,5)*DM(1,5))));
|
||||
|
||||
M(0,0)=((-DM(0,0) + DM(0,2) + DM(0,5)*DM(0,5))*(DM(1,5)*DM(1,5)) + (-2*DM(0,1)*DM(1,5) + DM(0,5)*(DM(0,0) \
|
||||
- (DM(0,5)*DM(0,5)) + (DM(1,5)*DM(1,5))))*DM(2,5) + (DM(0,0) - (DM(0,5)*DM(0,5)))*(DM(2,5)*DM(2,5))) / ddm;
|
||||
M(0,1)=((DM(1,5)*DM(1,5))*(-DM(0,1) + DM(1,2) + DM(0,5)*DM(1,5)) + (DM(0,1)*DM(0,5) - ((DM(0,5)*DM(0,5)) + 2*DM(1,1))*DM(1,5) + \
|
||||
(DM(1,5)*DM(1,5)*DM(1,5)))*DM(2,5) + (DM(0,1) - DM(0,5)*DM(1,5))*(DM(2,5)*DM(2,5))) / ddm;
|
||||
M(0,2)=(-2*DM(1,2)*DM(1,5)*DM(2,5) - DM(0,5)*(DM(2,5)*DM(2,5))*(DM(0,5) + DM(2,5)) + DM(0,2)*dnm + \
|
||||
(DM(1,5)*DM(1,5))*(DM(2,2) + DM(2,5)*(DM(0,5) + DM(2,5))))/ddm;
|
||||
M(0,3)=(DM(1,5)*(DM(1,5)*DM(2,3) - 2*DM(1,3)*DM(2,5)) + DM(0,3)*dnm) / ddm;
|
||||
M(0,4)=(DM(1,5)*(DM(1,5)*DM(2,4) - 2*DM(1,4)*DM(2,5)) + DM(0,4)*dnm) / ddm;
|
||||
M(1,0)=(-(DM(0,2)*DM(0,5)*DM(1,5)) + (2*DM(0,1)*DM(0,5) - DM(0,0)*DM(1,5))*DM(2,5))/ddmm;
|
||||
M(1,1)=(-(DM(0,1)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,2)*DM(1,5)) + 2*DM(1,1)*DM(2,5)))/ddmm;
|
||||
M(1,2)=(-(DM(0,2)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,2)) + 2*DM(1,2)*DM(2,5)))/ddmm;
|
||||
M(1,3)=(-(DM(0,3)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,3)) + 2*DM(1,3)*DM(2,5)))/ddmm;
|
||||
M(1,4)=(-(DM(0,4)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,4)) + 2*DM(1,4)*DM(2,5)))/ddmm;
|
||||
M(2,0)=(-2*DM(0,1)*DM(0,5)*DM(1,5) + (DM(0,0) + (DM(0,5)*DM(0,5)))*(DM(1,5)*DM(1,5)) + DM(0,5)*(-(DM(0,5)*DM(0,5)) \
|
||||
+ (DM(1,5)*DM(1,5)))*DM(2,5) - (DM(0,5)*DM(0,5))*(DM(2,5)*DM(2,5)) + DM(0,2)*(-(DM(1,5)*DM(1,5)) + DM(0,5)*(DM(0,5) + DM(2,5)))) / ddm;
|
||||
M(2,1)=((DM(0,5)*DM(0,5))*(DM(1,2) - DM(1,5)*DM(2,5)) + (DM(1,5)*DM(1,5))*(DM(0,1) - DM(1,2) + DM(1,5)*DM(2,5)) \
|
||||
+ DM(0,5)*(DM(1,2)*DM(2,5) + DM(1,5)*(-2*DM(1,1) + (DM(1,5)*DM(1,5)) - (DM(2,5)*DM(2,5))))) / ddm;
|
||||
M(2,2)=((DM(0,5)*DM(0,5))*(DM(2,2) - (DM(2,5)*DM(2,5))) + (DM(1,5)*DM(1,5))*(DM(0,2) - DM(2,2) + (DM(2,5)*DM(2,5))) + \
|
||||
DM(0,5)*(-2*DM(1,2)*DM(1,5) + DM(2,5)*((DM(1,5)*DM(1,5)) + DM(2,2) - (DM(2,5)*DM(2,5))))) / ddm;
|
||||
M(2,3)=((DM(1,5)*DM(1,5))*(DM(0,3) - DM(2,3)) + (DM(0,5)*DM(0,5))*DM(2,3) + DM(0,5)*(-2*DM(1,3)*DM(1,5) + DM(2,3)*DM(2,5))) / ddm;
|
||||
M(2,4)=((DM(1,5)*DM(1,5))*(DM(0,4) - DM(2,4)) + (DM(0,5)*DM(0,5))*DM(2,4) + DM(0,5)*(-2*DM(1,4)*DM(1,5) + DM(2,4)*DM(2,5))) / ddm;
|
||||
M(3,0)=DM(0,3);
|
||||
M(3,1)=DM(1,3);
|
||||
M(3,2)=DM(2,3);
|
||||
M(3,3)=DM(3,3);
|
||||
M(3,4)=DM(3,4);
|
||||
M(4,0)=DM(0,4);
|
||||
M(4,1)=DM(1,4);
|
||||
M(4,2)=DM(2,4);
|
||||
M(4,3)=DM(3,4);
|
||||
M(4,4)=DM(4,4);
|
||||
|
||||
if (fabs(cv::determinant(M)) > 1.0e-10) {
|
||||
break;
|
||||
}
|
||||
|
||||
eps = (float)(s/(n*2)*1e-2);
|
||||
}
|
||||
cv::mulTransposed( A, DM, true, noArray(), 1.0, -1 );
|
||||
DM *= (1.0/n);
|
||||
double dnm = ( DM(2,5)*(DM(0,5) + DM(2,5)) - (DM(1,5)*DM(1,5)) );
|
||||
double ddm = (4.*(DM(0,5) + DM(2,5))*( (DM(0,5)*DM(2,5)) - (DM(1,5)*DM(1,5))));
|
||||
double ddmm = (2.*(DM(0,5) + DM(2,5))*( (DM(0,5)*DM(2,5)) - (DM(1,5)*DM(1,5))));
|
||||
|
||||
M(0,0)=((-DM(0,0) + DM(0,2) + DM(0,5)*DM(0,5))*(DM(1,5)*DM(1,5)) + (-2*DM(0,1)*DM(1,5) + DM(0,5)*(DM(0,0) \
|
||||
- (DM(0,5)*DM(0,5)) + (DM(1,5)*DM(1,5))))*DM(2,5) + (DM(0,0) - (DM(0,5)*DM(0,5)))*(DM(2,5)*DM(2,5))) / ddm;
|
||||
M(0,1)=((DM(1,5)*DM(1,5))*(-DM(0,1) + DM(1,2) + DM(0,5)*DM(1,5)) + (DM(0,1)*DM(0,5) - ((DM(0,5)*DM(0,5)) + 2*DM(1,1))*DM(1,5) + \
|
||||
(DM(1,5)*DM(1,5)*DM(1,5)))*DM(2,5) + (DM(0,1) - DM(0,5)*DM(1,5))*(DM(2,5)*DM(2,5))) / ddm;
|
||||
M(0,2)=(-2*DM(1,2)*DM(1,5)*DM(2,5) - DM(0,5)*(DM(2,5)*DM(2,5))*(DM(0,5) + DM(2,5)) + DM(0,2)*dnm + \
|
||||
(DM(1,5)*DM(1,5))*(DM(2,2) + DM(2,5)*(DM(0,5) + DM(2,5))))/ddm;
|
||||
M(0,3)=(DM(1,5)*(DM(1,5)*DM(2,3) - 2*DM(1,3)*DM(2,5)) + DM(0,3)*dnm) / ddm;
|
||||
M(0,4)=(DM(1,5)*(DM(1,5)*DM(2,4) - 2*DM(1,4)*DM(2,5)) + DM(0,4)*dnm) / ddm;
|
||||
M(1,0)=(-(DM(0,2)*DM(0,5)*DM(1,5)) + (2*DM(0,1)*DM(0,5) - DM(0,0)*DM(1,5))*DM(2,5))/ddmm;
|
||||
M(1,1)=(-(DM(0,1)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,2)*DM(1,5)) + 2*DM(1,1)*DM(2,5)))/ddmm;
|
||||
M(1,2)=(-(DM(0,2)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,2)) + 2*DM(1,2)*DM(2,5)))/ddmm;
|
||||
M(1,3)=(-(DM(0,3)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,3)) + 2*DM(1,3)*DM(2,5)))/ddmm;
|
||||
M(1,4)=(-(DM(0,4)*DM(1,5)*DM(2,5)) + DM(0,5)*(-(DM(1,5)*DM(2,4)) + 2*DM(1,4)*DM(2,5)))/ddmm;
|
||||
M(2,0)=(-2*DM(0,1)*DM(0,5)*DM(1,5) + (DM(0,0) + (DM(0,5)*DM(0,5)))*(DM(1,5)*DM(1,5)) + DM(0,5)*(-(DM(0,5)*DM(0,5)) \
|
||||
+ (DM(1,5)*DM(1,5)))*DM(2,5) - (DM(0,5)*DM(0,5))*(DM(2,5)*DM(2,5)) + DM(0,2)*(-(DM(1,5)*DM(1,5)) + DM(0,5)*(DM(0,5) + DM(2,5)))) / ddm;
|
||||
M(2,1)=((DM(0,5)*DM(0,5))*(DM(1,2) - DM(1,5)*DM(2,5)) + (DM(1,5)*DM(1,5))*(DM(0,1) - DM(1,2) + DM(1,5)*DM(2,5)) \
|
||||
+ DM(0,5)*(DM(1,2)*DM(2,5) + DM(1,5)*(-2*DM(1,1) + (DM(1,5)*DM(1,5)) - (DM(2,5)*DM(2,5))))) / ddm;
|
||||
M(2,2)=((DM(0,5)*DM(0,5))*(DM(2,2) - (DM(2,5)*DM(2,5))) + (DM(1,5)*DM(1,5))*(DM(0,2) - DM(2,2) + (DM(2,5)*DM(2,5))) + \
|
||||
DM(0,5)*(-2*DM(1,2)*DM(1,5) + DM(2,5)*((DM(1,5)*DM(1,5)) + DM(2,2) - (DM(2,5)*DM(2,5))))) / ddm;
|
||||
M(2,3)=((DM(1,5)*DM(1,5))*(DM(0,3) - DM(2,3)) + (DM(0,5)*DM(0,5))*DM(2,3) + DM(0,5)*(-2*DM(1,3)*DM(1,5) + DM(2,3)*DM(2,5))) / ddm;
|
||||
M(2,4)=((DM(1,5)*DM(1,5))*(DM(0,4) - DM(2,4)) + (DM(0,5)*DM(0,5))*DM(2,4) + DM(0,5)*(-2*DM(1,4)*DM(1,5) + DM(2,4)*DM(2,5))) / ddm;
|
||||
M(3,0)=DM(0,3);
|
||||
M(3,1)=DM(1,3);
|
||||
M(3,2)=DM(2,3);
|
||||
M(3,3)=DM(3,3);
|
||||
M(3,4)=DM(3,4);
|
||||
M(4,0)=DM(0,4);
|
||||
M(4,1)=DM(1,4);
|
||||
M(4,2)=DM(2,4);
|
||||
M(4,3)=DM(3,4);
|
||||
M(4,4)=DM(4,4);
|
||||
|
||||
if (fabs(cv::determinant(M)) > 1.0e-10) {
|
||||
if (iter < 2) {
|
||||
Mat eVal, eVec;
|
||||
eigenNonSymmetric(M, eVal, eVec);
|
||||
|
||||
@@ -744,7 +759,7 @@ cv::RotatedRect cv::fitEllipseDirect( InputArray _points )
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y);
|
||||
Point2f delta = getOfs(i, eps);
|
||||
const Point2f delta = getOfs(eps);
|
||||
double px = (p.x + delta.x - c.x)*scale, py = (p.y + delta.y - c.y)*scale;
|
||||
|
||||
A.at<double>(i,0) = px*px;
|
||||
|
||||
@@ -385,7 +385,7 @@ __m512d IntegralCalculator < 3 > ::calculate_integral(const __m512i src_longs, c
|
||||
// shifts data left by 3 and 6 qwords(lanes) and gets rolling sum in all lanes
|
||||
// Vertical LANES: 76543210
|
||||
// src_longs : HGFEDCBA
|
||||
// shit3lanes : + EDCBA
|
||||
// shift3lanes : + EDCBA
|
||||
// shift6lanes : + BA
|
||||
// carry_over_idxs : + 65765765 (index position of result from previous iteration)
|
||||
// = integral
|
||||
@@ -418,7 +418,7 @@ __m512d IntegralCalculator < 4 > ::calculate_integral(const __m512i src_longs, c
|
||||
// shifts data left by 3 and 6 qwords(lanes) and gets rolling sum in all lanes
|
||||
// Vertical LANES: 76543210
|
||||
// src_longs : HGFEDCBA
|
||||
// shit4lanes : + DCBA
|
||||
// shift4lanes : + DCBA
|
||||
// carry_over_idxs : + 76547654 (index position of result from previous iteration)
|
||||
// = integral
|
||||
__m512i shifted4lanes = _mm512_maskz_expand_epi64(0xF0, src_longs);
|
||||
@@ -464,6 +464,7 @@ void calculate_integral_avx512(const uchar *src, size_t _srcstep,
|
||||
case 4: {
|
||||
IntegralCalculator< 4 > calculator;
|
||||
calculator.calculate_integral_avx512(src, _srcstep, sum, _sumstep, sqsum, _sqsumstep, width, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1402,10 +1402,13 @@ static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, d
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
|
||||
kercn = ocl::predictOptimalVectorWidth(_src, _dst), ktype = CV_MAKE_TYPE(depth, kercn);
|
||||
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
|
||||
const bool isDisabled = ((thresh_type & THRESH_DRYRUN) != 0);
|
||||
thresh_type &= ~THRESH_DRYRUN;
|
||||
|
||||
if ( !(thresh_type == THRESH_BINARY || thresh_type == THRESH_BINARY_INV || thresh_type == THRESH_TRUNC ||
|
||||
thresh_type == THRESH_TOZERO || thresh_type == THRESH_TOZERO_INV) ||
|
||||
(!doubleSupport && depth == CV_64F))
|
||||
if ( isDisabled ||
|
||||
!(thresh_type == THRESH_BINARY || thresh_type == THRESH_BINARY_INV || thresh_type == THRESH_TRUNC ||
|
||||
thresh_type == THRESH_TOZERO || thresh_type == THRESH_TOZERO_INV) ||
|
||||
(!doubleSupport && depth == CV_64F))
|
||||
return false;
|
||||
|
||||
const char * const thresholdMap[] = { "THRESH_BINARY", "THRESH_BINARY_INV", "THRESH_TRUNC",
|
||||
@@ -1450,10 +1453,14 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
CV_OCL_RUN_(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_threshold(_src, _dst, thresh, maxval, type), thresh)
|
||||
|
||||
const bool isDisabled = ((type & THRESH_DRYRUN) != 0);
|
||||
type &= ~THRESH_DRYRUN;
|
||||
|
||||
Mat src = _src.getMat();
|
||||
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
if (!isDisabled)
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = isDisabled ? cv::Mat() : _dst.getMat();
|
||||
|
||||
int automatic_thresh = (type & ~cv::THRESH_MASK);
|
||||
type &= THRESH_MASK;
|
||||
@@ -1480,6 +1487,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
{
|
||||
int ithresh = cvFloor(thresh);
|
||||
thresh = ithresh;
|
||||
if (isDisabled)
|
||||
return thresh;
|
||||
|
||||
int imaxval = cvRound(maxval);
|
||||
if( type == THRESH_TRUNC )
|
||||
imaxval = ithresh;
|
||||
@@ -1501,7 +1511,6 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
return thresh;
|
||||
}
|
||||
|
||||
|
||||
thresh = ithresh;
|
||||
maxval = imaxval;
|
||||
}
|
||||
@@ -1509,6 +1518,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
{
|
||||
int ithresh = cvFloor(thresh);
|
||||
thresh = ithresh;
|
||||
if (isDisabled)
|
||||
return thresh;
|
||||
|
||||
int imaxval = cvRound(maxval);
|
||||
if( type == THRESH_TRUNC )
|
||||
imaxval = ithresh;
|
||||
@@ -1536,6 +1548,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
{
|
||||
int ithresh = cvFloor(thresh);
|
||||
thresh = ithresh;
|
||||
if (isDisabled)
|
||||
return thresh;
|
||||
|
||||
int imaxval = cvRound(maxval);
|
||||
if (type == THRESH_TRUNC)
|
||||
imaxval = ithresh;
|
||||
@@ -1567,6 +1582,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
||||
else
|
||||
CV_Error( cv::Error::StsUnsupportedFormat, "" );
|
||||
|
||||
if (isDisabled)
|
||||
return thresh;
|
||||
|
||||
parallel_for_(Range(0, dst.rows),
|
||||
ThresholdRunner(src, dst, thresh, maxval, type),
|
||||
dst.total()/(double)(1<<16));
|
||||
|
||||
Reference in New Issue
Block a user