1 #include <opencv2/imgproc.hpp>
2 #include <opencv2/highgui.hpp>
3 #include <opencv2/ximgproc.hpp>
4
5 #include <iostream>
6
operator &(const cv::Mat & lhs,const cv::Matx23d & rhs)7 static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs )
8 {
9 cv::Mat ret;
10 cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR );
11 return ret;
12 }
13
operator &(const cv::Matx23d & lhs,const cv::Mat & rhs)14 static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs )
15 {
16 cv::Mat ret;
17 cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP );
18 return ret;
19 }
20
main(int argc,char ** argv)21 int main(int argc, char** argv)
22 {
23 cv::CommandLineParser parser(argc, argv, "{ @input1 | ../data/peilin_plane.png | }{ @input2 | ../data/peilin_shape.png | }");
24 parser.about("\nThis program demonstrates Pei&Lin Normalization\n");
25 parser.printMessage();
26
27 std::string filename1 = parser.get<std::string>("@input1");
28 std::string filename2 = parser.get<std::string>("@input2");
29
30 cv::Mat I = cv::imread(filename1, 0);
31 if (I.empty())
32 {
33 std::cout << "Couldn't open image " << filename1 << std::endl;
34 return 0;
35 }
36 cv::Mat J = cv::imread(filename2, 0);
37 if (J.empty())
38 {
39 std::cout << "Couldn't open image " << filename2 << std::endl;
40 return 0;
41 }
42 cv::Mat N = I & cv::ximgproc::PeiLinNormalization ( I );
43 cv::Mat D = cv::ximgproc::PeiLinNormalization ( J ) & I;
44 cv::imshow ( "I", I );
45 cv::imshow ( "N", N );
46 cv::imshow ( "J", J );
47 cv::imshow ( "D", D );
48 cv::waitKey();
49 return 0;
50 }
51