mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00
fix the bug when src*2 < dst
This commit is contained in:
parent
2920a8e0ec
commit
79731cb0ff
@ -983,13 +983,25 @@ pyrUp_( const Mat& _src, Mat& _dst, int)
|
||||
row0 = rows[0]; row1 = rows[1]; row2 = rows[2];
|
||||
dsts[0] = dst0; dsts[1] = dst1;
|
||||
|
||||
x = PyrUpVecV<WT, T>(rows, dsts, dsize.width);
|
||||
for( ; x < dsize.width; x++ )
|
||||
if (dst0 != dst1)
|
||||
{
|
||||
T t1 = castOp((row1[x] + row2[x])*4);
|
||||
T t0 = castOp(row0[x] + row1[x]*6 + row2[x]);
|
||||
dst1[x] = t1; dst0[x] = t0;
|
||||
x = PyrUpVecV<WT, T>(rows, dsts, dsize.width);
|
||||
for( ; x < dsize.width; x++ )
|
||||
{
|
||||
T t1 = castOp((row1[x] + row2[x])*4);
|
||||
T t0 = castOp(row0[x] + row1[x]*6 + row2[x]);
|
||||
dst1[x] = t1; dst0[x] = t0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x = 0; x < dsize.width; x++ )
|
||||
{
|
||||
T t0 = castOp(row0[x] + row1[x]*6 + row2[x]);
|
||||
dst0[x] = t0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (dsize.height > ssize.height*2)
|
||||
|
@ -8,12 +8,41 @@ namespace opencv_test { namespace {
|
||||
|
||||
TEST(Imgproc_PyrUp, pyrUp_regression_22184)
|
||||
{
|
||||
Mat src(100, 100, CV_16UC3, Scalar::all(255));
|
||||
Mat dst(100 * 2 + 1, 100 * 2 + 1, CV_16UC3, Scalar::all(0));
|
||||
Mat src(100,100,CV_16UC3,Scalar(255,255,255));
|
||||
Mat dst(100 * 2 + 1, 100 * 2 + 1, CV_16UC3, Scalar(0,0,0));
|
||||
pyrUp(src, dst, Size(dst.cols, dst.rows));
|
||||
double min_val = 0;
|
||||
double min_val;
|
||||
minMaxLoc(dst, &min_val);
|
||||
ASSERT_GT(cvRound(min_val), 0);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
TEST(Imgproc_PyrUp, pyrUp_regression_22193)
|
||||
{
|
||||
Mat src(13, 13,CV_16UC3,Scalar(0,0,0));
|
||||
{
|
||||
int swidth = src.cols;
|
||||
int sheight = src.rows;
|
||||
int cn = src.channels();
|
||||
int count = 0;
|
||||
for (int y = 0; y < sheight; y++)
|
||||
{
|
||||
ushort *src_c = src.ptr<ushort>(y);
|
||||
for (int x = 0; x < swidth * cn; x++)
|
||||
{
|
||||
src_c[x] = (count++) % 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
Mat dst(src.cols * 2 - 1, src.rows * 2 - 1, CV_16UC3, Scalar(0,0,0));
|
||||
pyrUp(src, dst, Size(dst.cols, dst.rows));
|
||||
|
||||
{
|
||||
ushort *dst_c = dst.ptr<ushort>(dst.rows - 1);
|
||||
ASSERT_EQ(dst_c[0], 6);
|
||||
ASSERT_EQ(dst_c[1], 6);
|
||||
ASSERT_EQ(dst_c[2], 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user