Added test case of cv::threshold(CV_64F)
This commit is contained in:
parent
e4f207c4b4
commit
6930325847
@ -56,8 +56,8 @@ protected:
|
||||
void prepare_to_validation( int );
|
||||
|
||||
int thresh_type;
|
||||
float thresh_val;
|
||||
float max_val;
|
||||
double thresh_val;
|
||||
double max_val;
|
||||
};
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ void CV_ThreshTest::run_func()
|
||||
|
||||
|
||||
static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
float thresh, float maxval, int thresh_type )
|
||||
double thresh, double maxval, int thresh_type )
|
||||
{
|
||||
int i, j;
|
||||
int depth = _src.depth(), cn = _src.channels();
|
||||
@ -144,7 +144,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
imaxval = cvRound(maxval);
|
||||
}
|
||||
|
||||
assert( depth == CV_8U || depth == CV_16S || depth == CV_32F );
|
||||
assert( depth == CV_8U || depth == CV_16S || depth == CV_32F || depth == CV_64F );
|
||||
|
||||
switch( thresh_type )
|
||||
{
|
||||
@ -165,13 +165,20 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = (short)(src[j] > ithresh ? imaxval : 0);
|
||||
}
|
||||
else
|
||||
else if( depth == CV_32F )
|
||||
{
|
||||
const float* src = _src.ptr<float>(i);
|
||||
float* dst = _dst.ptr<float>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = src[j] > thresh ? maxval : 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* src = _src.ptr<double>(i);
|
||||
double* dst = _dst.ptr<double>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = src[j] > thresh ? maxval : 0.0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CV_THRESH_BINARY_INV:
|
||||
@ -191,13 +198,20 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = (short)(src[j] > ithresh ? 0 : imaxval);
|
||||
}
|
||||
else
|
||||
else if( depth == CV_32F )
|
||||
{
|
||||
const float* src = _src.ptr<float>(i);
|
||||
float* dst = _dst.ptr<float>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = src[j] > thresh ? 0.f : maxval;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* src = _src.ptr<double>(i);
|
||||
double* dst = _dst.ptr<double>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
dst[j] = src[j] > thresh ? 0.0 : maxval;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CV_THRESH_TRUNC:
|
||||
@ -223,7 +237,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = (short)(s > ithresh ? ithresh2 : s);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( depth == CV_32F )
|
||||
{
|
||||
const float* src = _src.ptr<float>(i);
|
||||
float* dst = _dst.ptr<float>(i);
|
||||
@ -233,6 +247,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = s > thresh ? thresh : s;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* src = _src.ptr<double>(i);
|
||||
double* dst = _dst.ptr<double>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
{
|
||||
double s = src[j];
|
||||
dst[j] = s > thresh ? thresh : s;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CV_THRESH_TOZERO:
|
||||
@ -258,7 +282,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = (short)(s > ithresh ? s : 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( depth == CV_32F )
|
||||
{
|
||||
const float* src = _src.ptr<float>(i);
|
||||
float* dst = _dst.ptr<float>(i);
|
||||
@ -268,6 +292,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = s > thresh ? s : 0.f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* src = _src.ptr<double>(i);
|
||||
double* dst = _dst.ptr<double>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
{
|
||||
double s = src[j];
|
||||
dst[j] = s > thresh ? s : 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CV_THRESH_TOZERO_INV:
|
||||
@ -293,7 +327,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = (short)(s > ithresh ? 0 : s);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (depth == CV_32F)
|
||||
{
|
||||
const float* src = _src.ptr<float>(i);
|
||||
float* dst = _dst.ptr<float>(i);
|
||||
@ -303,6 +337,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
|
||||
dst[j] = s > thresh ? 0.f : s;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* src = _src.ptr<double>(i);
|
||||
double* dst = _dst.ptr<double>(i);
|
||||
for( j = 0; j < width_n; j++ )
|
||||
{
|
||||
double s = src[j];
|
||||
dst[j] = s > thresh ? 0.0 : s;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user