Commit f5dff872 authored by Rostislav Vasilikhin's avatar Rostislav Vasilikhin

CV_ColorCvtBaseTest: added methods for 8u implementations

parent f0ef7bd1
...@@ -68,6 +68,14 @@ protected: ...@@ -68,6 +68,14 @@ protected:
// called from default implementation of convert_backward // called from default implementation of convert_backward
virtual void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); virtual void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n );
// called from default implementation of convert_backward
// for cases of bit-exact functions
virtual int convert_row_abc2bgr_8u_c3( const uchar* src_row, uchar* dst_row, int n );
// called from default implementation of convert_forward
// for cases of bit-exact functions
virtual int convert_row_bgr2abc_8u_c3(const uchar *src_row, uchar *dst_row, int n );
const char* fwd_code_str; const char* fwd_code_str;
const char* inv_code_str; const char* inv_code_str;
...@@ -226,19 +234,23 @@ void CV_ColorCvtBaseTest::convert_forward( const Mat& src, Mat& dst ) ...@@ -226,19 +234,23 @@ void CV_ColorCvtBaseTest::convert_forward( const Mat& src, Mat& dst )
const uchar* src_row = src.ptr(i); const uchar* src_row = src.ptr(i);
uchar* dst_row = dst.ptr(i); uchar* dst_row = dst.ptr(i);
for( j = 0; j < cols; j++ ) int processed = convert_row_bgr2abc_8u_c3( src_row, dst_row, cols );
if(processed != cols)
{ {
src_buf[j*3] = src_row[j*cn + blue_idx]*c8u; for( j = 0; j < cols; j++ )
src_buf[j*3+1] = src_row[j*cn + 1]*c8u; {
src_buf[j*3+2] = src_row[j*cn + (blue_idx^2)]*c8u; src_buf[j*3] = src_row[j*cn + blue_idx]*c8u;
} src_buf[j*3+1] = src_row[j*cn + 1]*c8u;
src_buf[j*3+2] = src_row[j*cn + (blue_idx^2)]*c8u;
}
convert_row_bgr2abc_32f_c3( src_buf, dst_buf, cols ); convert_row_bgr2abc_32f_c3( src_buf, dst_buf, cols );
for( j = 0; j < dst_cols_n; j++ ) for( j = 0; j < dst_cols_n; j++ )
{ {
int t = cvRound( dst_buf[j] ); int t = cvRound( dst_buf[j] );
dst_row[j] = saturate_cast<uchar>(t); dst_row[j] = saturate_cast<uchar>(t);
}
} }
} }
break; break;
...@@ -297,6 +309,19 @@ void CV_ColorCvtBaseTest::convert_row_abc2bgr_32f_c3( const float* /*src_row*/, ...@@ -297,6 +309,19 @@ void CV_ColorCvtBaseTest::convert_row_abc2bgr_32f_c3( const float* /*src_row*/,
} }
int CV_ColorCvtBaseTest::convert_row_abc2bgr_8u_c3(const uchar * /*src_row*/,
uchar * /*dst_row*/, int /*n*/ )
{
return 0;
}
int CV_ColorCvtBaseTest::convert_row_bgr2abc_8u_c3( const uchar* /*src_row*/,
uchar* /*dst_row*/, int /*n*/ )
{
return 0;
}
void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat& dst2 ) void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat& dst2 )
{ {
if( custom_inv_transform ) if( custom_inv_transform )
...@@ -321,21 +346,26 @@ void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat& ...@@ -321,21 +346,26 @@ void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat&
const uchar* src_row = dst.ptr(i); const uchar* src_row = dst.ptr(i);
uchar* dst_row = dst2.ptr(i); uchar* dst_row = dst2.ptr(i);
for( j = 0; j < cols_n; j++ ) int processed = convert_row_abc2bgr_8u_c3(src_row, dst_row, dst_cols);
src_buf[j] = src_row[j];
convert_row_abc2bgr_32f_c3( src_buf, dst_buf, dst_cols ); if(processed != dst_cols)
for( j = 0; j < dst_cols; j++ )
{ {
int b = cvRound( dst_buf[j*3]*255. ); for( j = 0; j < cols_n; j++ )
int g = cvRound( dst_buf[j*3+1]*255. ); src_buf[j] = src_row[j];
int r = cvRound( dst_buf[j*3+2]*255. );
dst_row[j*cn + blue_idx] = saturate_cast<uchar>(b); convert_row_abc2bgr_32f_c3( src_buf, dst_buf, dst_cols );
dst_row[j*cn + 1] = saturate_cast<uchar>(g);
dst_row[j*cn + (blue_idx^2)] = saturate_cast<uchar>(r); for( j = 0; j < dst_cols; j++ )
if( cn == 4 ) {
dst_row[j*cn + 3] = 255; int b = cvRound( dst_buf[j*3]*255. );
int g = cvRound( dst_buf[j*3+1]*255. );
int r = cvRound( dst_buf[j*3+2]*255. );
dst_row[j*cn + blue_idx] = saturate_cast<uchar>(b);
dst_row[j*cn + 1] = saturate_cast<uchar>(g);
dst_row[j*cn + (blue_idx^2)] = saturate_cast<uchar>(r);
if( cn == 4 )
dst_row[j*cn + 3] = 255;
}
} }
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment