File: peilin.cpp

package info (click to toggle)
opencv 4.5.1%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 268,248 kB
  • sloc: cpp: 969,170; xml: 682,525; python: 36,732; lisp: 30,170; java: 25,155; ansic: 7,927; javascript: 5,643; objc: 2,041; sh: 935; cs: 601; perl: 494; makefile: 145
file content (50 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/ximgproc.hpp>

#include <iostream>

static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs )
{
    cv::Mat ret;
    cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR );
    return ret;
}

static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs )
{
    cv::Mat ret;
    cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP );
    return ret;
}

int main(int argc, char** argv)
{
    cv::CommandLineParser parser(argc, argv, "{ @input1 | ../data/peilin_plane.png | }{ @input2 | ../data/peilin_shape.png | }");
    parser.about("\nThis program demonstrates Pei&Lin Normalization\n");
    parser.printMessage();

    std::string filename1 = parser.get<std::string>("@input1");
    std::string filename2 = parser.get<std::string>("@input2");

    cv::Mat I = cv::imread(filename1, 0);
    if (I.empty())
    {
        std::cout << "Couldn't open image " << filename1 << std::endl;
        return 0;
    }
    cv::Mat J = cv::imread(filename2, 0);
    if (J.empty())
    {
        std::cout << "Couldn't open image " << filename2 << std::endl;
        return 0;
    }
    cv::Mat N = I & cv::ximgproc::PeiLinNormalization ( I );
    cv::Mat D = cv::ximgproc::PeiLinNormalization ( J ) & I;
    cv::imshow ( "I", I );
    cv::imshow ( "N", N );
    cv::imshow ( "J", J );
    cv::imshow ( "D", D );
    cv::waitKey();
    return 0;
}