1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Fix bug in distanceTransform (#12278)

* fix 12218

* Update test_distancetransform.cpp

marked the test as "BIGDATA_TEST" in order to skip it on low-mem platforms

* modify test

* use a smaller image in the test

* fix test code
This commit is contained in:
yuki takehara
2018-09-03 23:18:10 +09:00
committed by Vadim Pisarevsky
parent c7cf8fb35c
commit cb7ee27cd9
2 changed files with 49 additions and 26 deletions
@@ -283,4 +283,23 @@ void CV_DisTransTest::prepare_to_validation( int /*test_case_idx*/ )
TEST(Imgproc_DistanceTransform, accuracy) { CV_DisTransTest test; test.safe_run(); }
BIGDATA_TEST(Imgproc_DistanceTransform, large_image_12218)
{
const int lls_maxcnt = 79992000; // labels's maximum count
const int lls_mincnt = 1; // labels's minimum count
int i, j, nz;
Mat src(8000, 20000, CV_8UC1), dst, labels;
for( i = 0; i < src.rows; i++ )
for( j = 0; j < src.cols; j++ )
src.at<uchar>(i, j) = (j > (src.cols / 2)) ? 0 : 255;
distanceTransform(src, dst, labels, cv::DIST_L2, cv::DIST_MASK_3, DIST_LABEL_PIXEL);
double scale = (double)lls_mincnt / (double)lls_maxcnt;
labels.convertTo(labels, CV_32SC1, scale);
Size size = labels.size();
nz = cv::countNonZero(labels);
EXPECT_EQ(nz, (size.height*size.width / 2));
}
}} // namespace