Skip to content

Commit 969bb1e

Browse files
committed
Fixed review comments
1 parent 17c2ce9 commit 969bb1e

File tree

4 files changed

+57
-143
lines changed

4 files changed

+57
-143
lines changed

modules/ximgproc/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
set(the_description "Extended image processing module. It includes edge-aware filters and etc.")
22
ocv_define_module(ximgproc opencv_core opencv_imgproc opencv_calib3d opencv_imgcodecs WRAP python)
3-
4-
file(COPY samples/peilin_plane.png DESTINATION ${OpenCV_BINARY_DIR}/bin)
5-
file(COPY samples/peilin_shape.png DESTINATION ${OpenCV_BINARY_DIR}/bin)

modules/ximgproc/include/opencv2/ximgproc/peilin.hpp

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,27 @@
1-
/*M///////////////////////////////////////////////////////////////////////////////////////
2-
//
3-
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4-
//
5-
// By downloading, copying, installing or using the software you agree to this license.
6-
// If you do not agree to this license, do not download, install,
7-
// copy or use the software.
8-
//
9-
//
10-
// License Agreement
11-
// For Open Source Computer Vision Library
12-
//
13-
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
14-
// Third party copyrights are property of their respective owners.
15-
//
16-
// Redistribution and use in source and binary forms, with or without modification,
17-
// are permitted provided that the following conditions are met:
18-
//
19-
// * Redistribution's of source code must retain the above copyright notice,
20-
// this list of conditions and the following disclaimer.
21-
//
22-
// * Redistribution's in binary form must reproduce the above copyright notice,
23-
// this list of conditions and the following disclaimer in the documentation
24-
// and/or other materials provided with the distribution.
25-
//
26-
// * The name of Intel Corporation may not be used to endorse or promote products
27-
// derived from this software without specific prior written permission.
28-
//
29-
// This software is provided by the copyright holders and contributors "as is" and
30-
// any express or implied warranties, including, but not limited to, the implied
31-
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32-
// In no event shall the Intel Corporation or contributors be liable for any direct,
33-
// indirect, incidental, special, exemplary, or consequential damages
34-
// (including, but not limited to, procurement of substitute goods or services;
35-
// loss of use, data, or profits; or business interruption) however caused
36-
// and on any theory of liability, whether in contract, strict liability,
37-
// or tort (including negligence or otherwise) arising in any way out of
38-
// the use of this software, even if advised of the possibility of such damage.
39-
//
40-
//M*/
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
415
#ifndef __OPENCV_PEILIN_HPP__
426
#define __OPENCV_PEILIN_HPP__
437

448
#include <opencv2/core.hpp>
459

4610
namespace cv
4711
{
48-
//! @addtogroup ximgproc_filters
12+
//! @addtogroup ximgproc
4913
//! @{
5014

5115
/**
5216
* @brief Calculates an affine transformation that normalize given image using Pei&Lin Normalization.
5317
*
54-
* Assume given image :math:`I=T(\bar{I})` where :math:`\bar{I}` is a normalized image and :math:`T` is is an affine transformation distorting this image by translation, rotation, scaling and skew.
55-
* The function returns an affine transformation matrix corresponding to the transformation :math:`T^{-1}` described in [PeiLin95].
18+
* Assume given image \f$I=T(\bar{I})\f$ where \f$\bar{I}\f$ is a normalized image and \f$T\f$ is an affine transformation distorting this image by translation, rotation, scaling and skew.
19+
* The function returns an affine transformation matrix corresponding to the transformation \f$T^{-1}\f$ described in [PeiLin95].
5620
* For more details about this implementation, please see
5721
* [PeiLin95] Soo-Chang Pei and Chao-Nan Lin. Image normalization for pattern recognition. Image and Vision Computing, Vol. 13, N.10, pp. 711-723, 1995.
5822
*
5923
* @param I Given transformed image.
24+
* @return Transformation matrix corresponding to inversed image transformation
6025
*/
6126
CV_EXPORTS Matx23d PeiLinNormalization ( InputArray I );
6227
/** @overload */

modules/ximgproc/samples/peilin.cpp

Lines changed: 45 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,59 @@
1-
/*M///////////////////////////////////////////////////////////////////////////////////////
2-
//
3-
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4-
//
5-
// By downloading, copying, installing or using the software you agree to this license.
6-
// If you do not agree to this license, do not download, install,
7-
// copy or use the software.
8-
//
9-
//
10-
// License Agreement
11-
// For Open Source Computer Vision Library
12-
//
13-
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
14-
// Third party copyrights are property of their respective owners.
15-
//
16-
// Redistribution and use in source and binary forms, with or without modification,
17-
// are permitted provided that the following conditions are met:
18-
//
19-
// * Redistribution's of source code must retain the above copyright notice,
20-
// this list of conditions and the following disclaimer.
21-
//
22-
// * Redistribution's in binary form must reproduce the above copyright notice,
23-
// this list of conditions and the following disclaimer in the documentation
24-
// and/or other materials provided with the distribution.
25-
//
26-
// * The name of Intel Corporation may not be used to endorse or promote products
27-
// derived from this software without specific prior written permission.
28-
//
29-
// This software is provided by the copyright holders and contributors "as is" and
30-
// any express or implied warranties, including, but not limited to, the implied
31-
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32-
// In no event shall the Intel Corporation or contributors be liable for any direct,
33-
// indirect, incidental, special, exemplary, or consequential damages
34-
// (including, but not limited to, procurement of substitute goods or services;
35-
// loss of use, data, or profits; or business interruption) however caused
36-
// and on any theory of liability, whether in contract, strict liability,
37-
// or tort (including negligence or otherwise) arising in any way out of
38-
// the use of this software, even if advised of the possibility of such damage.
39-
//
40-
//M*/
411
#include <opencv2/imgproc.hpp>
422
#include <opencv2/highgui.hpp>
433
#include <opencv2/ximgproc.hpp>
444

5+
#include <iostream>
6+
7+
static void help()
8+
{
9+
std::cout << "\nThis program demonstrates Pei&Lin Normalization\n"
10+
"Usage:\n"
11+
"./peilin [image1_name -- default is ../data/peilin_plane.png] [image2_name -- default is ../data/peilin_shape.png]\n" << std::endl;
12+
}
13+
4514
static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs )
4615
{
47-
cv::Mat ret;
48-
cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR );
49-
return ret;
16+
cv::Mat ret;
17+
cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR );
18+
return ret;
5019
}
5120

5221
static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs )
5322
{
54-
cv::Mat ret;
55-
cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP );
56-
return ret;
23+
cv::Mat ret;
24+
cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP );
25+
return ret;
5726
}
5827

59-
int main()
28+
int main(int argc, char** argv)
6029
{
61-
cv::Mat I = cv::imread ( "../data/peilin_plane.png", 0 );
62-
cv::Mat N = I & cv::PeiLinNormalization ( I );
63-
cv::Mat J = cv::imread ( "../data/peilin_shape.png", 0 );
64-
cv::Mat D = cv::PeiLinNormalization ( J ) & I;
65-
cv::imshow ( "I", I );
66-
cv::imshow ( "N", N );
67-
cv::imshow ( "J", J );
68-
cv::imshow ( "D", D );
69-
cv::waitKey();
70-
return 0;
30+
cv::CommandLineParser parser(argc, argv, "{help h | | }{ @input1 | ../data/peilin_plane.png | }{ @input2 | ../data/peilin_plane.png | }");
31+
if (parser.has("help"))
32+
{
33+
help();
34+
return 0;
35+
}
36+
std::string filename1 = parser.get<std::string>("@input1");
37+
std::string filename2 = parser.get<std::string>("@input2");
38+
39+
cv::Mat I = cv::imread(filename1, 0);
40+
if (I.empty())
41+
{
42+
std::cout << "Couldn't open image " << filename1 << std::endl;
43+
return 0;
44+
}
45+
cv::Mat J = cv::imread(filename2, 0);
46+
if (J.empty())
47+
{
48+
std::cout << "Couldn't open image " << filename2 << std::endl;
49+
return 0;
50+
}
51+
cv::Mat N = I & cv::PeiLinNormalization ( I );
52+
cv::Mat D = cv::PeiLinNormalization ( J ) & I;
53+
cv::imshow ( "I", I );
54+
cv::imshow ( "N", N );
55+
cv::imshow ( "J", J );
56+
cv::imshow ( "D", D );
57+
cv::waitKey();
58+
return 0;
7159
}

modules/ximgproc/src/peilin.cpp

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,7 @@
1-
/*M///////////////////////////////////////////////////////////////////////////////////////
2-
//
3-
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4-
//
5-
// By downloading, copying, installing or using the software you agree to this license.
6-
// If you do not agree to this license, do not download, install,
7-
// copy or use the software.
8-
//
9-
//
10-
// License Agreement
11-
// For Open Source Computer Vision Library
12-
//
13-
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
14-
// Third party copyrights are property of their respective owners.
15-
//
16-
// Redistribution and use in source and binary forms, with or without modification,
17-
// are permitted provided that the following conditions are met:
18-
//
19-
// * Redistribution's of source code must retain the above copyright notice,
20-
// this list of conditions and the following disclaimer.
21-
//
22-
// * Redistribution's in binary form must reproduce the above copyright notice,
23-
// this list of conditions and the following disclaimer in the documentation
24-
// and/or other materials provided with the distribution.
25-
//
26-
// * The name of Intel Corporation may not be used to endorse or promote products
27-
// derived from this software without specific prior written permission.
28-
//
29-
// This software is provided by the copyright holders and contributors "as is" and
30-
// any express or implied warranties, including, but not limited to, the implied
31-
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32-
// In no event shall the Intel Corporation or contributors be liable for any direct,
33-
// indirect, incidental, special, exemplary, or consequential damages
34-
// (including, but not limited to, procurement of substitute goods or services;
35-
// loss of use, data, or profits; or business interruption) however caused
36-
// and on any theory of liability, whether in contract, strict liability,
37-
// or tort (including negligence or otherwise) arising in any way out of
38-
// the use of this software, even if advised of the possibility of such damage.
39-
//
40-
//M*/
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
415
#include "precomp.hpp"
426

437
namespace cv

0 commit comments

Comments
 (0)