mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
set(the_description "Image Processing")
|
||||
ocv_add_dispatched_file(accum SSE4_1 AVX AVX2)
|
||||
ocv_add_dispatched_file(bilateral_filter SSE2 AVX2)
|
||||
ocv_add_dispatched_file(bilateral_filter SSE2 AVX2 AVX512_SKX AVX512_ICL)
|
||||
ocv_add_dispatched_file(box_filter SSE2 SSE4_1 AVX2 AVX512_SKX)
|
||||
ocv_add_dispatched_file(filter SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_hsv SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_rgb SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(color_yuv SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2 AVX512_SKX)
|
||||
ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2 AVX512_SKX AVX512_ICL)
|
||||
ocv_add_dispatched_file(morph SSE2 SSE4_1 AVX2)
|
||||
ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2 AVX512_ICL)
|
||||
ocv_add_dispatched_file(sumpixels SSE2 AVX2 AVX512_SKX)
|
||||
|
||||
@@ -2401,7 +2401,7 @@ structuring element is used. Kernel can be created using #getStructuringElement
|
||||
@param anchor position of the anchor within the element; default value (-1, -1) means that the
|
||||
anchor is at the element center.
|
||||
@param iterations number of times dilation is applied.
|
||||
@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
|
||||
@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
|
||||
@param borderValue border value in case of a constant border
|
||||
@sa erode, morphologyEx, getStructuringElement
|
||||
*/
|
||||
|
||||
@@ -512,6 +512,9 @@ public:
|
||||
int nlanes_2 = 2 * nlanes;
|
||||
int nlanes_3 = 3 * nlanes;
|
||||
int nlanes_4 = 4 * nlanes;
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
#endif
|
||||
for( i = range.start; i < range.end; i++ )
|
||||
{
|
||||
@@ -523,9 +526,6 @@ public:
|
||||
j = 0;
|
||||
const float* sptr_j = sptr;
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
for(; j <= size.width - nlanes_4; j += nlanes_4, sptr_j += nlanes_4, dptr += nlanes_4)
|
||||
{
|
||||
v_float32 v_wsum0 = vx_setzero_f32();
|
||||
@@ -545,45 +545,37 @@ public:
|
||||
{
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
|
||||
//0th
|
||||
v_float32 val0 = vx_load(ksptr);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), v_not_nan(rval0)), knan0);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
|
||||
//1st
|
||||
v_float32 val1 = vx_load(ksptr + nlanes);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), v_not_nan(rval1)), knan1);
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
|
||||
//2nd
|
||||
v_float32 val2 = vx_load(ksptr + nlanes_2);
|
||||
v_float32 knan2 = v_not_nan(val2);
|
||||
v_float32 alpha2 = v_and(v_and(v_mul(v_absdiff(val2, rval2), sindex), v_not_nan(rval2)), knan2);
|
||||
v_int32 idx2 = v_min(v_trunc(alpha2), vx_setall_s32(kExpNumBins));
|
||||
alpha2 = v_sub(alpha2, v_cvt_f32(idx2));
|
||||
v_float32 w2 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx2), alpha2, v_mul(v_lut(this->expLUT, idx2), v_sub(v_one, alpha2)))), knan2);
|
||||
v_wsum2 = v_add(v_wsum2, w2);
|
||||
v_sum2 = v_muladd(v_and(val2, knan2), w2, v_sum2);
|
||||
|
||||
//3rd
|
||||
v_float32 val3 = vx_load(ksptr + nlanes_3);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 knan2 = v_not_nan(val2);
|
||||
v_float32 knan3 = v_not_nan(val3);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), v_not_nan(rval0)), knan0);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), v_not_nan(rval1)), knan1);
|
||||
v_float32 alpha2 = v_and(v_and(v_mul(v_absdiff(val2, rval2), sindex), v_not_nan(rval2)), knan2);
|
||||
v_float32 alpha3 = v_and(v_and(v_mul(v_absdiff(val3, rval3), sindex), v_not_nan(rval3)), knan3);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx2 = v_min(v_trunc(alpha2), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx3 = v_min(v_trunc(alpha3), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
alpha2 = v_sub(alpha2, v_cvt_f32(idx2));
|
||||
alpha3 = v_sub(alpha3, v_cvt_f32(idx3));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_float32 w2 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx2), alpha2, v_mul(v_lut(this->expLUT, idx2), v_sub(v_one, alpha2)))), knan2);
|
||||
v_float32 w3 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx3), alpha3, v_mul(v_lut(this->expLUT, idx3), v_sub(v_one, alpha3)))), knan3);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_wsum2 = v_add(v_wsum2, w2);
|
||||
v_wsum3 = v_add(v_wsum3, w3);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
v_sum2 = v_muladd(v_and(val2, knan2), w2, v_sum2);
|
||||
v_sum3 = v_muladd(v_and(val3, knan3), w3, v_sum3);
|
||||
}
|
||||
v_store(dptr , v_div(v_add(v_sum0, v_and(rval0, v_not_nan(rval0))), v_add(v_wsum0, v_and(v_one, v_not_nan(rval0)))));
|
||||
@@ -607,24 +599,21 @@ public:
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
|
||||
//0th
|
||||
v_float32 val0 = vx_load(ksptr);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), rval0_not_nan), knan0);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
|
||||
//1st
|
||||
v_float32 val1 = vx_load(ksptr + nlanes);
|
||||
v_float32 knan0 = v_not_nan(val0);
|
||||
v_float32 knan1 = v_not_nan(val1);
|
||||
v_float32 alpha0 = v_and(v_and(v_mul(v_absdiff(val0, rval0), sindex), rval0_not_nan), knan0);
|
||||
v_float32 alpha1 = v_and(v_and(v_mul(v_absdiff(val1, rval1), sindex), rval1_not_nan), knan1);
|
||||
v_int32 idx0 = v_min(v_trunc(alpha0), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha0 = v_sub(alpha0, v_cvt_f32(idx0));
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w0 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx0), alpha0, v_mul(v_lut(this->expLUT, idx0), v_sub(v_one, alpha0)))), knan0);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum0 = v_add(v_wsum0, w0);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum0 = v_muladd(v_and(val0, knan0), w0, v_sum0);
|
||||
v_sum1 = v_muladd(v_and(val1, knan1), w1, v_sum1);
|
||||
}
|
||||
v_store(dptr, v_div(v_add(v_sum0, v_and(rval0, rval0_not_nan)), v_add(v_wsum0, v_and(v_one, rval0_not_nan))));
|
||||
@@ -660,42 +649,61 @@ public:
|
||||
j = 0;
|
||||
const float* sptr_j = sptr;
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
v_float32 v_one = vx_setall_f32(1.f);
|
||||
v_float32 sindex = vx_setall_f32(scale_index);
|
||||
|
||||
for (; j <= size.width - nlanes; j += nlanes, sptr_j += nlanes_3, dptr += nlanes_3)
|
||||
for (; j <= size.width - nlanes_2; j += nlanes_2, sptr_j += (nlanes_3*2), dptr += (nlanes_3*2))
|
||||
{
|
||||
v_float32 kb, kg, kr, kb1, kg1, kr1;
|
||||
v_float32 rb, rg, rr, rb1, rg1, rr1;
|
||||
const float* rsptr = sptr_j;
|
||||
v_float32 v_wsum = vx_setzero_f32();
|
||||
v_float32 v_sum_b = vx_setzero_f32();
|
||||
v_float32 v_sum_g = vx_setzero_f32();
|
||||
v_float32 v_sum_r = vx_setzero_f32();
|
||||
v_float32 v_wsum1 = vx_setzero_f32();
|
||||
v_float32 v_sum_b1 = vx_setzero_f32();
|
||||
v_float32 v_sum_g1 = vx_setzero_f32();
|
||||
v_float32 v_sum_r1 = vx_setzero_f32();
|
||||
v_load_deinterleave(rsptr, rb, rg, rr);
|
||||
v_load_deinterleave(rsptr + nlanes_3, rb1, rg1, rr1);
|
||||
|
||||
for (k = 0; k < maxk; k++)
|
||||
{
|
||||
const float* ksptr = sptr_j + space_ofs[k];
|
||||
v_float32 kweight = vx_setall_f32(space_weight[k]);
|
||||
|
||||
v_float32 kb, kg, kr, rb, rg, rr;
|
||||
v_load_deinterleave(ksptr, kb, kg, kr);
|
||||
v_load_deinterleave(rsptr, rb, rg, rr);
|
||||
v_load_deinterleave(ksptr + nlanes_3, kb1, kg1, kr1);
|
||||
|
||||
v_float32 knan = v_and(v_and(v_not_nan(kb), v_not_nan(kg)), v_not_nan(kr));
|
||||
v_float32 knan1 = v_and(v_and(v_not_nan(kb1), v_not_nan(kg1)), v_not_nan(kr1));
|
||||
v_float32 alpha = v_and(v_and(v_and(v_and(v_mul(v_add(v_add(v_absdiff(kb, rb), v_absdiff(kg, rg)), v_absdiff(kr, rr)), sindex), v_not_nan(rb)), v_not_nan(rg)), v_not_nan(rr)), knan);
|
||||
v_float32 alpha1 = v_and(v_and(v_and(v_and(v_mul(v_add(v_add(v_absdiff(kb1, rb1), v_absdiff(kg1, rg1)), v_absdiff(kr1, rr1)), sindex), v_not_nan(rb1)), v_not_nan(rg1)), v_not_nan(rr1)), knan1);
|
||||
v_int32 idx = v_min(v_trunc(alpha), vx_setall_s32(kExpNumBins));
|
||||
v_int32 idx1 = v_min(v_trunc(alpha1), vx_setall_s32(kExpNumBins));
|
||||
alpha = v_sub(alpha, v_cvt_f32(idx));
|
||||
|
||||
alpha1 = v_sub(alpha1, v_cvt_f32(idx1));
|
||||
v_float32 w = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx), alpha, v_mul(v_lut(this->expLUT, idx), v_sub(v_one, alpha)))), knan);
|
||||
v_float32 w1 = v_and(v_mul(kweight, v_muladd(v_lut(this->expLUT + 1, idx1), alpha1, v_mul(v_lut(this->expLUT, idx1), v_sub(v_one, alpha1)))), knan1);
|
||||
v_wsum = v_add(v_wsum, w);
|
||||
v_wsum1 = v_add(v_wsum1, w1);
|
||||
v_sum_b = v_muladd(v_and(kb, knan), w, v_sum_b);
|
||||
v_sum_g = v_muladd(v_and(kg, knan), w, v_sum_g);
|
||||
v_sum_r = v_muladd(v_and(kr, knan), w, v_sum_r);
|
||||
v_sum_b1 = v_muladd(v_and(kb1, knan1), w1, v_sum_b1);
|
||||
v_sum_g1 = v_muladd(v_and(kg1, knan1), w1, v_sum_g1);
|
||||
v_sum_r1 = v_muladd(v_and(kr1, knan1), w1, v_sum_r1);
|
||||
}
|
||||
|
||||
v_float32 b, g, r;
|
||||
v_float32 b1, g1, r1;
|
||||
v_load_deinterleave(sptr_j, b, g, r);
|
||||
v_load_deinterleave(sptr_j + nlanes_3, b1, g1, r1);
|
||||
v_float32 mask = v_and(v_and(v_not_nan(b), v_not_nan(g)), v_not_nan(r));
|
||||
v_float32 mask1 = v_and(v_and(v_not_nan(b1), v_not_nan(g1)), v_not_nan(r1));
|
||||
v_float32 w = v_div(v_one, v_add(v_wsum, v_and(v_one, mask)));
|
||||
v_float32 w1 = v_div(v_one, v_add(v_wsum1, v_and(v_one, mask1)));
|
||||
v_store_interleave(dptr, v_mul(v_add(v_sum_b, v_and(b, mask)), w), v_mul(v_add(v_sum_g, v_and(g, mask)), w), v_mul(v_add(v_sum_r, v_and(r, mask)), w));
|
||||
v_store_interleave(dptr + nlanes_3, v_mul(v_add(v_sum_b1, v_and(b1, mask1)), w1), v_mul(v_add(v_sum_g1, v_and(g1, mask1)), w1), v_mul(v_add(v_sum_r1, v_and(r1, mask1)), w1));
|
||||
}
|
||||
#endif
|
||||
for (; j < size.width; j++, sptr_j += 3)
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace cv {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
@@ -1513,7 +1514,7 @@ void BlockSum(const Mat& _src, Mat& _dst, Size ksize, Point anchor, const Size &
|
||||
borderLeft*sizeof(T), inplace);
|
||||
}
|
||||
else
|
||||
ref = (const T*)(src+(srcY-roi.y)*srcStep);
|
||||
ref = (const T*)(src+(srcY-roi.y)*(ptrdiff_t)srcStep);
|
||||
|
||||
S = ref;
|
||||
R = (T*)alignPtr(border, VEC_ALIGN);
|
||||
|
||||
@@ -598,7 +598,7 @@ static bool ipp_cornerHarris( Mat &src, Mat &dst, int blockSize, int ksize, doub
|
||||
scale *= 2.0;
|
||||
if (depth == CV_8U)
|
||||
scale *= 255.0;
|
||||
scale = std::pow(scale, -4.0);
|
||||
scale = std::pow(scale, -4);
|
||||
|
||||
if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0)
|
||||
{
|
||||
|
||||
@@ -96,7 +96,11 @@ void cv::cornerSubPix( InputArray _image, InputOutputArray _corners,
|
||||
for( int pt_i = 0; pt_i < count; pt_i++ )
|
||||
{
|
||||
Point2f cT = corners[pt_i], cI = cT;
|
||||
CV_Assert( Rect(0, 0, src.cols, src.rows).contains(cT) );
|
||||
if (!Rect(0, 0, src.cols, src.rows).contains(cT))
|
||||
{
|
||||
CV_Error(Error::StsOutOfRange,
|
||||
"cornerSubPix: initial corner is outside the image.");
|
||||
}
|
||||
int iter = 0;
|
||||
double err = 0;
|
||||
|
||||
|
||||
@@ -715,15 +715,30 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
ddepth = sdepth;
|
||||
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
Mat kernel;
|
||||
|
||||
if( ksize == 1 || ksize == 3 )
|
||||
{
|
||||
float K[2][9] =
|
||||
static const double K[2][9] =
|
||||
{
|
||||
{ 0, 1, 0, 1, -4, 1, 0, 1, 0 },
|
||||
{ 2, 0, 2, 0, -8, 0, 2, 0, 2 }
|
||||
};
|
||||
|
||||
Mat kernel(3, 3, CV_32F, K[ksize == 3]);
|
||||
kernel.create(3, 3, ktype);
|
||||
if (ktype == CV_32F)
|
||||
{
|
||||
float* kptr = kernel.ptr<float>();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
kptr[i] = static_cast<float>(K[ksize == 3][i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
double* kptr = kernel.ptr<double>();
|
||||
for (int i = 0; i < 9; ++i)
|
||||
kptr[i] = K[ksize == 3][i];
|
||||
}
|
||||
if( scale != 1 )
|
||||
kernel *= scale;
|
||||
|
||||
@@ -735,20 +750,10 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
|
||||
if( ksize == 1 || ksize == 3 )
|
||||
{
|
||||
float K[2][9] =
|
||||
{
|
||||
{ 0, 1, 0, 1, -4, 1, 0, 1, 0 },
|
||||
{ 2, 0, 2, 0, -8, 0, 2, 0, 2 }
|
||||
};
|
||||
Mat kernel(3, 3, CV_32F, K[ksize == 3]);
|
||||
if( scale != 1 )
|
||||
kernel *= scale;
|
||||
|
||||
filter2D( _src, _dst, ddepth, kernel, Point(-1, -1), delta, borderType );
|
||||
}
|
||||
else
|
||||
{
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
int wdepth = sdepth == CV_8U && ksize <= 5 ? CV_16S : sdepth <= CV_32F ? CV_32F : CV_64F;
|
||||
int wtype = CV_MAKETYPE(wdepth, cn);
|
||||
Mat kd, ks;
|
||||
|
||||
@@ -138,7 +138,7 @@ inline double get_limit(cv::Point2d p, int row, double slope) {
|
||||
inline double log_gamma_windschitl(const double& x)
|
||||
{
|
||||
return 0.918938533204673 + (x-0.5)*log(x) - x
|
||||
+ 0.5*x*log(x*sinh(1/x) + 1/(810.0*pow(x, 6.0)));
|
||||
+ 0.5*x*log(x*sinh(1/x) + 1/(810.0*std::pow(x, 6)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ inline double log_gamma_lanczos(const double& x)
|
||||
for(int n = 0; n < 7; ++n)
|
||||
{
|
||||
a -= log(x + double(n));
|
||||
b += q[n] * pow(x, double(n));
|
||||
b += q[n] * std::pow(x, n);
|
||||
}
|
||||
return a + log(b);
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ double LineSegmentDetectorImpl::nfa(const int& n, const int& k, const double& p)
|
||||
bin_tail += term;
|
||||
if(bin_term < 1)
|
||||
{
|
||||
double err = term * ((1 - pow(mult_term, double(n-i+1))) / (1 - mult_term) - 1);
|
||||
double err = term * ((1 - std::pow(mult_term, double(n-i+1))) / (1 - mult_term) - 1);
|
||||
if(err < tolerance * fabs(-log10(bin_tail) - LOG_NT) * bin_tail) break;
|
||||
}
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
||||
uchar* dst = _dst.ptr();
|
||||
int src_step = (int)_src.step, dst_step = (int)_dst.step;
|
||||
int cn = _src.channels();
|
||||
const uchar* src_max = src + size.height*src_step;
|
||||
const uchar* src_max = src + (size_t)size.height*src_step;
|
||||
CV_Assert(cn > 0 && cn <= 4);
|
||||
|
||||
#define UPDATE_ACC01( pix, cn, op ) \
|
||||
@@ -381,8 +381,8 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
||||
|
||||
if( x % 2 != 0 )
|
||||
{
|
||||
src_bottom = src_top += src_step*(size.height-1);
|
||||
dst_cur += dst_step*(size.height-1);
|
||||
src_bottom = src_top += (size_t)src_step*(size.height-1);
|
||||
dst_cur += (size_t)dst_step*(size.height-1);
|
||||
src_step1 = -src_step1;
|
||||
dst_step1 = -dst_step1;
|
||||
}
|
||||
@@ -663,9 +663,9 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
|
||||
size.width *= cn;
|
||||
for( i = 0; i < size.height; i++, dst += dstep )
|
||||
{
|
||||
const T* row0 = src + std::max(i - 1, 0)*sstep;
|
||||
const T* row1 = src + i*sstep;
|
||||
const T* row2 = src + std::min(i + 1, size.height-1)*sstep;
|
||||
const T* row0 = src + (size_t)std::max(i - 1, 0)*sstep;
|
||||
const T* row1 = src + (size_t)i*sstep;
|
||||
const T* row2 = src + (size_t)std::min(i + 1, size.height-1)*sstep;
|
||||
int limit = cn;
|
||||
|
||||
for(j = 0;; )
|
||||
@@ -750,11 +750,11 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
|
||||
for( i = 0; i < size.height; i++, dst += dstep )
|
||||
{
|
||||
const T* row[5];
|
||||
row[0] = src + std::max(i - 2, 0)*sstep;
|
||||
row[1] = src + std::max(i - 1, 0)*sstep;
|
||||
row[2] = src + i*sstep;
|
||||
row[3] = src + std::min(i + 1, size.height-1)*sstep;
|
||||
row[4] = src + std::min(i + 2, size.height-1)*sstep;
|
||||
row[0] = src + (size_t)std::max(i - 2, 0)*sstep;
|
||||
row[1] = src + (size_t)std::max(i - 1, 0)*sstep;
|
||||
row[2] = src + (size_t)i*sstep;
|
||||
row[3] = src + (size_t)std::min(i + 1, size.height-1)*sstep;
|
||||
row[4] = src + (size_t)std::min(i + 2, size.height-1)*sstep;
|
||||
int limit = cn*2;
|
||||
|
||||
for(j = 0;; )
|
||||
|
||||
@@ -619,7 +619,7 @@ void inline smooth3N121Impl(const ET* src, int cn, ET *dst, int ito, int idst,
|
||||
int v = idst - 1;
|
||||
int len = (width - offset) * cn;
|
||||
int x = offset * cn;
|
||||
int maxRow = min((ito - vOffset),height-2);
|
||||
int maxRow = min((ito - vOffset),height-vOffset);
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
VFT v_8 = vx_setall((WET)8);
|
||||
const int VECSZ = VTraits<VET>::vlanes();
|
||||
@@ -708,11 +708,11 @@ template <typename ET, typename FT, typename WET, typename VFT, typename VET>
|
||||
void inline smooth5N14641Impl(const ET* src, int cn, ET* dst, int ito, int idst, int width, int height, size_t src_stride, size_t dst_stride)
|
||||
{
|
||||
int offset = 2;
|
||||
int vOffset = 3;
|
||||
int vOffset = 4;
|
||||
int v = idst - 2;
|
||||
int len = (width - offset) * cn;
|
||||
int x = offset * cn;
|
||||
int maxRow = min((ito - vOffset),height-4);
|
||||
int maxRow = min((ito - vOffset),height-vOffset);
|
||||
|
||||
#if (CV_SIMD || CV_SIMD_SCALABLE)
|
||||
VFT v_6 = vx_setall((WET)6);
|
||||
|
||||
@@ -585,6 +585,19 @@ TEST(Imgproc_minAreaRect, reproducer_19769)
|
||||
EXPECT_TRUE(checkMinAreaRect(rr, contour)) << rr.center << " " << rr.size << " " << rr.angle;
|
||||
}
|
||||
|
||||
TEST(Imgproc_minAreaRect, roundtrip_accuracy)
|
||||
{
|
||||
RotatedRect rect(Point2f(12.f, 56.f), Size2f(10.f, 25.f), -45.f);
|
||||
std::vector<Point2f> points;
|
||||
rect.points(points);
|
||||
RotatedRect rect_out = minAreaRect(points);
|
||||
EXPECT_LT(std::abs(rect.center.x - rect_out.center.x), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.center.y - rect_out.center.y), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.size.width - rect_out.size.width), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.size.height - rect_out.size.height), 1e-5);
|
||||
EXPECT_LT(std::abs(rect.angle - rect_out.angle), 1e-5);
|
||||
}
|
||||
|
||||
TEST(Imgproc_minEnclosingTriangle, regression_17585)
|
||||
{
|
||||
const int N = 3;
|
||||
|
||||
@@ -557,9 +557,9 @@ TEST(Drawing, _914)
|
||||
line(img, Point(-5, 20), Point(260, 20), Scalar(0), 2, 4);
|
||||
line(img, Point(10, 0), Point(10, 255), Scalar(0), 2, 4);
|
||||
|
||||
double x0 = 0.0/pow(2.0, -2.0);
|
||||
double x1 = 255.0/pow(2.0, -2.0);
|
||||
double y = 30.5/pow(2.0, -2.0);
|
||||
double x0 = 0.0/std::pow(2, -2);
|
||||
double x1 = 255.0/std::pow(2, -2);
|
||||
double y = 30.5/std::pow(2, -2);
|
||||
|
||||
line(img, Point(int(x0), int(y)), Point(int(x1), int(y)), Scalar(0), 2, 4, 2);
|
||||
|
||||
|
||||
@@ -974,6 +974,19 @@ TEST(Imgproc_MedianBlur, hires_regression_13409)
|
||||
ASSERT_EQ(0.0, cvtest::norm(dst_hires(Rect(516, 516, 1016, 1016)), dst_ref(Rect(4, 4, 1016, 1016)), NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Imgproc_MedianBlur, regression_28385)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_MEMORY_6GB);
|
||||
|
||||
Mat out;
|
||||
// create a matrix larger than 2^31 to check for signed 32 bit integer overflow
|
||||
Mat img(50000, 50000, CV_8U);
|
||||
Mat sub = img(Rect(0, 0, 100, 50000));
|
||||
// this crashes in case of overflow because of out-of-bounds memory access
|
||||
medianBlur(sub, out, 3);
|
||||
ASSERT_EQ(out.size(), Size(100, 50000));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Sobel, s16_regression_13506)
|
||||
{
|
||||
Mat src = (Mat_<short>(8, 16) << 127, 138, 130, 102, 118, 97, 76, 84, 124, 90, 146, 63, 130, 87, 212, 85,
|
||||
|
||||
Reference in New Issue
Block a user