|
|
|
@ -1744,4 +1744,86 @@ TEST(Imgproc_Remap, DISABLED_memleak) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(Imgproc_linearPolar, identity) |
|
|
|
|
{ |
|
|
|
|
const int N = 33; |
|
|
|
|
Mat in(N, N, CV_8UC3, Scalar(255, 0, 0)); |
|
|
|
|
in(cv::Rect(N/3, N/3, N/3, N/3)).setTo(Scalar::all(255)); |
|
|
|
|
cv::blur(in, in, Size(5, 5)); |
|
|
|
|
cv::blur(in, in, Size(5, 5)); |
|
|
|
|
|
|
|
|
|
Mat src = in.clone(); |
|
|
|
|
Mat dst; |
|
|
|
|
|
|
|
|
|
Rect roi = Rect(0, 0, in.cols - ((N+19)/20), in.rows); |
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= 5; i++) |
|
|
|
|
{ |
|
|
|
|
linearPolar(src, dst, |
|
|
|
|
Point2f((N-1) * 0.5f, (N-1) * 0.5f), N * 0.5f, |
|
|
|
|
CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR | CV_WARP_INVERSE_MAP); |
|
|
|
|
|
|
|
|
|
linearPolar(dst, src, |
|
|
|
|
Point2f((N-1) * 0.5f, (N-1) * 0.5f), N * 0.5f, |
|
|
|
|
CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR); |
|
|
|
|
|
|
|
|
|
double psnr = cvtest::PSNR(in(roi), src(roi)); |
|
|
|
|
EXPECT_LE(25, psnr) << "iteration=" << i; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
Mat all(N*2+2,N*2+2, src.type(), Scalar(0,0,255)); |
|
|
|
|
in.copyTo(all(Rect(0,0,N,N))); |
|
|
|
|
src.copyTo(all(Rect(0,N+1,N,N))); |
|
|
|
|
src.copyTo(all(Rect(N+1,0,N,N))); |
|
|
|
|
dst.copyTo(all(Rect(N+1,N+1,N,N))); |
|
|
|
|
imwrite("linearPolar.png", all); |
|
|
|
|
imshow("input", in); imshow("result", dst); imshow("restore", src); imshow("all", all); |
|
|
|
|
cv::waitKey(); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(Imgproc_logPolar, identity) |
|
|
|
|
{ |
|
|
|
|
const int N = 33; |
|
|
|
|
Mat in(N, N, CV_8UC3, Scalar(255, 0, 0)); |
|
|
|
|
in(cv::Rect(N/3, N/3, N/3, N/3)).setTo(Scalar::all(255)); |
|
|
|
|
cv::blur(in, in, Size(5, 5)); |
|
|
|
|
cv::blur(in, in, Size(5, 5)); |
|
|
|
|
|
|
|
|
|
Mat src = in.clone(); |
|
|
|
|
Mat dst; |
|
|
|
|
|
|
|
|
|
Rect roi = Rect(0, 0, in.cols - ((N+19)/20), in.rows); |
|
|
|
|
|
|
|
|
|
double M = N/log(N * 0.5f); |
|
|
|
|
for (int i = 1; i <= 5; i++) |
|
|
|
|
{ |
|
|
|
|
logPolar(src, dst, |
|
|
|
|
Point2f((N-1) * 0.5f, (N-1) * 0.5f), M, |
|
|
|
|
CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR | CV_WARP_INVERSE_MAP); |
|
|
|
|
|
|
|
|
|
logPolar(dst, src, |
|
|
|
|
Point2f((N-1) * 0.5f, (N-1) * 0.5f), M, |
|
|
|
|
CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR); |
|
|
|
|
|
|
|
|
|
double psnr = cvtest::PSNR(in(roi), src(roi)); |
|
|
|
|
EXPECT_LE(25, psnr) << "iteration=" << i; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
Mat all(N*2+2,N*2+2, src.type(), Scalar(0,0,255)); |
|
|
|
|
in.copyTo(all(Rect(0,0,N,N))); |
|
|
|
|
src.copyTo(all(Rect(0,N+1,N,N))); |
|
|
|
|
src.copyTo(all(Rect(N+1,0,N,N))); |
|
|
|
|
dst.copyTo(all(Rect(N+1,N+1,N,N))); |
|
|
|
|
imwrite("logPolar.png", all); |
|
|
|
|
imshow("input", in); imshow("result", dst); imshow("restore", src); imshow("all", all); |
|
|
|
|
cv::waitKey(); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* End of file. */ |
|
|
|
|