GPU resize with INTER_AREA

This commit is contained in:
Marina Kolpakova
2012-06-06 10:39:42 +00:00
parent bc54195199
commit d192117e86
8 changed files with 273 additions and 28 deletions
+17 -17
View File
@@ -878,8 +878,8 @@ struct VResizeLinear
VecOp vecOp;
int x = vecOp((const uchar**)src, (uchar*)dst, (const uchar*)beta, width);
#if CV_ENABLE_UNROLLED
for( ; x <= width - 4; x += 4 )
#if CV_ENABLE_UNROLLED
for( ; x <= width - 4; x += 4 )
{
WT t0, t1;
t0 = S0[x]*b0 + S1[x]*b1;
@@ -1035,7 +1035,7 @@ struct VResizeLanczos4
CastOp castOp;
VecOp vecOp;
int k, x = vecOp((const uchar**)src, (uchar*)dst, (const uchar*)beta, width);
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; x <= width - 4; x += 4 )
{
WT b = beta[0];
@@ -1130,7 +1130,7 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
if( k0 < ksize )
hresize( srows + k0, rows + k0, ksize - k0, xofs, alpha,
ssize.width, dsize.width, cn, xmin, xmax );
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
}
}
@@ -1163,8 +1163,8 @@ static void resizeAreaFast_( const Mat& src, Mat& dst, const int* ofs, const int
{
const T* S = (const T*)(src.data + src.step*sy0) + xofs[dx];
WT sum = 0;
k=0;
#if CV_ENABLE_UNROLLED
k=0;
#if CV_ENABLE_UNROLLED
for( ; k <= area - 4; k += 4 )
sum += S[ofs[k]] + S[ofs[k+1]] + S[ofs[k+2]] + S[ofs[k+3]];
#endif
@@ -1329,11 +1329,11 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
resizeGeneric_<
HResizeLinear<uchar, int, short,
INTER_RESIZE_COEF_SCALE,
HResizeLinearVec_8u32s>,
HResizeLinearVec_8u32s>,
VResizeLinear<uchar, int, short,
FixedPtCast<int, uchar, INTER_RESIZE_COEF_BITS*2>,
VResizeLinearVec_32s8u> >,
0,
VResizeLinearVec_32s8u> >,
0,
resizeGeneric_<
HResizeLinear<ushort, float, float, 1,
HResizeLinearVec_16u32f>,
@@ -1344,7 +1344,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
HResizeLinearVec_16s32f>,
VResizeLinear<short, float, float, Cast<float, short>,
VResizeLinearVec_32f16s> >,
0,
0,
resizeGeneric_<
HResizeLinear<float, float, float, 1,
HResizeLinearVec_32f>,
@@ -1374,7 +1374,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
HResizeCubic<short, float, float>,
VResizeCubic<short, float, float, Cast<float, short>,
VResizeCubicVec_32f16s> >,
0,
0,
resizeGeneric_<
HResizeCubic<float, float, float>,
VResizeCubic<float, float, float, Cast<float, float>,
@@ -1396,10 +1396,10 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
resizeGeneric_<HResizeLanczos4<ushort, float, float>,
VResizeLanczos4<ushort, float, float, Cast<float, ushort>,
VResizeNoVec> >,
resizeGeneric_<HResizeLanczos4<short, float, float>,
resizeGeneric_<HResizeLanczos4<short, float, float>,
VResizeLanczos4<short, float, float, Cast<float, short>,
VResizeNoVec> >,
0,
0,
resizeGeneric_<HResizeLanczos4<float, float, float>,
VResizeLanczos4<float, float, float, Cast<float, float>,
VResizeNoVec> >,
@@ -1412,8 +1412,8 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
static ResizeAreaFastFunc areafast_tab[] =
{
resizeAreaFast_<uchar, int>, 0,
resizeAreaFast_<ushort, float>,
resizeAreaFast_<short, float>,
resizeAreaFast_<ushort, float>,
resizeAreaFast_<short, float>,
0,
resizeAreaFast_<float, float>,
resizeAreaFast_<double, double>,
@@ -1528,7 +1528,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
assert( k < ssize.width*2 );
xofs[k].di = dx*cn;
xofs[k].si = sx2*cn;
xofs[k++].alpha = (float)((fsx2 - sx2)*scale);
xofs[k++].alpha = (float)(min(fsx2 - sx2, 1.)*scale);
}
}
@@ -3480,7 +3480,7 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
if( !CV_ARE_TYPES_EQ( src, dst ))
CV_Error( CV_StsUnmatchedFormats, "" );
ssize.width = src->cols;
ssize.width = src->cols;
ssize.height = src->rows;
dsize.width = dst->cols;
dsize.height = dst->rows;
+34
View File
@@ -1462,6 +1462,40 @@ TEST(Imgproc_fitLine_Mat_3dC1, regression)
ASSERT_EQ(line2.size(), (size_t)6);
}
TEST(Imgproc_resize_area, regression)
{
static ushort input_data[16 * 16] = {
90, 94, 80, 3, 231, 2, 186, 245, 188, 165, 10, 19, 201, 169, 8, 228,
86, 5, 203, 120, 136, 185, 24, 94, 81, 150, 163, 137, 88, 105, 132, 132,
236, 48, 250, 218, 19, 52, 54, 221, 159, 112, 45, 11, 152, 153, 112, 134,
78, 133, 136, 83, 65, 76, 82, 250, 9, 235, 148, 26, 236, 179, 200, 50,
99, 51, 103, 142, 201, 65, 176, 33, 49, 226, 177, 109, 46, 21, 67, 130,
54, 125, 107, 154, 145, 51, 199, 189, 161, 142, 231, 240, 139, 162, 240, 22,
231, 86, 79, 106, 92, 47, 146, 156, 36, 207, 71, 33, 2, 244, 221, 71,
44, 127, 71, 177, 75, 126, 68, 119, 200, 129, 191, 251, 6, 236, 247, 6,
133, 175, 56, 239, 147, 221, 243, 154, 242, 82, 106, 99, 77, 158, 60, 229,
2, 42, 24, 174, 27, 198, 14, 204, 246, 251, 141, 31, 114, 163, 29, 147,
121, 53, 74, 31, 147, 189, 42, 98, 202, 17, 228, 123, 209, 40, 77, 49,
112, 203, 30, 12, 205, 25, 19, 106, 145, 185, 163, 201, 237, 223, 247, 38,
33, 105, 243, 117, 92, 179, 204, 248, 160, 90, 73, 126, 2, 41, 213, 204,
6, 124, 195, 201, 230, 187, 210, 167, 48, 79, 123, 159, 145, 218, 105, 209,
240, 152, 136, 235, 235, 164, 157, 9, 152, 38, 27, 209, 120, 77, 238, 196,
240, 233, 10, 241, 90, 67, 12, 79, 0, 43, 58, 27, 83, 199, 190, 182};
static ushort expected_data = {
// row 1
120, 100, 151, 101, 103,//?
// row 2
106, 115, 141, 130, suturate_cast<ushort>(0),
// row 3
91, 136, 170, 114, suturate_cast<ushort>(0),
// row 4
104, 122, 131, 147, suturate_cast<ushort>(0),
// row 5
suturate_cast<ushort>(0),suturate_cast<ushort>(0),suturate_cast<ushort>(0),suturate_cast<ushort>(0),suturate_cast<ushort>(0)
};
}
//////////////////////////////////////////////////////////////////////////
TEST(Imgproc_Resize, accuracy) { CV_ResizeTest test; test.safe_run(); }