1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-07-18 19:15:14 +00:00
15 changed files with 437 additions and 394 deletions
+22 -4
View File
@@ -1142,6 +1142,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
const int N = 256;
int i, j, h[N] = {0};
#if CV_ENABLE_UNROLLED
int h_unrolled[3][N] = {};
#endif
for( i = 0; i < size.height; i++ )
{
const uchar* src = _src.ptr() + step*i;
@@ -1150,9 +1153,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
for( ; j <= size.width - 4; j += 4 )
{
int v0 = src[j], v1 = src[j+1];
h[v0]++; h[v1]++;
h[v0]++; h_unrolled[0][v1]++;
v0 = src[j+2]; v1 = src[j+3];
h[v0]++; h[v1]++;
h_unrolled[1][v0]++; h_unrolled[2][v1]++;
}
#endif
for( ; j < size.width; j++ )
@@ -1161,7 +1164,12 @@ getThreshVal_Otsu_8u( const Mat& _src )
double mu = 0, scale = 1./(size.width*size.height);
for( i = 0; i < N; i++ )
{
#if CV_ENABLE_UNROLLED
h[i] += h_unrolled[0][i] + h_unrolled[1][i] + h_unrolled[2][i];
#endif
mu += i*(double)h[i];
}
mu *= scale;
double mu1 = 0, q1 = 0;
@@ -1206,6 +1214,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
const int N = 256;
int i, j, h[N] = {0};
#if CV_ENABLE_UNROLLED
int h_unrolled[3][N] = {};
#endif
for( i = 0; i < size.height; i++ )
{
const uchar* src = _src.ptr() + step*i;
@@ -1214,9 +1225,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
for( ; j <= size.width - 4; j += 4 )
{
int v0 = src[j], v1 = src[j+1];
h[v0]++; h[v1]++;
h[v0]++; h_unrolled[0][v1]++;
v0 = src[j+2]; v1 = src[j+3];
h[v0]++; h[v1]++;
h_unrolled[1][v0]++; h_unrolled[2][v1]++;
}
#endif
for( ; j < size.width; j++ )
@@ -1227,6 +1238,13 @@ getThreshVal_Triangle_8u( const Mat& _src )
int temp;
bool isflipped = false;
#if CV_ENABLE_UNROLLED
for( i = 0; i < N; i++ )
{
h[i] += h_unrolled[0][i] + h_unrolled[1][i] + h_unrolled[2][i];
}
#endif
for( i = 0; i < N; i++ )
{
if( h[i] > 0 )