Skip to content

Commit

Permalink
Update test_radon_transform.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sturkmen72 committed Oct 22, 2024
1 parent 787632a commit 370eb5f
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions modules/ximgproc/test/test_radon_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,36 @@ namespace opencv_test {namespace {
TEST(RadonTransformTest, output_size)
{
Mat src(Size(256, 256), CV_8U, Scalar(0));
circle(src, Point(128, 128), 64, Scalar(255), FILLED);
Mat radon;
cv::ximgproc::RadonTransform(src, radon);

ximgproc::RadonTransform(src, radon);
EXPECT_EQ(363, radon.rows);
EXPECT_EQ(180, radon.cols);

cv::ximgproc::RadonTransform(src, radon, 1, 0, 180, true);

ximgproc::RadonTransform(src, radon, 1, 0, 180, true);
EXPECT_EQ(256, radon.rows);
EXPECT_EQ(180, radon.cols);
}

TEST(RadonTransformTest, output_type)
{
Mat src_int(Size(256, 256), CV_8U, Scalar(0));
circle(src_int, Point(128, 128), 64, Scalar(255), FILLED);
Mat src_float(Size(256, 256), CV_32FC1, Scalar(0));
Mat src_double(Size(256, 256), CV_64FC1, Scalar(0));
Mat radon, radon_norm;
cv::ximgproc::RadonTransform(src_int, radon);
cv::ximgproc::RadonTransform(src_int, radon_norm, 1, 0, 180, false, true);

ximgproc::RadonTransform(src_int, radon);
ximgproc::RadonTransform(src_int, radon_norm, 1, 0, 180, false, true);
EXPECT_EQ(CV_32SC1, radon.type());
EXPECT_EQ(CV_8U, radon_norm.type());

Mat src_float(Size(256, 256), CV_32FC1, Scalar(0));
Mat src_double(Size(256, 256), CV_32FC1, Scalar(0));
cv::ximgproc::RadonTransform(src_float, radon);
cv::ximgproc::RadonTransform(src_float, radon_norm, 1, 0, 180, false, true);
ximgproc::RadonTransform(src_float, radon);
ximgproc::RadonTransform(src_float, radon_norm, 1, 0, 180, false, true);
EXPECT_EQ(CV_64FC1, radon.type());
EXPECT_EQ(CV_8U, radon_norm.type());
cv::ximgproc::RadonTransform(src_double, radon);

ximgproc::RadonTransform(src_double, radon);
ximgproc::RadonTransform(src_double, radon_norm, 1, 0, 180, false, true);
EXPECT_EQ(CV_64FC1, radon.type());
EXPECT_EQ(CV_8U, radon_norm.type());
}
Expand All @@ -49,31 +48,29 @@ TEST(RadonTransformTest, accuracy_by_pixel)
Mat src(Size(256, 256), CV_8U, Scalar(0));
circle(src, Point(128, 128), 64, Scalar(255), FILLED);
Mat radon;
cv::ximgproc::RadonTransform(src, radon);

ximgproc::RadonTransform(src, radon);
ASSERT_EQ(CV_32SC1, radon.type());

EXPECT_EQ(0, radon.at<int>(0, 0));

EXPECT_LT(18000, radon.at<int>(128, 128));
EXPECT_GT(19000, radon.at<int>(128, 128));
}

TEST(RadonTransformTest, accuracy_uchar)
{
Mat src(Size(10, 10), CV_8UC1, Scalar(1));
cv::Mat radon;
ximgproc::RadonTransform(src, radon, 45, 0, 180, false, false);
Mat radon;

ximgproc::RadonTransform(src, radon, 45, 0, 180, false, false);
EXPECT_EQ(100, sum(radon.col(0))[0]);
}

TEST(RadonTransformTest, accuracy_float)
{
Mat src(Size(10, 10), CV_32FC1, Scalar(1.1));
cv::Mat radon;
ximgproc::RadonTransform(src, radon, 45, 0, 180, false, false);
Mat radon;

ximgproc::RadonTransform(src, radon, 45, 0, 180, false, false);
EXPECT_LT(109, sum(radon.col(0))[0]);
EXPECT_GT(111, sum(radon.col(0))[0]);
}
Expand Down

0 comments on commit 370eb5f

Please sign in to comment.