Fixed review comments

pull/1379/head
Vitaly Tuzov 7 years ago
parent 17c2ce9c78
commit 969bb1ef44
  1. 3
      modules/ximgproc/CMakeLists.txt
  2. 51
      modules/ximgproc/include/opencv2/ximgproc/peilin.hpp
  3. 102
      modules/ximgproc/samples/peilin.cpp
  4. 44
      modules/ximgproc/src/peilin.cpp

@ -1,5 +1,2 @@
set(the_description "Extended image processing module. It includes edge-aware filters and etc.") set(the_description "Extended image processing module. It includes edge-aware filters and etc.")
ocv_define_module(ximgproc opencv_core opencv_imgproc opencv_calib3d opencv_imgcodecs WRAP python) ocv_define_module(ximgproc opencv_core opencv_imgproc opencv_calib3d opencv_imgcodecs WRAP python)
file(COPY samples/peilin_plane.png DESTINATION ${OpenCV_BINARY_DIR}/bin)
file(COPY samples/peilin_shape.png DESTINATION ${OpenCV_BINARY_DIR}/bin)

@ -1,43 +1,7 @@
/*M/////////////////////////////////////////////////////////////////////////////////////// // This file is part of OpenCV project.
// // It is subject to the license terms in the LICENSE file found in the top-level directory
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // of this distribution and at http://opencv.org/license.html.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_PEILIN_HPP__ #ifndef __OPENCV_PEILIN_HPP__
#define __OPENCV_PEILIN_HPP__ #define __OPENCV_PEILIN_HPP__
@ -45,18 +9,19 @@
namespace cv namespace cv
{ {
//! @addtogroup ximgproc_filters //! @addtogroup ximgproc
//! @{ //! @{
/** /**
* @brief Calculates an affine transformation that normalize given image using Pei&Lin Normalization. * @brief Calculates an affine transformation that normalize given image using Pei&Lin Normalization.
* *
* 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. * 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.
* The function returns an affine transformation matrix corresponding to the transformation :math:`T^{-1}` described in [PeiLin95]. * The function returns an affine transformation matrix corresponding to the transformation \f$T^{-1}\f$ described in [PeiLin95].
* For more details about this implementation, please see * For more details about this implementation, please see
* [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. * [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.
* *
* @param I Given transformed image. * @param I Given transformed image.
* @return Transformation matrix corresponding to inversed image transformation
*/ */
CV_EXPORTS Matx23d PeiLinNormalization ( InputArray I ); CV_EXPORTS Matx23d PeiLinNormalization ( InputArray I );
/** @overload */ /** @overload */

@ -1,71 +1,59 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <opencv2/ximgproc.hpp> #include <opencv2/ximgproc.hpp>
#include <iostream>
static void help()
{
std::cout << "\nThis program demonstrates Pei&Lin Normalization\n"
"Usage:\n"
"./peilin [image1_name -- default is ../data/peilin_plane.png] [image2_name -- default is ../data/peilin_shape.png]\n" << std::endl;
}
static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs ) static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs )
{ {
cv::Mat ret; cv::Mat ret;
cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR ); cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR );
return ret; return ret;
} }
static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs ) static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs )
{ {
cv::Mat ret; cv::Mat ret;
cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP ); cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP );
return ret; return ret;
} }
int main() int main(int argc, char** argv)
{ {
cv::Mat I = cv::imread ( "../data/peilin_plane.png", 0 ); cv::CommandLineParser parser(argc, argv, "{help h | | }{ @input1 | ../data/peilin_plane.png | }{ @input2 | ../data/peilin_plane.png | }");
cv::Mat N = I & cv::PeiLinNormalization ( I ); if (parser.has("help"))
cv::Mat J = cv::imread ( "../data/peilin_shape.png", 0 ); {
cv::Mat D = cv::PeiLinNormalization ( J ) & I; help();
cv::imshow ( "I", I ); return 0;
cv::imshow ( "N", N ); }
cv::imshow ( "J", J ); std::string filename1 = parser.get<std::string>("@input1");
cv::imshow ( "D", D ); std::string filename2 = parser.get<std::string>("@input2");
cv::waitKey();
return 0; 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::PeiLinNormalization ( I );
cv::Mat D = cv::PeiLinNormalization ( J ) & I;
cv::imshow ( "I", I );
cv::imshow ( "N", N );
cv::imshow ( "J", J );
cv::imshow ( "D", D );
cv::waitKey();
return 0;
} }

@ -1,43 +1,7 @@
/*M/////////////////////////////////////////////////////////////////////////////////////// // This file is part of OpenCV project.
// // It is subject to the license terms in the LICENSE file found in the top-level directory
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // of this distribution and at http://opencv.org/license.html.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2008, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp" #include "precomp.hpp"
namespace cv namespace cv

Loading…
Cancel
Save