openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:0e0631af0305 1 /*M///////////////////////////////////////////////////////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2 //
RyoheiHagimoto 0:0e0631af0305 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
RyoheiHagimoto 0:0e0631af0305 4 //
RyoheiHagimoto 0:0e0631af0305 5 // By downloading, copying, installing or using the software you agree to this license.
RyoheiHagimoto 0:0e0631af0305 6 // If you do not agree to this license, do not download, install,
RyoheiHagimoto 0:0e0631af0305 7 // copy or use the software.
RyoheiHagimoto 0:0e0631af0305 8 //
RyoheiHagimoto 0:0e0631af0305 9 //
RyoheiHagimoto 0:0e0631af0305 10 // License Agreement
RyoheiHagimoto 0:0e0631af0305 11 // For Open Source Computer Vision Library
RyoheiHagimoto 0:0e0631af0305 12 //
RyoheiHagimoto 0:0e0631af0305 13 // Copyright (C) 2000-2015, Intel Corporation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 14 // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 15 // Copyright (C) 2015, OpenCV Foundation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 16 // Copyright (C) 2015, Itseez Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 17 // Third party copyrights are property of their respective owners.
RyoheiHagimoto 0:0e0631af0305 18 //
RyoheiHagimoto 0:0e0631af0305 19 // Redistribution and use in source and binary forms, with or without modification,
RyoheiHagimoto 0:0e0631af0305 20 // are permitted provided that the following conditions are met:
RyoheiHagimoto 0:0e0631af0305 21 //
RyoheiHagimoto 0:0e0631af0305 22 // * Redistribution's of source code must retain the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 23 // this list of conditions and the following disclaimer.
RyoheiHagimoto 0:0e0631af0305 24 //
RyoheiHagimoto 0:0e0631af0305 25 // * Redistribution's in binary form must reproduce the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 26 // this list of conditions and the following disclaimer in the documentation
RyoheiHagimoto 0:0e0631af0305 27 // and/or other materials provided with the distribution.
RyoheiHagimoto 0:0e0631af0305 28 //
RyoheiHagimoto 0:0e0631af0305 29 // * The name of the copyright holders may not be used to endorse or promote products
RyoheiHagimoto 0:0e0631af0305 30 // derived from this software without specific prior written permission.
RyoheiHagimoto 0:0e0631af0305 31 //
RyoheiHagimoto 0:0e0631af0305 32 // This software is provided by the copyright holders and contributors "as is" and
RyoheiHagimoto 0:0e0631af0305 33 // any express or implied warranties, including, but not limited to, the implied
RyoheiHagimoto 0:0e0631af0305 34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
RyoheiHagimoto 0:0e0631af0305 35 // In no event shall the Intel Corporation or contributors be liable for any direct,
RyoheiHagimoto 0:0e0631af0305 36 // indirect, incidental, special, exemplary, or consequential damages
RyoheiHagimoto 0:0e0631af0305 37 // (including, but not limited to, procurement of substitute goods or services;
RyoheiHagimoto 0:0e0631af0305 38 // loss of use, data, or profits; or business interruption) however caused
RyoheiHagimoto 0:0e0631af0305 39 // and on any theory of liability, whether in contract, strict liability,
RyoheiHagimoto 0:0e0631af0305 40 // or tort (including negligence or otherwise) arising in any way out of
RyoheiHagimoto 0:0e0631af0305 41 // the use of this software, even if advised of the possibility of such damage.
RyoheiHagimoto 0:0e0631af0305 42 //
RyoheiHagimoto 0:0e0631af0305 43 //M*/
RyoheiHagimoto 0:0e0631af0305 44
RyoheiHagimoto 0:0e0631af0305 45 #ifndef OPENCV_CORE_HPP
RyoheiHagimoto 0:0e0631af0305 46 #define OPENCV_CORE_HPP
RyoheiHagimoto 0:0e0631af0305 47
RyoheiHagimoto 0:0e0631af0305 48 #ifndef __cplusplus
RyoheiHagimoto 0:0e0631af0305 49 # error core.hpp header must be compiled as C++
RyoheiHagimoto 0:0e0631af0305 50 #endif
RyoheiHagimoto 0:0e0631af0305 51
RyoheiHagimoto 0:0e0631af0305 52 #include "opencv2/core/cvdef.h"
RyoheiHagimoto 0:0e0631af0305 53 #include "opencv2/core/version.hpp"
RyoheiHagimoto 0:0e0631af0305 54 #include "opencv2/core/base.hpp"
RyoheiHagimoto 0:0e0631af0305 55 #include "opencv2/core/cvstd.hpp"
RyoheiHagimoto 0:0e0631af0305 56 #include "opencv2/core/traits.hpp"
RyoheiHagimoto 0:0e0631af0305 57 #include "opencv2/core/matx.hpp"
RyoheiHagimoto 0:0e0631af0305 58 #include "opencv2/core/types.hpp"
RyoheiHagimoto 0:0e0631af0305 59 #include "opencv2/core/mat.hpp"
RyoheiHagimoto 0:0e0631af0305 60 #include "opencv2/core/persistence.hpp"
RyoheiHagimoto 0:0e0631af0305 61
RyoheiHagimoto 0:0e0631af0305 62 /**
RyoheiHagimoto 0:0e0631af0305 63 @defgroup core Core functionality
RyoheiHagimoto 0:0e0631af0305 64 @{
RyoheiHagimoto 0:0e0631af0305 65 @defgroup core_basic Basic structures
RyoheiHagimoto 0:0e0631af0305 66 @defgroup core_c C structures and operations
RyoheiHagimoto 0:0e0631af0305 67 @{
RyoheiHagimoto 0:0e0631af0305 68 @defgroup core_c_glue Connections with C++
RyoheiHagimoto 0:0e0631af0305 69 @}
RyoheiHagimoto 0:0e0631af0305 70 @defgroup core_array Operations on arrays
RyoheiHagimoto 0:0e0631af0305 71 @defgroup core_xml XML/YAML Persistence
RyoheiHagimoto 0:0e0631af0305 72 @defgroup core_cluster Clustering
RyoheiHagimoto 0:0e0631af0305 73 @defgroup core_utils Utility and system functions and macros
RyoheiHagimoto 0:0e0631af0305 74 @{
RyoheiHagimoto 0:0e0631af0305 75 @defgroup core_utils_sse SSE utilities
RyoheiHagimoto 0:0e0631af0305 76 @defgroup core_utils_neon NEON utilities
RyoheiHagimoto 0:0e0631af0305 77 @}
RyoheiHagimoto 0:0e0631af0305 78 @defgroup core_opengl OpenGL interoperability
RyoheiHagimoto 0:0e0631af0305 79 @defgroup core_ipp Intel IPP Asynchronous C/C++ Converters
RyoheiHagimoto 0:0e0631af0305 80 @defgroup core_optim Optimization Algorithms
RyoheiHagimoto 0:0e0631af0305 81 @defgroup core_directx DirectX interoperability
RyoheiHagimoto 0:0e0631af0305 82 @defgroup core_eigen Eigen support
RyoheiHagimoto 0:0e0631af0305 83 @defgroup core_opencl OpenCL support
RyoheiHagimoto 0:0e0631af0305 84 @defgroup core_va_intel Intel VA-API/OpenCL (CL-VA) interoperability
RyoheiHagimoto 0:0e0631af0305 85 @defgroup core_hal Hardware Acceleration Layer
RyoheiHagimoto 0:0e0631af0305 86 @{
RyoheiHagimoto 0:0e0631af0305 87 @defgroup core_hal_functions Functions
RyoheiHagimoto 0:0e0631af0305 88 @defgroup core_hal_interface Interface
RyoheiHagimoto 0:0e0631af0305 89 @defgroup core_hal_intrin Universal intrinsics
RyoheiHagimoto 0:0e0631af0305 90 @{
RyoheiHagimoto 0:0e0631af0305 91 @defgroup core_hal_intrin_impl Private implementation helpers
RyoheiHagimoto 0:0e0631af0305 92 @}
RyoheiHagimoto 0:0e0631af0305 93 @}
RyoheiHagimoto 0:0e0631af0305 94 @}
RyoheiHagimoto 0:0e0631af0305 95 */
RyoheiHagimoto 0:0e0631af0305 96
RyoheiHagimoto 0:0e0631af0305 97 namespace cv {
RyoheiHagimoto 0:0e0631af0305 98
RyoheiHagimoto 0:0e0631af0305 99 //! @addtogroup core_utils
RyoheiHagimoto 0:0e0631af0305 100 //! @{
RyoheiHagimoto 0:0e0631af0305 101
RyoheiHagimoto 0:0e0631af0305 102 /*! @brief Class passed to an error.
RyoheiHagimoto 0:0e0631af0305 103
RyoheiHagimoto 0:0e0631af0305 104 This class encapsulates all or almost all necessary
RyoheiHagimoto 0:0e0631af0305 105 information about the error happened in the program. The exception is
RyoheiHagimoto 0:0e0631af0305 106 usually constructed and thrown implicitly via CV_Error and CV_Error_ macros.
RyoheiHagimoto 0:0e0631af0305 107 @see error
RyoheiHagimoto 0:0e0631af0305 108 */
RyoheiHagimoto 0:0e0631af0305 109 class CV_EXPORTS Exception : public std::exception
RyoheiHagimoto 0:0e0631af0305 110 {
RyoheiHagimoto 0:0e0631af0305 111 public:
RyoheiHagimoto 0:0e0631af0305 112 /*!
RyoheiHagimoto 0:0e0631af0305 113 Default constructor
RyoheiHagimoto 0:0e0631af0305 114 */
RyoheiHagimoto 0:0e0631af0305 115 Exception();
RyoheiHagimoto 0:0e0631af0305 116 /*!
RyoheiHagimoto 0:0e0631af0305 117 Full constructor. Normally the constuctor is not called explicitly.
RyoheiHagimoto 0:0e0631af0305 118 Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
RyoheiHagimoto 0:0e0631af0305 119 */
RyoheiHagimoto 0:0e0631af0305 120 Exception(int _code, const String& _err, const String& _func, const String& _file, int _line);
RyoheiHagimoto 0:0e0631af0305 121 virtual ~Exception() throw();
RyoheiHagimoto 0:0e0631af0305 122
RyoheiHagimoto 0:0e0631af0305 123 /*!
RyoheiHagimoto 0:0e0631af0305 124 \return the error description and the context as a text string.
RyoheiHagimoto 0:0e0631af0305 125 */
RyoheiHagimoto 0:0e0631af0305 126 virtual const char *what() const throw();
RyoheiHagimoto 0:0e0631af0305 127 void formatMessage();
RyoheiHagimoto 0:0e0631af0305 128
RyoheiHagimoto 0:0e0631af0305 129 String msg; ///< the formatted error message
RyoheiHagimoto 0:0e0631af0305 130
RyoheiHagimoto 0:0e0631af0305 131 int code; ///< error code @see CVStatus
RyoheiHagimoto 0:0e0631af0305 132 String err; ///< error description
RyoheiHagimoto 0:0e0631af0305 133 String func; ///< function name. Available only when the compiler supports getting it
RyoheiHagimoto 0:0e0631af0305 134 String file; ///< source file name where the error has occured
RyoheiHagimoto 0:0e0631af0305 135 int line; ///< line number in the source file where the error has occured
RyoheiHagimoto 0:0e0631af0305 136 };
RyoheiHagimoto 0:0e0631af0305 137
RyoheiHagimoto 0:0e0631af0305 138 /*! @brief Signals an error and raises the exception.
RyoheiHagimoto 0:0e0631af0305 139
RyoheiHagimoto 0:0e0631af0305 140 By default the function prints information about the error to stderr,
RyoheiHagimoto 0:0e0631af0305 141 then it either stops if cv::setBreakOnError() had been called before or raises the exception.
RyoheiHagimoto 0:0e0631af0305 142 It is possible to alternate error processing by using cv::redirectError().
RyoheiHagimoto 0:0e0631af0305 143 @param exc the exception raisen.
RyoheiHagimoto 0:0e0631af0305 144 @deprecated drop this version
RyoheiHagimoto 0:0e0631af0305 145 */
RyoheiHagimoto 0:0e0631af0305 146 CV_EXPORTS void error( const Exception& exc );
RyoheiHagimoto 0:0e0631af0305 147
RyoheiHagimoto 0:0e0631af0305 148 enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
RyoheiHagimoto 0:0e0631af0305 149 SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted
RyoheiHagimoto 0:0e0631af0305 150 //!< independently; this flag and the previous one are
RyoheiHagimoto 0:0e0631af0305 151 //!< mutually exclusive.
RyoheiHagimoto 0:0e0631af0305 152 SORT_ASCENDING = 0, //!< each matrix row is sorted in the ascending
RyoheiHagimoto 0:0e0631af0305 153 //!< order.
RyoheiHagimoto 0:0e0631af0305 154 SORT_DESCENDING = 16 //!< each matrix row is sorted in the
RyoheiHagimoto 0:0e0631af0305 155 //!< descending order; this flag and the previous one are also
RyoheiHagimoto 0:0e0631af0305 156 //!< mutually exclusive.
RyoheiHagimoto 0:0e0631af0305 157 };
RyoheiHagimoto 0:0e0631af0305 158
RyoheiHagimoto 0:0e0631af0305 159 //! @} core_utils
RyoheiHagimoto 0:0e0631af0305 160
RyoheiHagimoto 0:0e0631af0305 161 //! @addtogroup core
RyoheiHagimoto 0:0e0631af0305 162 //! @{
RyoheiHagimoto 0:0e0631af0305 163
RyoheiHagimoto 0:0e0631af0305 164 //! Covariation flags
RyoheiHagimoto 0:0e0631af0305 165 enum CovarFlags {
RyoheiHagimoto 0:0e0631af0305 166 /** The output covariance matrix is calculated as:
RyoheiHagimoto 0:0e0631af0305 167 \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...],\f]
RyoheiHagimoto 0:0e0631af0305 168 The covariance matrix will be nsamples x nsamples. Such an unusual covariance matrix is used
RyoheiHagimoto 0:0e0631af0305 169 for fast PCA of a set of very large vectors (see, for example, the EigenFaces technique for
RyoheiHagimoto 0:0e0631af0305 170 face recognition). Eigenvalues of this "scrambled" matrix match the eigenvalues of the true
RyoheiHagimoto 0:0e0631af0305 171 covariance matrix. The "true" eigenvectors can be easily calculated from the eigenvectors of
RyoheiHagimoto 0:0e0631af0305 172 the "scrambled" covariance matrix. */
RyoheiHagimoto 0:0e0631af0305 173 COVAR_SCRAMBLED = 0,
RyoheiHagimoto 0:0e0631af0305 174 /**The output covariance matrix is calculated as:
RyoheiHagimoto 0:0e0631af0305 175 \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f]
RyoheiHagimoto 0:0e0631af0305 176 covar will be a square matrix of the same size as the total number of elements in each input
RyoheiHagimoto 0:0e0631af0305 177 vector. One and only one of COVAR_SCRAMBLED and COVAR_NORMAL must be specified.*/
RyoheiHagimoto 0:0e0631af0305 178 COVAR_NORMAL = 1,
RyoheiHagimoto 0:0e0631af0305 179 /** If the flag is specified, the function does not calculate mean from
RyoheiHagimoto 0:0e0631af0305 180 the input vectors but, instead, uses the passed mean vector. This is useful if mean has been
RyoheiHagimoto 0:0e0631af0305 181 pre-calculated or known in advance, or if the covariance matrix is calculated by parts. In
RyoheiHagimoto 0:0e0631af0305 182 this case, mean is not a mean vector of the input sub-set of vectors but rather the mean
RyoheiHagimoto 0:0e0631af0305 183 vector of the whole set.*/
RyoheiHagimoto 0:0e0631af0305 184 COVAR_USE_AVG = 2,
RyoheiHagimoto 0:0e0631af0305 185 /** If the flag is specified, the covariance matrix is scaled. In the
RyoheiHagimoto 0:0e0631af0305 186 "normal" mode, scale is 1./nsamples . In the "scrambled" mode, scale is the reciprocal of the
RyoheiHagimoto 0:0e0631af0305 187 total number of elements in each input vector. By default (if the flag is not specified), the
RyoheiHagimoto 0:0e0631af0305 188 covariance matrix is not scaled ( scale=1 ).*/
RyoheiHagimoto 0:0e0631af0305 189 COVAR_SCALE = 4,
RyoheiHagimoto 0:0e0631af0305 190 /** If the flag is
RyoheiHagimoto 0:0e0631af0305 191 specified, all the input vectors are stored as rows of the samples matrix. mean should be a
RyoheiHagimoto 0:0e0631af0305 192 single-row vector in this case.*/
RyoheiHagimoto 0:0e0631af0305 193 COVAR_ROWS = 8,
RyoheiHagimoto 0:0e0631af0305 194 /** If the flag is
RyoheiHagimoto 0:0e0631af0305 195 specified, all the input vectors are stored as columns of the samples matrix. mean should be a
RyoheiHagimoto 0:0e0631af0305 196 single-column vector in this case.*/
RyoheiHagimoto 0:0e0631af0305 197 COVAR_COLS = 16
RyoheiHagimoto 0:0e0631af0305 198 };
RyoheiHagimoto 0:0e0631af0305 199
RyoheiHagimoto 0:0e0631af0305 200 //! k-Means flags
RyoheiHagimoto 0:0e0631af0305 201 enum KmeansFlags {
RyoheiHagimoto 0:0e0631af0305 202 /** Select random initial centers in each attempt.*/
RyoheiHagimoto 0:0e0631af0305 203 KMEANS_RANDOM_CENTERS = 0,
RyoheiHagimoto 0:0e0631af0305 204 /** Use kmeans++ center initialization by Arthur and Vassilvitskii [Arthur2007].*/
RyoheiHagimoto 0:0e0631af0305 205 KMEANS_PP_CENTERS = 2,
RyoheiHagimoto 0:0e0631af0305 206 /** During the first (and possibly the only) attempt, use the
RyoheiHagimoto 0:0e0631af0305 207 user-supplied labels instead of computing them from the initial centers. For the second and
RyoheiHagimoto 0:0e0631af0305 208 further attempts, use the random or semi-random centers. Use one of KMEANS_\*_CENTERS flag
RyoheiHagimoto 0:0e0631af0305 209 to specify the exact method.*/
RyoheiHagimoto 0:0e0631af0305 210 KMEANS_USE_INITIAL_LABELS = 1
RyoheiHagimoto 0:0e0631af0305 211 };
RyoheiHagimoto 0:0e0631af0305 212
RyoheiHagimoto 0:0e0631af0305 213 //! type of line
RyoheiHagimoto 0:0e0631af0305 214 enum LineTypes {
RyoheiHagimoto 0:0e0631af0305 215 FILLED = -1,
RyoheiHagimoto 0:0e0631af0305 216 LINE_4 = 4, //!< 4-connected line
RyoheiHagimoto 0:0e0631af0305 217 LINE_8 = 8, //!< 8-connected line
RyoheiHagimoto 0:0e0631af0305 218 LINE_AA = 16 //!< antialiased line
RyoheiHagimoto 0:0e0631af0305 219 };
RyoheiHagimoto 0:0e0631af0305 220
RyoheiHagimoto 0:0e0631af0305 221 //! Only a subset of Hershey fonts
RyoheiHagimoto 0:0e0631af0305 222 //! <http://sources.isc.org/utils/misc/hershey-font.txt> are supported
RyoheiHagimoto 0:0e0631af0305 223 enum HersheyFonts {
RyoheiHagimoto 0:0e0631af0305 224 FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font
RyoheiHagimoto 0:0e0631af0305 225 FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font
RyoheiHagimoto 0:0e0631af0305 226 FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX)
RyoheiHagimoto 0:0e0631af0305 227 FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font
RyoheiHagimoto 0:0e0631af0305 228 FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX)
RyoheiHagimoto 0:0e0631af0305 229 FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX
RyoheiHagimoto 0:0e0631af0305 230 FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font
RyoheiHagimoto 0:0e0631af0305 231 FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX
RyoheiHagimoto 0:0e0631af0305 232 FONT_ITALIC = 16 //!< flag for italic font
RyoheiHagimoto 0:0e0631af0305 233 };
RyoheiHagimoto 0:0e0631af0305 234
RyoheiHagimoto 0:0e0631af0305 235 enum ReduceTypes { REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix.
RyoheiHagimoto 0:0e0631af0305 236 REDUCE_AVG = 1, //!< the output is the mean vector of all rows/columns of the matrix.
RyoheiHagimoto 0:0e0631af0305 237 REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all rows/columns of the matrix.
RyoheiHagimoto 0:0e0631af0305 238 REDUCE_MIN = 3 //!< the output is the minimum (column/row-wise) of all rows/columns of the matrix.
RyoheiHagimoto 0:0e0631af0305 239 };
RyoheiHagimoto 0:0e0631af0305 240
RyoheiHagimoto 0:0e0631af0305 241
RyoheiHagimoto 0:0e0631af0305 242 /** @brief Swaps two matrices
RyoheiHagimoto 0:0e0631af0305 243 */
RyoheiHagimoto 0:0e0631af0305 244 CV_EXPORTS void swap(Mat& a, Mat& b);
RyoheiHagimoto 0:0e0631af0305 245 /** @overload */
RyoheiHagimoto 0:0e0631af0305 246 CV_EXPORTS void swap( UMat& a, UMat& b );
RyoheiHagimoto 0:0e0631af0305 247
RyoheiHagimoto 0:0e0631af0305 248 //! @} core
RyoheiHagimoto 0:0e0631af0305 249
RyoheiHagimoto 0:0e0631af0305 250 //! @addtogroup core_array
RyoheiHagimoto 0:0e0631af0305 251 //! @{
RyoheiHagimoto 0:0e0631af0305 252
RyoheiHagimoto 0:0e0631af0305 253 /** @brief Computes the source location of an extrapolated pixel.
RyoheiHagimoto 0:0e0631af0305 254
RyoheiHagimoto 0:0e0631af0305 255 The function computes and returns the coordinate of a donor pixel corresponding to the specified
RyoheiHagimoto 0:0e0631af0305 256 extrapolated pixel when using the specified extrapolation border mode. For example, if you use
RyoheiHagimoto 0:0e0631af0305 257 cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and
RyoheiHagimoto 0:0e0631af0305 258 want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it
RyoheiHagimoto 0:0e0631af0305 259 looks like:
RyoheiHagimoto 0:0e0631af0305 260 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 261 float val = img.at<float>(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101),
RyoheiHagimoto 0:0e0631af0305 262 borderInterpolate(-5, img.cols, cv::BORDER_WRAP));
RyoheiHagimoto 0:0e0631af0305 263 @endcode
RyoheiHagimoto 0:0e0631af0305 264 Normally, the function is not called directly. It is used inside filtering functions and also in
RyoheiHagimoto 0:0e0631af0305 265 copyMakeBorder.
RyoheiHagimoto 0:0e0631af0305 266 @param p 0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or \>= len
RyoheiHagimoto 0:0e0631af0305 267 @param len Length of the array along the corresponding axis.
RyoheiHagimoto 0:0e0631af0305 268 @param borderType Border type, one of the cv::BorderTypes, except for cv::BORDER_TRANSPARENT and
RyoheiHagimoto 0:0e0631af0305 269 cv::BORDER_ISOLATED . When borderType==cv::BORDER_CONSTANT , the function always returns -1, regardless
RyoheiHagimoto 0:0e0631af0305 270 of p and len.
RyoheiHagimoto 0:0e0631af0305 271
RyoheiHagimoto 0:0e0631af0305 272 @sa copyMakeBorder
RyoheiHagimoto 0:0e0631af0305 273 */
RyoheiHagimoto 0:0e0631af0305 274 CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
RyoheiHagimoto 0:0e0631af0305 275
RyoheiHagimoto 0:0e0631af0305 276 /** @brief Forms a border around an image.
RyoheiHagimoto 0:0e0631af0305 277
RyoheiHagimoto 0:0e0631af0305 278 The function copies the source image into the middle of the destination image. The areas to the
RyoheiHagimoto 0:0e0631af0305 279 left, to the right, above and below the copied source image will be filled with extrapolated
RyoheiHagimoto 0:0e0631af0305 280 pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
RyoheiHagimoto 0:0e0631af0305 281 what other more complex functions, including your own, may do to simplify image boundary handling.
RyoheiHagimoto 0:0e0631af0305 282
RyoheiHagimoto 0:0e0631af0305 283 The function supports the mode when src is already in the middle of dst . In this case, the
RyoheiHagimoto 0:0e0631af0305 284 function does not copy src itself but simply constructs the border, for example:
RyoheiHagimoto 0:0e0631af0305 285
RyoheiHagimoto 0:0e0631af0305 286 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 287 // let border be the same in all directions
RyoheiHagimoto 0:0e0631af0305 288 int border=2;
RyoheiHagimoto 0:0e0631af0305 289 // constructs a larger image to fit both the image and the border
RyoheiHagimoto 0:0e0631af0305 290 Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
RyoheiHagimoto 0:0e0631af0305 291 // select the middle part of it w/o copying data
RyoheiHagimoto 0:0e0631af0305 292 Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
RyoheiHagimoto 0:0e0631af0305 293 // convert image from RGB to grayscale
RyoheiHagimoto 0:0e0631af0305 294 cvtColor(rgb, gray, COLOR_RGB2GRAY);
RyoheiHagimoto 0:0e0631af0305 295 // form a border in-place
RyoheiHagimoto 0:0e0631af0305 296 copyMakeBorder(gray, gray_buf, border, border,
RyoheiHagimoto 0:0e0631af0305 297 border, border, BORDER_REPLICATE);
RyoheiHagimoto 0:0e0631af0305 298 // now do some custom filtering ...
RyoheiHagimoto 0:0e0631af0305 299 ...
RyoheiHagimoto 0:0e0631af0305 300 @endcode
RyoheiHagimoto 0:0e0631af0305 301 @note When the source image is a part (ROI) of a bigger image, the function will try to use the
RyoheiHagimoto 0:0e0631af0305 302 pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
RyoheiHagimoto 0:0e0631af0305 303 if src was not a ROI, use borderType | BORDER_ISOLATED.
RyoheiHagimoto 0:0e0631af0305 304
RyoheiHagimoto 0:0e0631af0305 305 @param src Source image.
RyoheiHagimoto 0:0e0631af0305 306 @param dst Destination image of the same type as src and the size Size(src.cols+left+right,
RyoheiHagimoto 0:0e0631af0305 307 src.rows+top+bottom) .
RyoheiHagimoto 0:0e0631af0305 308 @param top
RyoheiHagimoto 0:0e0631af0305 309 @param bottom
RyoheiHagimoto 0:0e0631af0305 310 @param left
RyoheiHagimoto 0:0e0631af0305 311 @param right Parameter specifying how many pixels in each direction from the source image rectangle
RyoheiHagimoto 0:0e0631af0305 312 to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
RyoheiHagimoto 0:0e0631af0305 313 to be built.
RyoheiHagimoto 0:0e0631af0305 314 @param borderType Border type. See borderInterpolate for details.
RyoheiHagimoto 0:0e0631af0305 315 @param value Border value if borderType==BORDER_CONSTANT .
RyoheiHagimoto 0:0e0631af0305 316
RyoheiHagimoto 0:0e0631af0305 317 @sa borderInterpolate
RyoheiHagimoto 0:0e0631af0305 318 */
RyoheiHagimoto 0:0e0631af0305 319 CV_EXPORTS_W void copyMakeBorder(InputArray src, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 320 int top, int bottom, int left, int right,
RyoheiHagimoto 0:0e0631af0305 321 int borderType, const Scalar& value = Scalar() );
RyoheiHagimoto 0:0e0631af0305 322
RyoheiHagimoto 0:0e0631af0305 323 /** @brief Calculates the per-element sum of two arrays or an array and a scalar.
RyoheiHagimoto 0:0e0631af0305 324
RyoheiHagimoto 0:0e0631af0305 325 The function add calculates:
RyoheiHagimoto 0:0e0631af0305 326 - Sum of two arrays when both input arrays have the same size and the same number of channels:
RyoheiHagimoto 0:0e0631af0305 327 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 328 - Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
RyoheiHagimoto 0:0e0631af0305 329 elements as `src1.channels()`:
RyoheiHagimoto 0:0e0631af0305 330 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 331 - Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
RyoheiHagimoto 0:0e0631af0305 332 elements as `src2.channels()`:
RyoheiHagimoto 0:0e0631af0305 333 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 334 where `I` is a multi-dimensional index of array elements. In case of multi-channel arrays, each
RyoheiHagimoto 0:0e0631af0305 335 channel is processed independently.
RyoheiHagimoto 0:0e0631af0305 336
RyoheiHagimoto 0:0e0631af0305 337 The first function in the list above can be replaced with matrix expressions:
RyoheiHagimoto 0:0e0631af0305 338 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 339 dst = src1 + src2;
RyoheiHagimoto 0:0e0631af0305 340 dst += src1; // equivalent to add(dst, src1, dst);
RyoheiHagimoto 0:0e0631af0305 341 @endcode
RyoheiHagimoto 0:0e0631af0305 342 The input arrays and the output array can all have the same or different depths. For example, you
RyoheiHagimoto 0:0e0631af0305 343 can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
RyoheiHagimoto 0:0e0631af0305 344 floating-point array. Depth of the output array is determined by the dtype parameter. In the second
RyoheiHagimoto 0:0e0631af0305 345 and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
RyoheiHagimoto 0:0e0631af0305 346 be set to the default -1. In this case, the output array will have the same depth as the input
RyoheiHagimoto 0:0e0631af0305 347 array, be it src1, src2 or both.
RyoheiHagimoto 0:0e0631af0305 348 @note Saturation is not applied when the output array has the depth CV_32S. You may even get
RyoheiHagimoto 0:0e0631af0305 349 result of an incorrect sign in the case of overflow.
RyoheiHagimoto 0:0e0631af0305 350 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 351 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 352 @param dst output array that has the same size and number of channels as the input array(s); the
RyoheiHagimoto 0:0e0631af0305 353 depth is defined by dtype or src1/src2.
RyoheiHagimoto 0:0e0631af0305 354 @param mask optional operation mask - 8-bit single channel array, that specifies elements of the
RyoheiHagimoto 0:0e0631af0305 355 output array to be changed.
RyoheiHagimoto 0:0e0631af0305 356 @param dtype optional depth of the output array (see the discussion below).
RyoheiHagimoto 0:0e0631af0305 357 @sa subtract, addWeighted, scaleAdd, Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 358 */
RyoheiHagimoto 0:0e0631af0305 359 CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 360 InputArray mask = noArray(), int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 361
RyoheiHagimoto 0:0e0631af0305 362 /** @brief Calculates the per-element difference between two arrays or array and a scalar.
RyoheiHagimoto 0:0e0631af0305 363
RyoheiHagimoto 0:0e0631af0305 364 The function subtract calculates:
RyoheiHagimoto 0:0e0631af0305 365 - Difference between two arrays, when both input arrays have the same size and the same number of
RyoheiHagimoto 0:0e0631af0305 366 channels:
RyoheiHagimoto 0:0e0631af0305 367 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 368 - Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
RyoheiHagimoto 0:0e0631af0305 369 number of elements as `src1.channels()`:
RyoheiHagimoto 0:0e0631af0305 370 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 371 - Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
RyoheiHagimoto 0:0e0631af0305 372 number of elements as `src2.channels()`:
RyoheiHagimoto 0:0e0631af0305 373 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 374 - The reverse difference between a scalar and an array in the case of `SubRS`:
RyoheiHagimoto 0:0e0631af0305 375 \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 376 where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
RyoheiHagimoto 0:0e0631af0305 377 channel is processed independently.
RyoheiHagimoto 0:0e0631af0305 378
RyoheiHagimoto 0:0e0631af0305 379 The first function in the list above can be replaced with matrix expressions:
RyoheiHagimoto 0:0e0631af0305 380 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 381 dst = src1 - src2;
RyoheiHagimoto 0:0e0631af0305 382 dst -= src1; // equivalent to subtract(dst, src1, dst);
RyoheiHagimoto 0:0e0631af0305 383 @endcode
RyoheiHagimoto 0:0e0631af0305 384 The input arrays and the output array can all have the same or different depths. For example, you
RyoheiHagimoto 0:0e0631af0305 385 can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
RyoheiHagimoto 0:0e0631af0305 386 the output array is determined by dtype parameter. In the second and third cases above, as well as
RyoheiHagimoto 0:0e0631af0305 387 in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
RyoheiHagimoto 0:0e0631af0305 388 case the output array will have the same depth as the input array, be it src1, src2 or both.
RyoheiHagimoto 0:0e0631af0305 389 @note Saturation is not applied when the output array has the depth CV_32S. You may even get
RyoheiHagimoto 0:0e0631af0305 390 result of an incorrect sign in the case of overflow.
RyoheiHagimoto 0:0e0631af0305 391 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 392 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 393 @param dst output array of the same size and the same number of channels as the input array.
RyoheiHagimoto 0:0e0631af0305 394 @param mask optional operation mask; this is an 8-bit single channel array that specifies elements
RyoheiHagimoto 0:0e0631af0305 395 of the output array to be changed.
RyoheiHagimoto 0:0e0631af0305 396 @param dtype optional depth of the output array
RyoheiHagimoto 0:0e0631af0305 397 @sa add, addWeighted, scaleAdd, Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 398 */
RyoheiHagimoto 0:0e0631af0305 399 CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 400 InputArray mask = noArray(), int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 401
RyoheiHagimoto 0:0e0631af0305 402
RyoheiHagimoto 0:0e0631af0305 403 /** @brief Calculates the per-element scaled product of two arrays.
RyoheiHagimoto 0:0e0631af0305 404
RyoheiHagimoto 0:0e0631af0305 405 The function multiply calculates the per-element product of two arrays:
RyoheiHagimoto 0:0e0631af0305 406
RyoheiHagimoto 0:0e0631af0305 407 \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\f]
RyoheiHagimoto 0:0e0631af0305 408
RyoheiHagimoto 0:0e0631af0305 409 There is also a @ref MatrixExpressions -friendly variant of the first function. See Mat::mul .
RyoheiHagimoto 0:0e0631af0305 410
RyoheiHagimoto 0:0e0631af0305 411 For a not-per-element matrix product, see gemm .
RyoheiHagimoto 0:0e0631af0305 412
RyoheiHagimoto 0:0e0631af0305 413 @note Saturation is not applied when the output array has the depth
RyoheiHagimoto 0:0e0631af0305 414 CV_32S. You may even get result of an incorrect sign in the case of
RyoheiHagimoto 0:0e0631af0305 415 overflow.
RyoheiHagimoto 0:0e0631af0305 416 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 417 @param src2 second input array of the same size and the same type as src1.
RyoheiHagimoto 0:0e0631af0305 418 @param dst output array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 419 @param scale optional scale factor.
RyoheiHagimoto 0:0e0631af0305 420 @param dtype optional depth of the output array
RyoheiHagimoto 0:0e0631af0305 421 @sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
RyoheiHagimoto 0:0e0631af0305 422 Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 423 */
RyoheiHagimoto 0:0e0631af0305 424 CV_EXPORTS_W void multiply(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 425 OutputArray dst, double scale = 1, int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 426
RyoheiHagimoto 0:0e0631af0305 427 /** @brief Performs per-element division of two arrays or a scalar by an array.
RyoheiHagimoto 0:0e0631af0305 428
RyoheiHagimoto 0:0e0631af0305 429 The function cv::divide divides one array by another:
RyoheiHagimoto 0:0e0631af0305 430 \f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
RyoheiHagimoto 0:0e0631af0305 431 or a scalar by an array when there is no src1 :
RyoheiHagimoto 0:0e0631af0305 432 \f[\texttt{dst(I) = saturate(scale/src2(I))}\f]
RyoheiHagimoto 0:0e0631af0305 433
RyoheiHagimoto 0:0e0631af0305 434 When src2(I) is zero, dst(I) will also be zero. Different channels of
RyoheiHagimoto 0:0e0631af0305 435 multi-channel arrays are processed independently.
RyoheiHagimoto 0:0e0631af0305 436
RyoheiHagimoto 0:0e0631af0305 437 @note Saturation is not applied when the output array has the depth CV_32S. You may even get
RyoheiHagimoto 0:0e0631af0305 438 result of an incorrect sign in the case of overflow.
RyoheiHagimoto 0:0e0631af0305 439 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 440 @param src2 second input array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 441 @param scale scalar factor.
RyoheiHagimoto 0:0e0631af0305 442 @param dst output array of the same size and type as src2.
RyoheiHagimoto 0:0e0631af0305 443 @param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in
RyoheiHagimoto 0:0e0631af0305 444 case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
RyoheiHagimoto 0:0e0631af0305 445 @sa multiply, add, subtract
RyoheiHagimoto 0:0e0631af0305 446 */
RyoheiHagimoto 0:0e0631af0305 447 CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 448 double scale = 1, int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 449
RyoheiHagimoto 0:0e0631af0305 450 /** @overload */
RyoheiHagimoto 0:0e0631af0305 451 CV_EXPORTS_W void divide(double scale, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 452 OutputArray dst, int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 453
RyoheiHagimoto 0:0e0631af0305 454 /** @brief Calculates the sum of a scaled array and another array.
RyoheiHagimoto 0:0e0631af0305 455
RyoheiHagimoto 0:0e0631af0305 456 The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY
RyoheiHagimoto 0:0e0631af0305 457 or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates
RyoheiHagimoto 0:0e0631af0305 458 the sum of a scaled array and another array:
RyoheiHagimoto 0:0e0631af0305 459 \f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\f]
RyoheiHagimoto 0:0e0631af0305 460 The function can also be emulated with a matrix expression, for example:
RyoheiHagimoto 0:0e0631af0305 461 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 462 Mat A(3, 3, CV_64F);
RyoheiHagimoto 0:0e0631af0305 463 ...
RyoheiHagimoto 0:0e0631af0305 464 A.row(0) = A.row(1)*2 + A.row(2);
RyoheiHagimoto 0:0e0631af0305 465 @endcode
RyoheiHagimoto 0:0e0631af0305 466 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 467 @param alpha scale factor for the first array.
RyoheiHagimoto 0:0e0631af0305 468 @param src2 second input array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 469 @param dst output array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 470 @sa add, addWeighted, subtract, Mat::dot, Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 471 */
RyoheiHagimoto 0:0e0631af0305 472 CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 473
RyoheiHagimoto 0:0e0631af0305 474 /** @brief Calculates the weighted sum of two arrays.
RyoheiHagimoto 0:0e0631af0305 475
RyoheiHagimoto 0:0e0631af0305 476 The function addWeighted calculates the weighted sum of two arrays as follows:
RyoheiHagimoto 0:0e0631af0305 477 \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f]
RyoheiHagimoto 0:0e0631af0305 478 where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
RyoheiHagimoto 0:0e0631af0305 479 channel is processed independently.
RyoheiHagimoto 0:0e0631af0305 480 The function can be replaced with a matrix expression:
RyoheiHagimoto 0:0e0631af0305 481 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 482 dst = src1*alpha + src2*beta + gamma;
RyoheiHagimoto 0:0e0631af0305 483 @endcode
RyoheiHagimoto 0:0e0631af0305 484 @note Saturation is not applied when the output array has the depth CV_32S. You may even get
RyoheiHagimoto 0:0e0631af0305 485 result of an incorrect sign in the case of overflow.
RyoheiHagimoto 0:0e0631af0305 486 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 487 @param alpha weight of the first array elements.
RyoheiHagimoto 0:0e0631af0305 488 @param src2 second input array of the same size and channel number as src1.
RyoheiHagimoto 0:0e0631af0305 489 @param beta weight of the second array elements.
RyoheiHagimoto 0:0e0631af0305 490 @param gamma scalar added to each sum.
RyoheiHagimoto 0:0e0631af0305 491 @param dst output array that has the same size and number of channels as the input arrays.
RyoheiHagimoto 0:0e0631af0305 492 @param dtype optional depth of the output array; when both input arrays have the same depth, dtype
RyoheiHagimoto 0:0e0631af0305 493 can be set to -1, which will be equivalent to src1.depth().
RyoheiHagimoto 0:0e0631af0305 494 @sa add, subtract, scaleAdd, Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 495 */
RyoheiHagimoto 0:0e0631af0305 496 CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 497 double beta, double gamma, OutputArray dst, int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 498
RyoheiHagimoto 0:0e0631af0305 499 /** @brief Scales, calculates absolute values, and converts the result to 8-bit.
RyoheiHagimoto 0:0e0631af0305 500
RyoheiHagimoto 0:0e0631af0305 501 On each element of the input array, the function convertScaleAbs
RyoheiHagimoto 0:0e0631af0305 502 performs three operations sequentially: scaling, taking an absolute
RyoheiHagimoto 0:0e0631af0305 503 value, conversion to an unsigned 8-bit type:
RyoheiHagimoto 0:0e0631af0305 504 \f[\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\f]
RyoheiHagimoto 0:0e0631af0305 505 In case of multi-channel arrays, the function processes each channel
RyoheiHagimoto 0:0e0631af0305 506 independently. When the output is not 8-bit, the operation can be
RyoheiHagimoto 0:0e0631af0305 507 emulated by calling the Mat::convertTo method (or by using matrix
RyoheiHagimoto 0:0e0631af0305 508 expressions) and then by calculating an absolute value of the result.
RyoheiHagimoto 0:0e0631af0305 509 For example:
RyoheiHagimoto 0:0e0631af0305 510 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 511 Mat_<float> A(30,30);
RyoheiHagimoto 0:0e0631af0305 512 randu(A, Scalar(-100), Scalar(100));
RyoheiHagimoto 0:0e0631af0305 513 Mat_<float> B = A*5 + 3;
RyoheiHagimoto 0:0e0631af0305 514 B = abs(B);
RyoheiHagimoto 0:0e0631af0305 515 // Mat_<float> B = abs(A*5+3) will also do the job,
RyoheiHagimoto 0:0e0631af0305 516 // but it will allocate a temporary matrix
RyoheiHagimoto 0:0e0631af0305 517 @endcode
RyoheiHagimoto 0:0e0631af0305 518 @param src input array.
RyoheiHagimoto 0:0e0631af0305 519 @param dst output array.
RyoheiHagimoto 0:0e0631af0305 520 @param alpha optional scale factor.
RyoheiHagimoto 0:0e0631af0305 521 @param beta optional delta added to the scaled values.
RyoheiHagimoto 0:0e0631af0305 522 @sa Mat::convertTo, cv::abs(const Mat&)
RyoheiHagimoto 0:0e0631af0305 523 */
RyoheiHagimoto 0:0e0631af0305 524 CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 525 double alpha = 1, double beta = 0);
RyoheiHagimoto 0:0e0631af0305 526
RyoheiHagimoto 0:0e0631af0305 527 /** @brief Converts an array to half precision floating number.
RyoheiHagimoto 0:0e0631af0305 528
RyoheiHagimoto 0:0e0631af0305 529 This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). The input array has to have type of CV_32F or
RyoheiHagimoto 0:0e0631af0305 530 CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
RyoheiHagimoto 0:0e0631af0305 531 The format of half precision floating point is defined in IEEE 754-2008.
RyoheiHagimoto 0:0e0631af0305 532
RyoheiHagimoto 0:0e0631af0305 533 @param src input array.
RyoheiHagimoto 0:0e0631af0305 534 @param dst output array.
RyoheiHagimoto 0:0e0631af0305 535 */
RyoheiHagimoto 0:0e0631af0305 536 CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 537
RyoheiHagimoto 0:0e0631af0305 538 /** @brief Performs a look-up table transform of an array.
RyoheiHagimoto 0:0e0631af0305 539
RyoheiHagimoto 0:0e0631af0305 540 The function LUT fills the output array with values from the look-up table. Indices of the entries
RyoheiHagimoto 0:0e0631af0305 541 are taken from the input array. That is, the function processes each element of src as follows:
RyoheiHagimoto 0:0e0631af0305 542 \f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\f]
RyoheiHagimoto 0:0e0631af0305 543 where
RyoheiHagimoto 0:0e0631af0305 544 \f[d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\f]
RyoheiHagimoto 0:0e0631af0305 545 @param src input array of 8-bit elements.
RyoheiHagimoto 0:0e0631af0305 546 @param lut look-up table of 256 elements; in case of multi-channel input array, the table should
RyoheiHagimoto 0:0e0631af0305 547 either have a single channel (in this case the same table is used for all channels) or the same
RyoheiHagimoto 0:0e0631af0305 548 number of channels as in the input array.
RyoheiHagimoto 0:0e0631af0305 549 @param dst output array of the same size and number of channels as src, and the same depth as lut.
RyoheiHagimoto 0:0e0631af0305 550 @sa convertScaleAbs, Mat::convertTo
RyoheiHagimoto 0:0e0631af0305 551 */
RyoheiHagimoto 0:0e0631af0305 552 CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 553
RyoheiHagimoto 0:0e0631af0305 554 /** @brief Calculates the sum of array elements.
RyoheiHagimoto 0:0e0631af0305 555
RyoheiHagimoto 0:0e0631af0305 556 The function cv::sum calculates and returns the sum of array elements,
RyoheiHagimoto 0:0e0631af0305 557 independently for each channel.
RyoheiHagimoto 0:0e0631af0305 558 @param src input array that must have from 1 to 4 channels.
RyoheiHagimoto 0:0e0631af0305 559 @sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
RyoheiHagimoto 0:0e0631af0305 560 */
RyoheiHagimoto 0:0e0631af0305 561 CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src);
RyoheiHagimoto 0:0e0631af0305 562
RyoheiHagimoto 0:0e0631af0305 563 /** @brief Counts non-zero array elements.
RyoheiHagimoto 0:0e0631af0305 564
RyoheiHagimoto 0:0e0631af0305 565 The function returns the number of non-zero elements in src :
RyoheiHagimoto 0:0e0631af0305 566 \f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f]
RyoheiHagimoto 0:0e0631af0305 567 @param src single-channel array.
RyoheiHagimoto 0:0e0631af0305 568 @sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
RyoheiHagimoto 0:0e0631af0305 569 */
RyoheiHagimoto 0:0e0631af0305 570 CV_EXPORTS_W int countNonZero( InputArray src );
RyoheiHagimoto 0:0e0631af0305 571
RyoheiHagimoto 0:0e0631af0305 572 /** @brief Returns the list of locations of non-zero pixels
RyoheiHagimoto 0:0e0631af0305 573
RyoheiHagimoto 0:0e0631af0305 574 Given a binary matrix (likely returned from an operation such
RyoheiHagimoto 0:0e0631af0305 575 as threshold(), compare(), >, ==, etc, return all of
RyoheiHagimoto 0:0e0631af0305 576 the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
RyoheiHagimoto 0:0e0631af0305 577 For example:
RyoheiHagimoto 0:0e0631af0305 578 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 579 cv::Mat binaryImage; // input, binary image
RyoheiHagimoto 0:0e0631af0305 580 cv::Mat locations; // output, locations of non-zero pixels
RyoheiHagimoto 0:0e0631af0305 581 cv::findNonZero(binaryImage, locations);
RyoheiHagimoto 0:0e0631af0305 582
RyoheiHagimoto 0:0e0631af0305 583 // access pixel coordinates
RyoheiHagimoto 0:0e0631af0305 584 Point pnt = locations.at<Point>(i);
RyoheiHagimoto 0:0e0631af0305 585 @endcode
RyoheiHagimoto 0:0e0631af0305 586 or
RyoheiHagimoto 0:0e0631af0305 587 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 588 cv::Mat binaryImage; // input, binary image
RyoheiHagimoto 0:0e0631af0305 589 vector<Point> locations; // output, locations of non-zero pixels
RyoheiHagimoto 0:0e0631af0305 590 cv::findNonZero(binaryImage, locations);
RyoheiHagimoto 0:0e0631af0305 591
RyoheiHagimoto 0:0e0631af0305 592 // access pixel coordinates
RyoheiHagimoto 0:0e0631af0305 593 Point pnt = locations[i];
RyoheiHagimoto 0:0e0631af0305 594 @endcode
RyoheiHagimoto 0:0e0631af0305 595 @param src single-channel array (type CV_8UC1)
RyoheiHagimoto 0:0e0631af0305 596 @param idx the output array, type of cv::Mat or std::vector<Point>, corresponding to non-zero indices in the input
RyoheiHagimoto 0:0e0631af0305 597 */
RyoheiHagimoto 0:0e0631af0305 598 CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );
RyoheiHagimoto 0:0e0631af0305 599
RyoheiHagimoto 0:0e0631af0305 600 /** @brief Calculates an average (mean) of array elements.
RyoheiHagimoto 0:0e0631af0305 601
RyoheiHagimoto 0:0e0631af0305 602 The function cv::mean calculates the mean value M of array elements,
RyoheiHagimoto 0:0e0631af0305 603 independently for each channel, and return it:
RyoheiHagimoto 0:0e0631af0305 604 \f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 605 When all the mask elements are 0's, the function returns Scalar::all(0)
RyoheiHagimoto 0:0e0631af0305 606 @param src input array that should have from 1 to 4 channels so that the result can be stored in
RyoheiHagimoto 0:0e0631af0305 607 Scalar_ .
RyoheiHagimoto 0:0e0631af0305 608 @param mask optional operation mask.
RyoheiHagimoto 0:0e0631af0305 609 @sa countNonZero, meanStdDev, norm, minMaxLoc
RyoheiHagimoto 0:0e0631af0305 610 */
RyoheiHagimoto 0:0e0631af0305 611 CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 612
RyoheiHagimoto 0:0e0631af0305 613 /** Calculates a mean and standard deviation of array elements.
RyoheiHagimoto 0:0e0631af0305 614
RyoheiHagimoto 0:0e0631af0305 615 The function cv::meanStdDev calculates the mean and the standard deviation M
RyoheiHagimoto 0:0e0631af0305 616 of array elements independently for each channel and returns it via the
RyoheiHagimoto 0:0e0631af0305 617 output parameters:
RyoheiHagimoto 0:0e0631af0305 618 \f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 619 When all the mask elements are 0's, the function returns
RyoheiHagimoto 0:0e0631af0305 620 mean=stddev=Scalar::all(0).
RyoheiHagimoto 0:0e0631af0305 621 @note The calculated standard deviation is only the diagonal of the
RyoheiHagimoto 0:0e0631af0305 622 complete normalized covariance matrix. If the full matrix is needed, you
RyoheiHagimoto 0:0e0631af0305 623 can reshape the multi-channel array M x N to the single-channel array
RyoheiHagimoto 0:0e0631af0305 624 M\*N x mtx.channels() (only possible when the matrix is continuous) and
RyoheiHagimoto 0:0e0631af0305 625 then pass the matrix to calcCovarMatrix .
RyoheiHagimoto 0:0e0631af0305 626 @param src input array that should have from 1 to 4 channels so that the results can be stored in
RyoheiHagimoto 0:0e0631af0305 627 Scalar_ 's.
RyoheiHagimoto 0:0e0631af0305 628 @param mean output parameter: calculated mean value.
RyoheiHagimoto 0:0e0631af0305 629 @param stddev output parameter: calculateded standard deviation.
RyoheiHagimoto 0:0e0631af0305 630 @param mask optional operation mask.
RyoheiHagimoto 0:0e0631af0305 631 @sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
RyoheiHagimoto 0:0e0631af0305 632 */
RyoheiHagimoto 0:0e0631af0305 633 CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,
RyoheiHagimoto 0:0e0631af0305 634 InputArray mask=noArray());
RyoheiHagimoto 0:0e0631af0305 635
RyoheiHagimoto 0:0e0631af0305 636 /** @brief Calculates an absolute array norm, an absolute difference norm, or a
RyoheiHagimoto 0:0e0631af0305 637 relative difference norm.
RyoheiHagimoto 0:0e0631af0305 638
RyoheiHagimoto 0:0e0631af0305 639 The function cv::norm calculates an absolute norm of src1 (when there is no
RyoheiHagimoto 0:0e0631af0305 640 src2 ):
RyoheiHagimoto 0:0e0631af0305 641
RyoheiHagimoto 0:0e0631af0305 642 \f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
RyoheiHagimoto 0:0e0631af0305 643 { \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
RyoheiHagimoto 0:0e0631af0305 644 { \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 645
RyoheiHagimoto 0:0e0631af0305 646 or an absolute or relative difference norm if src2 is there:
RyoheiHagimoto 0:0e0631af0305 647
RyoheiHagimoto 0:0e0631af0305 648 \f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
RyoheiHagimoto 0:0e0631af0305 649 { \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
RyoheiHagimoto 0:0e0631af0305 650 { \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 651
RyoheiHagimoto 0:0e0631af0305 652 or
RyoheiHagimoto 0:0e0631af0305 653
RyoheiHagimoto 0:0e0631af0305 654 \f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
RyoheiHagimoto 0:0e0631af0305 655 { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
RyoheiHagimoto 0:0e0631af0305 656 { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
RyoheiHagimoto 0:0e0631af0305 657
RyoheiHagimoto 0:0e0631af0305 658 The function cv::norm returns the calculated norm.
RyoheiHagimoto 0:0e0631af0305 659
RyoheiHagimoto 0:0e0631af0305 660 When the mask parameter is specified and it is not empty, the norm is
RyoheiHagimoto 0:0e0631af0305 661 calculated only over the region specified by the mask.
RyoheiHagimoto 0:0e0631af0305 662
RyoheiHagimoto 0:0e0631af0305 663 A multi-channel input arrays are treated as a single-channel, that is,
RyoheiHagimoto 0:0e0631af0305 664 the results for all channels are combined.
RyoheiHagimoto 0:0e0631af0305 665
RyoheiHagimoto 0:0e0631af0305 666 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 667 @param normType type of the norm (see cv::NormTypes).
RyoheiHagimoto 0:0e0631af0305 668 @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
RyoheiHagimoto 0:0e0631af0305 669 */
RyoheiHagimoto 0:0e0631af0305 670 CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 671
RyoheiHagimoto 0:0e0631af0305 672 /** @overload
RyoheiHagimoto 0:0e0631af0305 673 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 674 @param src2 second input array of the same size and the same type as src1.
RyoheiHagimoto 0:0e0631af0305 675 @param normType type of the norm (cv::NormTypes).
RyoheiHagimoto 0:0e0631af0305 676 @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
RyoheiHagimoto 0:0e0631af0305 677 */
RyoheiHagimoto 0:0e0631af0305 678 CV_EXPORTS_W double norm(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 679 int normType = NORM_L2, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 680 /** @overload
RyoheiHagimoto 0:0e0631af0305 681 @param src first input array.
RyoheiHagimoto 0:0e0631af0305 682 @param normType type of the norm (see cv::NormTypes).
RyoheiHagimoto 0:0e0631af0305 683 */
RyoheiHagimoto 0:0e0631af0305 684 CV_EXPORTS double norm( const SparseMat& src, int normType );
RyoheiHagimoto 0:0e0631af0305 685
RyoheiHagimoto 0:0e0631af0305 686 /** @brief computes PSNR image/video quality metric
RyoheiHagimoto 0:0e0631af0305 687
RyoheiHagimoto 0:0e0631af0305 688 see http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio for details
RyoheiHagimoto 0:0e0631af0305 689 @todo document
RyoheiHagimoto 0:0e0631af0305 690 */
RyoheiHagimoto 0:0e0631af0305 691 CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2);
RyoheiHagimoto 0:0e0631af0305 692
RyoheiHagimoto 0:0e0631af0305 693 /** @brief naive nearest neighbor finder
RyoheiHagimoto 0:0e0631af0305 694
RyoheiHagimoto 0:0e0631af0305 695 see http://en.wikipedia.org/wiki/Nearest_neighbor_search
RyoheiHagimoto 0:0e0631af0305 696 @todo document
RyoheiHagimoto 0:0e0631af0305 697 */
RyoheiHagimoto 0:0e0631af0305 698 CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 699 OutputArray dist, int dtype, OutputArray nidx,
RyoheiHagimoto 0:0e0631af0305 700 int normType = NORM_L2, int K = 0,
RyoheiHagimoto 0:0e0631af0305 701 InputArray mask = noArray(), int update = 0,
RyoheiHagimoto 0:0e0631af0305 702 bool crosscheck = false);
RyoheiHagimoto 0:0e0631af0305 703
RyoheiHagimoto 0:0e0631af0305 704 /** @brief Normalizes the norm or value range of an array.
RyoheiHagimoto 0:0e0631af0305 705
RyoheiHagimoto 0:0e0631af0305 706 The function cv::normalize normalizes scale and shift the input array elements so that
RyoheiHagimoto 0:0e0631af0305 707 \f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f]
RyoheiHagimoto 0:0e0631af0305 708 (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
RyoheiHagimoto 0:0e0631af0305 709 \f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f]
RyoheiHagimoto 0:0e0631af0305 710
RyoheiHagimoto 0:0e0631af0305 711 when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
RyoheiHagimoto 0:0e0631af0305 712 normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
RyoheiHagimoto 0:0e0631af0305 713 sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
RyoheiHagimoto 0:0e0631af0305 714 min-max but modify the whole array, you can use norm and Mat::convertTo.
RyoheiHagimoto 0:0e0631af0305 715
RyoheiHagimoto 0:0e0631af0305 716 In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
RyoheiHagimoto 0:0e0631af0305 717 the range transformation for sparse matrices is not allowed since it can shift the zero level.
RyoheiHagimoto 0:0e0631af0305 718
RyoheiHagimoto 0:0e0631af0305 719 Possible usage with some positive example data:
RyoheiHagimoto 0:0e0631af0305 720 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 721 vector<double> positiveData = { 2.0, 8.0, 10.0 };
RyoheiHagimoto 0:0e0631af0305 722 vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
RyoheiHagimoto 0:0e0631af0305 723
RyoheiHagimoto 0:0e0631af0305 724 // Norm to probability (total count)
RyoheiHagimoto 0:0e0631af0305 725 // sum(numbers) = 20.0
RyoheiHagimoto 0:0e0631af0305 726 // 2.0 0.1 (2.0/20.0)
RyoheiHagimoto 0:0e0631af0305 727 // 8.0 0.4 (8.0/20.0)
RyoheiHagimoto 0:0e0631af0305 728 // 10.0 0.5 (10.0/20.0)
RyoheiHagimoto 0:0e0631af0305 729 normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
RyoheiHagimoto 0:0e0631af0305 730
RyoheiHagimoto 0:0e0631af0305 731 // Norm to unit vector: ||positiveData|| = 1.0
RyoheiHagimoto 0:0e0631af0305 732 // 2.0 0.15
RyoheiHagimoto 0:0e0631af0305 733 // 8.0 0.62
RyoheiHagimoto 0:0e0631af0305 734 // 10.0 0.77
RyoheiHagimoto 0:0e0631af0305 735 normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
RyoheiHagimoto 0:0e0631af0305 736
RyoheiHagimoto 0:0e0631af0305 737 // Norm to max element
RyoheiHagimoto 0:0e0631af0305 738 // 2.0 0.2 (2.0/10.0)
RyoheiHagimoto 0:0e0631af0305 739 // 8.0 0.8 (8.0/10.0)
RyoheiHagimoto 0:0e0631af0305 740 // 10.0 1.0 (10.0/10.0)
RyoheiHagimoto 0:0e0631af0305 741 normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
RyoheiHagimoto 0:0e0631af0305 742
RyoheiHagimoto 0:0e0631af0305 743 // Norm to range [0.0;1.0]
RyoheiHagimoto 0:0e0631af0305 744 // 2.0 0.0 (shift to left border)
RyoheiHagimoto 0:0e0631af0305 745 // 8.0 0.75 (6.0/8.0)
RyoheiHagimoto 0:0e0631af0305 746 // 10.0 1.0 (shift to right border)
RyoheiHagimoto 0:0e0631af0305 747 normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
RyoheiHagimoto 0:0e0631af0305 748 @endcode
RyoheiHagimoto 0:0e0631af0305 749
RyoheiHagimoto 0:0e0631af0305 750 @param src input array.
RyoheiHagimoto 0:0e0631af0305 751 @param dst output array of the same size as src .
RyoheiHagimoto 0:0e0631af0305 752 @param alpha norm value to normalize to or the lower range boundary in case of the range
RyoheiHagimoto 0:0e0631af0305 753 normalization.
RyoheiHagimoto 0:0e0631af0305 754 @param beta upper range boundary in case of the range normalization; it is not used for the norm
RyoheiHagimoto 0:0e0631af0305 755 normalization.
RyoheiHagimoto 0:0e0631af0305 756 @param norm_type normalization type (see cv::NormTypes).
RyoheiHagimoto 0:0e0631af0305 757 @param dtype when negative, the output array has the same type as src; otherwise, it has the same
RyoheiHagimoto 0:0e0631af0305 758 number of channels as src and the depth =CV_MAT_DEPTH(dtype).
RyoheiHagimoto 0:0e0631af0305 759 @param mask optional operation mask.
RyoheiHagimoto 0:0e0631af0305 760 @sa norm, Mat::convertTo, SparseMat::convertTo
RyoheiHagimoto 0:0e0631af0305 761 */
RyoheiHagimoto 0:0e0631af0305 762 CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0,
RyoheiHagimoto 0:0e0631af0305 763 int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 764
RyoheiHagimoto 0:0e0631af0305 765 /** @overload
RyoheiHagimoto 0:0e0631af0305 766 @param src input array.
RyoheiHagimoto 0:0e0631af0305 767 @param dst output array of the same size as src .
RyoheiHagimoto 0:0e0631af0305 768 @param alpha norm value to normalize to or the lower range boundary in case of the range
RyoheiHagimoto 0:0e0631af0305 769 normalization.
RyoheiHagimoto 0:0e0631af0305 770 @param normType normalization type (see cv::NormTypes).
RyoheiHagimoto 0:0e0631af0305 771 */
RyoheiHagimoto 0:0e0631af0305 772 CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, int normType );
RyoheiHagimoto 0:0e0631af0305 773
RyoheiHagimoto 0:0e0631af0305 774 /** @brief Finds the global minimum and maximum in an array.
RyoheiHagimoto 0:0e0631af0305 775
RyoheiHagimoto 0:0e0631af0305 776 The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The
RyoheiHagimoto 0:0e0631af0305 777 extremums are searched across the whole array or, if mask is not an empty array, in the specified
RyoheiHagimoto 0:0e0631af0305 778 array region.
RyoheiHagimoto 0:0e0631af0305 779
RyoheiHagimoto 0:0e0631af0305 780 The function do not work with multi-channel arrays. If you need to find minimum or maximum
RyoheiHagimoto 0:0e0631af0305 781 elements across all the channels, use Mat::reshape first to reinterpret the array as
RyoheiHagimoto 0:0e0631af0305 782 single-channel. Or you may extract the particular channel using either extractImageCOI , or
RyoheiHagimoto 0:0e0631af0305 783 mixChannels , or split .
RyoheiHagimoto 0:0e0631af0305 784 @param src input single-channel array.
RyoheiHagimoto 0:0e0631af0305 785 @param minVal pointer to the returned minimum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 786 @param maxVal pointer to the returned maximum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 787 @param minLoc pointer to the returned minimum location (in 2D case); NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 788 @param maxLoc pointer to the returned maximum location (in 2D case); NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 789 @param mask optional mask used to select a sub-array.
RyoheiHagimoto 0:0e0631af0305 790 @sa max, min, compare, inRange, extractImageCOI, mixChannels, split, Mat::reshape
RyoheiHagimoto 0:0e0631af0305 791 */
RyoheiHagimoto 0:0e0631af0305 792 CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal,
RyoheiHagimoto 0:0e0631af0305 793 CV_OUT double* maxVal = 0, CV_OUT Point* minLoc = 0,
RyoheiHagimoto 0:0e0631af0305 794 CV_OUT Point* maxLoc = 0, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 795
RyoheiHagimoto 0:0e0631af0305 796
RyoheiHagimoto 0:0e0631af0305 797 /** @brief Finds the global minimum and maximum in an array
RyoheiHagimoto 0:0e0631af0305 798
RyoheiHagimoto 0:0e0631af0305 799 The function cv::minMaxIdx finds the minimum and maximum element values and their positions. The
RyoheiHagimoto 0:0e0631af0305 800 extremums are searched across the whole array or, if mask is not an empty array, in the specified
RyoheiHagimoto 0:0e0631af0305 801 array region. The function does not work with multi-channel arrays. If you need to find minimum or
RyoheiHagimoto 0:0e0631af0305 802 maximum elements across all the channels, use Mat::reshape first to reinterpret the array as
RyoheiHagimoto 0:0e0631af0305 803 single-channel. Or you may extract the particular channel using either extractImageCOI , or
RyoheiHagimoto 0:0e0631af0305 804 mixChannels , or split . In case of a sparse matrix, the minimum is found among non-zero elements
RyoheiHagimoto 0:0e0631af0305 805 only.
RyoheiHagimoto 0:0e0631af0305 806 @note When minIdx is not NULL, it must have at least 2 elements (as well as maxIdx), even if src is
RyoheiHagimoto 0:0e0631af0305 807 a single-row or single-column matrix. In OpenCV (following MATLAB) each array has at least 2
RyoheiHagimoto 0:0e0631af0305 808 dimensions, i.e. single-column matrix is Mx1 matrix (and therefore minIdx/maxIdx will be
RyoheiHagimoto 0:0e0631af0305 809 (i1,0)/(i2,0)) and single-row matrix is 1xN matrix (and therefore minIdx/maxIdx will be
RyoheiHagimoto 0:0e0631af0305 810 (0,j1)/(0,j2)).
RyoheiHagimoto 0:0e0631af0305 811 @param src input single-channel array.
RyoheiHagimoto 0:0e0631af0305 812 @param minVal pointer to the returned minimum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 813 @param maxVal pointer to the returned maximum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 814 @param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required;
RyoheiHagimoto 0:0e0631af0305 815 Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element
RyoheiHagimoto 0:0e0631af0305 816 in each dimension are stored there sequentially.
RyoheiHagimoto 0:0e0631af0305 817 @param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 818 @param mask specified array region
RyoheiHagimoto 0:0e0631af0305 819 */
RyoheiHagimoto 0:0e0631af0305 820 CV_EXPORTS void minMaxIdx(InputArray src, double* minVal, double* maxVal = 0,
RyoheiHagimoto 0:0e0631af0305 821 int* minIdx = 0, int* maxIdx = 0, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 822
RyoheiHagimoto 0:0e0631af0305 823 /** @overload
RyoheiHagimoto 0:0e0631af0305 824 @param a input single-channel array.
RyoheiHagimoto 0:0e0631af0305 825 @param minVal pointer to the returned minimum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 826 @param maxVal pointer to the returned maximum value; NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 827 @param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required;
RyoheiHagimoto 0:0e0631af0305 828 Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element
RyoheiHagimoto 0:0e0631af0305 829 in each dimension are stored there sequentially.
RyoheiHagimoto 0:0e0631af0305 830 @param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required.
RyoheiHagimoto 0:0e0631af0305 831 */
RyoheiHagimoto 0:0e0631af0305 832 CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal,
RyoheiHagimoto 0:0e0631af0305 833 double* maxVal, int* minIdx = 0, int* maxIdx = 0);
RyoheiHagimoto 0:0e0631af0305 834
RyoheiHagimoto 0:0e0631af0305 835 /** @brief Reduces a matrix to a vector.
RyoheiHagimoto 0:0e0631af0305 836
RyoheiHagimoto 0:0e0631af0305 837 The function cv::reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
RyoheiHagimoto 0:0e0631af0305 838 1D vectors and performing the specified operation on the vectors until a single row/column is
RyoheiHagimoto 0:0e0631af0305 839 obtained. For example, the function can be used to compute horizontal and vertical projections of a
RyoheiHagimoto 0:0e0631af0305 840 raster image. In case of REDUCE_MAX and REDUCE_MIN , the output image should have the same type as the source one.
RyoheiHagimoto 0:0e0631af0305 841 In case of REDUCE_SUM and REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
RyoheiHagimoto 0:0e0631af0305 842 And multi-channel arrays are also supported in these two reduction modes.
RyoheiHagimoto 0:0e0631af0305 843 @param src input 2D matrix.
RyoheiHagimoto 0:0e0631af0305 844 @param dst output vector. Its size and type is defined by dim and dtype parameters.
RyoheiHagimoto 0:0e0631af0305 845 @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
RyoheiHagimoto 0:0e0631af0305 846 a single row. 1 means that the matrix is reduced to a single column.
RyoheiHagimoto 0:0e0631af0305 847 @param rtype reduction operation that could be one of cv::ReduceTypes
RyoheiHagimoto 0:0e0631af0305 848 @param dtype when negative, the output vector will have the same type as the input matrix,
RyoheiHagimoto 0:0e0631af0305 849 otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
RyoheiHagimoto 0:0e0631af0305 850 @sa repeat
RyoheiHagimoto 0:0e0631af0305 851 */
RyoheiHagimoto 0:0e0631af0305 852 CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype = -1);
RyoheiHagimoto 0:0e0631af0305 853
RyoheiHagimoto 0:0e0631af0305 854 /** @brief Creates one multi-channel array out of several single-channel ones.
RyoheiHagimoto 0:0e0631af0305 855
RyoheiHagimoto 0:0e0631af0305 856 The function cv::merge merges several arrays to make a single multi-channel array. That is, each
RyoheiHagimoto 0:0e0631af0305 857 element of the output array will be a concatenation of the elements of the input arrays, where
RyoheiHagimoto 0:0e0631af0305 858 elements of i-th input array are treated as mv[i].channels()-element vectors.
RyoheiHagimoto 0:0e0631af0305 859
RyoheiHagimoto 0:0e0631af0305 860 The function cv::split does the reverse operation. If you need to shuffle channels in some other
RyoheiHagimoto 0:0e0631af0305 861 advanced way, use cv::mixChannels.
RyoheiHagimoto 0:0e0631af0305 862 @param mv input array of matrices to be merged; all the matrices in mv must have the same
RyoheiHagimoto 0:0e0631af0305 863 size and the same depth.
RyoheiHagimoto 0:0e0631af0305 864 @param count number of input matrices when mv is a plain C array; it must be greater than zero.
RyoheiHagimoto 0:0e0631af0305 865 @param dst output array of the same size and the same depth as mv[0]; The number of channels will
RyoheiHagimoto 0:0e0631af0305 866 be equal to the parameter count.
RyoheiHagimoto 0:0e0631af0305 867 @sa mixChannels, split, Mat::reshape
RyoheiHagimoto 0:0e0631af0305 868 */
RyoheiHagimoto 0:0e0631af0305 869 CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 870
RyoheiHagimoto 0:0e0631af0305 871 /** @overload
RyoheiHagimoto 0:0e0631af0305 872 @param mv input vector of matrices to be merged; all the matrices in mv must have the same
RyoheiHagimoto 0:0e0631af0305 873 size and the same depth.
RyoheiHagimoto 0:0e0631af0305 874 @param dst output array of the same size and the same depth as mv[0]; The number of channels will
RyoheiHagimoto 0:0e0631af0305 875 be the total number of channels in the matrix array.
RyoheiHagimoto 0:0e0631af0305 876 */
RyoheiHagimoto 0:0e0631af0305 877 CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 878
RyoheiHagimoto 0:0e0631af0305 879 /** @brief Divides a multi-channel array into several single-channel arrays.
RyoheiHagimoto 0:0e0631af0305 880
RyoheiHagimoto 0:0e0631af0305 881 The function cv::split splits a multi-channel array into separate single-channel arrays:
RyoheiHagimoto 0:0e0631af0305 882 \f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f]
RyoheiHagimoto 0:0e0631af0305 883 If you need to extract a single channel or do some other sophisticated channel permutation, use
RyoheiHagimoto 0:0e0631af0305 884 mixChannels .
RyoheiHagimoto 0:0e0631af0305 885 @param src input multi-channel array.
RyoheiHagimoto 0:0e0631af0305 886 @param mvbegin output array; the number of arrays must match src.channels(); the arrays themselves are
RyoheiHagimoto 0:0e0631af0305 887 reallocated, if needed.
RyoheiHagimoto 0:0e0631af0305 888 @sa merge, mixChannels, cvtColor
RyoheiHagimoto 0:0e0631af0305 889 */
RyoheiHagimoto 0:0e0631af0305 890 CV_EXPORTS void split(const Mat& src, Mat* mvbegin);
RyoheiHagimoto 0:0e0631af0305 891
RyoheiHagimoto 0:0e0631af0305 892 /** @overload
RyoheiHagimoto 0:0e0631af0305 893 @param m input multi-channel array.
RyoheiHagimoto 0:0e0631af0305 894 @param mv output vector of arrays; the arrays themselves are reallocated, if needed.
RyoheiHagimoto 0:0e0631af0305 895 */
RyoheiHagimoto 0:0e0631af0305 896 CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);
RyoheiHagimoto 0:0e0631af0305 897
RyoheiHagimoto 0:0e0631af0305 898 /** @brief Copies specified channels from input arrays to the specified channels of
RyoheiHagimoto 0:0e0631af0305 899 output arrays.
RyoheiHagimoto 0:0e0631af0305 900
RyoheiHagimoto 0:0e0631af0305 901 The function cv::mixChannels provides an advanced mechanism for shuffling image channels.
RyoheiHagimoto 0:0e0631af0305 902
RyoheiHagimoto 0:0e0631af0305 903 cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of cv::cvtColor are partial cases of cv::mixChannels.
RyoheiHagimoto 0:0e0631af0305 904
RyoheiHagimoto 0:0e0631af0305 905 In the example below, the code splits a 4-channel BGRA image into a 3-channel BGR (with B and R
RyoheiHagimoto 0:0e0631af0305 906 channels swapped) and a separate alpha-channel image:
RyoheiHagimoto 0:0e0631af0305 907 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 908 Mat bgra( 100, 100, CV_8UC4, Scalar(255,0,0,255) );
RyoheiHagimoto 0:0e0631af0305 909 Mat bgr( bgra.rows, bgra.cols, CV_8UC3 );
RyoheiHagimoto 0:0e0631af0305 910 Mat alpha( bgra.rows, bgra.cols, CV_8UC1 );
RyoheiHagimoto 0:0e0631af0305 911
RyoheiHagimoto 0:0e0631af0305 912 // forming an array of matrices is a quite efficient operation,
RyoheiHagimoto 0:0e0631af0305 913 // because the matrix data is not copied, only the headers
RyoheiHagimoto 0:0e0631af0305 914 Mat out[] = { bgr, alpha };
RyoheiHagimoto 0:0e0631af0305 915 // bgra[0] -> bgr[2], bgra[1] -> bgr[1],
RyoheiHagimoto 0:0e0631af0305 916 // bgra[2] -> bgr[0], bgra[3] -> alpha[0]
RyoheiHagimoto 0:0e0631af0305 917 int from_to[] = { 0,2, 1,1, 2,0, 3,3 };
RyoheiHagimoto 0:0e0631af0305 918 mixChannels( &bgra, 1, out, 2, from_to, 4 );
RyoheiHagimoto 0:0e0631af0305 919 @endcode
RyoheiHagimoto 0:0e0631af0305 920 @note Unlike many other new-style C++ functions in OpenCV (see the introduction section and
RyoheiHagimoto 0:0e0631af0305 921 Mat::create ), cv::mixChannels requires the output arrays to be pre-allocated before calling the
RyoheiHagimoto 0:0e0631af0305 922 function.
RyoheiHagimoto 0:0e0631af0305 923 @param src input array or vector of matrices; all of the matrices must have the same size and the
RyoheiHagimoto 0:0e0631af0305 924 same depth.
RyoheiHagimoto 0:0e0631af0305 925 @param nsrcs number of matrices in `src`.
RyoheiHagimoto 0:0e0631af0305 926 @param dst output array or vector of matrices; all the matrices **must be allocated**; their size and
RyoheiHagimoto 0:0e0631af0305 927 depth must be the same as in `src[0]`.
RyoheiHagimoto 0:0e0631af0305 928 @param ndsts number of matrices in `dst`.
RyoheiHagimoto 0:0e0631af0305 929 @param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
RyoheiHagimoto 0:0e0631af0305 930 a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
RyoheiHagimoto 0:0e0631af0305 931 dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
RyoheiHagimoto 0:0e0631af0305 932 src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
RyoheiHagimoto 0:0e0631af0305 933 src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
RyoheiHagimoto 0:0e0631af0305 934 channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
RyoheiHagimoto 0:0e0631af0305 935 filled with zero .
RyoheiHagimoto 0:0e0631af0305 936 @param npairs number of index pairs in `fromTo`.
RyoheiHagimoto 0:0e0631af0305 937 @sa split, merge, extractChannel, insertChannel, cvtColor
RyoheiHagimoto 0:0e0631af0305 938 */
RyoheiHagimoto 0:0e0631af0305 939 CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
RyoheiHagimoto 0:0e0631af0305 940 const int* fromTo, size_t npairs);
RyoheiHagimoto 0:0e0631af0305 941
RyoheiHagimoto 0:0e0631af0305 942 /** @overload
RyoheiHagimoto 0:0e0631af0305 943 @param src input array or vector of matrices; all of the matrices must have the same size and the
RyoheiHagimoto 0:0e0631af0305 944 same depth.
RyoheiHagimoto 0:0e0631af0305 945 @param dst output array or vector of matrices; all the matrices **must be allocated**; their size and
RyoheiHagimoto 0:0e0631af0305 946 depth must be the same as in src[0].
RyoheiHagimoto 0:0e0631af0305 947 @param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
RyoheiHagimoto 0:0e0631af0305 948 a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
RyoheiHagimoto 0:0e0631af0305 949 dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
RyoheiHagimoto 0:0e0631af0305 950 src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
RyoheiHagimoto 0:0e0631af0305 951 src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
RyoheiHagimoto 0:0e0631af0305 952 channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
RyoheiHagimoto 0:0e0631af0305 953 filled with zero .
RyoheiHagimoto 0:0e0631af0305 954 @param npairs number of index pairs in fromTo.
RyoheiHagimoto 0:0e0631af0305 955 */
RyoheiHagimoto 0:0e0631af0305 956 CV_EXPORTS void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
RyoheiHagimoto 0:0e0631af0305 957 const int* fromTo, size_t npairs);
RyoheiHagimoto 0:0e0631af0305 958
RyoheiHagimoto 0:0e0631af0305 959 /** @overload
RyoheiHagimoto 0:0e0631af0305 960 @param src input array or vector of matrices; all of the matrices must have the same size and the
RyoheiHagimoto 0:0e0631af0305 961 same depth.
RyoheiHagimoto 0:0e0631af0305 962 @param dst output array or vector of matrices; all the matrices **must be allocated**; their size and
RyoheiHagimoto 0:0e0631af0305 963 depth must be the same as in src[0].
RyoheiHagimoto 0:0e0631af0305 964 @param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
RyoheiHagimoto 0:0e0631af0305 965 a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
RyoheiHagimoto 0:0e0631af0305 966 dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
RyoheiHagimoto 0:0e0631af0305 967 src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
RyoheiHagimoto 0:0e0631af0305 968 src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
RyoheiHagimoto 0:0e0631af0305 969 channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
RyoheiHagimoto 0:0e0631af0305 970 filled with zero .
RyoheiHagimoto 0:0e0631af0305 971 */
RyoheiHagimoto 0:0e0631af0305 972 CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
RyoheiHagimoto 0:0e0631af0305 973 const std::vector<int>& fromTo);
RyoheiHagimoto 0:0e0631af0305 974
RyoheiHagimoto 0:0e0631af0305 975 /** @brief Extracts a single channel from src (coi is 0-based index)
RyoheiHagimoto 0:0e0631af0305 976 @param src input array
RyoheiHagimoto 0:0e0631af0305 977 @param dst output array
RyoheiHagimoto 0:0e0631af0305 978 @param coi index of channel to extract
RyoheiHagimoto 0:0e0631af0305 979 @sa mixChannels, split
RyoheiHagimoto 0:0e0631af0305 980 */
RyoheiHagimoto 0:0e0631af0305 981 CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
RyoheiHagimoto 0:0e0631af0305 982
RyoheiHagimoto 0:0e0631af0305 983 /** @brief Inserts a single channel to dst (coi is 0-based index)
RyoheiHagimoto 0:0e0631af0305 984 @param src input array
RyoheiHagimoto 0:0e0631af0305 985 @param dst output array
RyoheiHagimoto 0:0e0631af0305 986 @param coi index of channel for insertion
RyoheiHagimoto 0:0e0631af0305 987 @sa mixChannels, merge
RyoheiHagimoto 0:0e0631af0305 988 */
RyoheiHagimoto 0:0e0631af0305 989 CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi);
RyoheiHagimoto 0:0e0631af0305 990
RyoheiHagimoto 0:0e0631af0305 991 /** @brief Flips a 2D array around vertical, horizontal, or both axes.
RyoheiHagimoto 0:0e0631af0305 992
RyoheiHagimoto 0:0e0631af0305 993 The function cv::flip flips the array in one of three different ways (row
RyoheiHagimoto 0:0e0631af0305 994 and column indices are 0-based):
RyoheiHagimoto 0:0e0631af0305 995 \f[\texttt{dst} _{ij} =
RyoheiHagimoto 0:0e0631af0305 996 \left\{
RyoheiHagimoto 0:0e0631af0305 997 \begin{array}{l l}
RyoheiHagimoto 0:0e0631af0305 998 \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\
RyoheiHagimoto 0:0e0631af0305 999 \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\
RyoheiHagimoto 0:0e0631af0305 1000 \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\
RyoheiHagimoto 0:0e0631af0305 1001 \end{array}
RyoheiHagimoto 0:0e0631af0305 1002 \right.\f]
RyoheiHagimoto 0:0e0631af0305 1003 The example scenarios of using the function are the following:
RyoheiHagimoto 0:0e0631af0305 1004 * Vertical flipping of the image (flipCode == 0) to switch between
RyoheiHagimoto 0:0e0631af0305 1005 top-left and bottom-left image origin. This is a typical operation
RyoheiHagimoto 0:0e0631af0305 1006 in video processing on Microsoft Windows\* OS.
RyoheiHagimoto 0:0e0631af0305 1007 * Horizontal flipping of the image with the subsequent horizontal
RyoheiHagimoto 0:0e0631af0305 1008 shift and absolute difference calculation to check for a
RyoheiHagimoto 0:0e0631af0305 1009 vertical-axis symmetry (flipCode \> 0).
RyoheiHagimoto 0:0e0631af0305 1010 * Simultaneous horizontal and vertical flipping of the image with
RyoheiHagimoto 0:0e0631af0305 1011 the subsequent shift and absolute difference calculation to check
RyoheiHagimoto 0:0e0631af0305 1012 for a central symmetry (flipCode \< 0).
RyoheiHagimoto 0:0e0631af0305 1013 * Reversing the order of point arrays (flipCode \> 0 or
RyoheiHagimoto 0:0e0631af0305 1014 flipCode == 0).
RyoheiHagimoto 0:0e0631af0305 1015 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1016 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1017 @param flipCode a flag to specify how to flip the array; 0 means
RyoheiHagimoto 0:0e0631af0305 1018 flipping around the x-axis and positive value (for example, 1) means
RyoheiHagimoto 0:0e0631af0305 1019 flipping around y-axis. Negative value (for example, -1) means flipping
RyoheiHagimoto 0:0e0631af0305 1020 around both axes.
RyoheiHagimoto 0:0e0631af0305 1021 @sa transpose , repeat , completeSymm
RyoheiHagimoto 0:0e0631af0305 1022 */
RyoheiHagimoto 0:0e0631af0305 1023 CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);
RyoheiHagimoto 0:0e0631af0305 1024
RyoheiHagimoto 0:0e0631af0305 1025 enum RotateFlags {
RyoheiHagimoto 0:0e0631af0305 1026 ROTATE_90_CLOCKWISE = 0, //Rotate 90 degrees clockwise
RyoheiHagimoto 0:0e0631af0305 1027 ROTATE_180 = 1, //Rotate 180 degrees clockwise
RyoheiHagimoto 0:0e0631af0305 1028 ROTATE_90_COUNTERCLOCKWISE = 2, //Rotate 270 degrees clockwise
RyoheiHagimoto 0:0e0631af0305 1029 };
RyoheiHagimoto 0:0e0631af0305 1030 /** @brief Rotates a 2D array in multiples of 90 degrees.
RyoheiHagimoto 0:0e0631af0305 1031 The function rotate rotates the array in one of three different ways:
RyoheiHagimoto 0:0e0631af0305 1032 * Rotate by 90 degrees clockwise (rotateCode = ROTATE_90).
RyoheiHagimoto 0:0e0631af0305 1033 * Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
RyoheiHagimoto 0:0e0631af0305 1034 * Rotate by 270 degrees clockwise (rotateCode = ROTATE_270).
RyoheiHagimoto 0:0e0631af0305 1035 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1036 @param dst output array of the same type as src. The size is the same with ROTATE_180,
RyoheiHagimoto 0:0e0631af0305 1037 and the rows and cols are switched for ROTATE_90 and ROTATE_270.
RyoheiHagimoto 0:0e0631af0305 1038 @param rotateCode an enum to specify how to rotate the array; see the enum RotateFlags
RyoheiHagimoto 0:0e0631af0305 1039 @sa transpose , repeat , completeSymm, flip, RotateFlags
RyoheiHagimoto 0:0e0631af0305 1040 */
RyoheiHagimoto 0:0e0631af0305 1041 CV_EXPORTS_W void rotate(InputArray src, OutputArray dst, int rotateCode);
RyoheiHagimoto 0:0e0631af0305 1042
RyoheiHagimoto 0:0e0631af0305 1043 /** @brief Fills the output array with repeated copies of the input array.
RyoheiHagimoto 0:0e0631af0305 1044
RyoheiHagimoto 0:0e0631af0305 1045 The function cv::repeat duplicates the input array one or more times along each of the two axes:
RyoheiHagimoto 0:0e0631af0305 1046 \f[\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\f]
RyoheiHagimoto 0:0e0631af0305 1047 The second variant of the function is more convenient to use with @ref MatrixExpressions.
RyoheiHagimoto 0:0e0631af0305 1048 @param src input array to replicate.
RyoheiHagimoto 0:0e0631af0305 1049 @param ny Flag to specify how many times the `src` is repeated along the
RyoheiHagimoto 0:0e0631af0305 1050 vertical axis.
RyoheiHagimoto 0:0e0631af0305 1051 @param nx Flag to specify how many times the `src` is repeated along the
RyoheiHagimoto 0:0e0631af0305 1052 horizontal axis.
RyoheiHagimoto 0:0e0631af0305 1053 @param dst output array of the same type as `src`.
RyoheiHagimoto 0:0e0631af0305 1054 @sa cv::reduce
RyoheiHagimoto 0:0e0631af0305 1055 */
RyoheiHagimoto 0:0e0631af0305 1056 CV_EXPORTS_W void repeat(InputArray src, int ny, int nx, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1057
RyoheiHagimoto 0:0e0631af0305 1058 /** @overload
RyoheiHagimoto 0:0e0631af0305 1059 @param src input array to replicate.
RyoheiHagimoto 0:0e0631af0305 1060 @param ny Flag to specify how many times the `src` is repeated along the
RyoheiHagimoto 0:0e0631af0305 1061 vertical axis.
RyoheiHagimoto 0:0e0631af0305 1062 @param nx Flag to specify how many times the `src` is repeated along the
RyoheiHagimoto 0:0e0631af0305 1063 horizontal axis.
RyoheiHagimoto 0:0e0631af0305 1064 */
RyoheiHagimoto 0:0e0631af0305 1065 CV_EXPORTS Mat repeat(const Mat& src, int ny, int nx);
RyoheiHagimoto 0:0e0631af0305 1066
RyoheiHagimoto 0:0e0631af0305 1067 /** @brief Applies horizontal concatenation to given matrices.
RyoheiHagimoto 0:0e0631af0305 1068
RyoheiHagimoto 0:0e0631af0305 1069 The function horizontally concatenates two or more cv::Mat matrices (with the same number of rows).
RyoheiHagimoto 0:0e0631af0305 1070 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1071 cv::Mat matArray[] = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
RyoheiHagimoto 0:0e0631af0305 1072 cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
RyoheiHagimoto 0:0e0631af0305 1073 cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
RyoheiHagimoto 0:0e0631af0305 1074
RyoheiHagimoto 0:0e0631af0305 1075 cv::Mat out;
RyoheiHagimoto 0:0e0631af0305 1076 cv::hconcat( matArray, 3, out );
RyoheiHagimoto 0:0e0631af0305 1077 //out:
RyoheiHagimoto 0:0e0631af0305 1078 //[1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1079 // 1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1080 // 1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1081 // 1, 2, 3]
RyoheiHagimoto 0:0e0631af0305 1082 @endcode
RyoheiHagimoto 0:0e0631af0305 1083 @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth.
RyoheiHagimoto 0:0e0631af0305 1084 @param nsrc number of matrices in src.
RyoheiHagimoto 0:0e0631af0305 1085 @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src.
RyoheiHagimoto 0:0e0631af0305 1086 @sa cv::vconcat(const Mat*, size_t, OutputArray), @sa cv::vconcat(InputArrayOfArrays, OutputArray) and @sa cv::vconcat(InputArray, InputArray, OutputArray)
RyoheiHagimoto 0:0e0631af0305 1087 */
RyoheiHagimoto 0:0e0631af0305 1088 CV_EXPORTS void hconcat(const Mat* src, size_t nsrc, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1089 /** @overload
RyoheiHagimoto 0:0e0631af0305 1090 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1091 cv::Mat_<float> A = (cv::Mat_<float>(3, 2) << 1, 4,
RyoheiHagimoto 0:0e0631af0305 1092 2, 5,
RyoheiHagimoto 0:0e0631af0305 1093 3, 6);
RyoheiHagimoto 0:0e0631af0305 1094 cv::Mat_<float> B = (cv::Mat_<float>(3, 2) << 7, 10,
RyoheiHagimoto 0:0e0631af0305 1095 8, 11,
RyoheiHagimoto 0:0e0631af0305 1096 9, 12);
RyoheiHagimoto 0:0e0631af0305 1097
RyoheiHagimoto 0:0e0631af0305 1098 cv::Mat C;
RyoheiHagimoto 0:0e0631af0305 1099 cv::hconcat(A, B, C);
RyoheiHagimoto 0:0e0631af0305 1100 //C:
RyoheiHagimoto 0:0e0631af0305 1101 //[1, 4, 7, 10;
RyoheiHagimoto 0:0e0631af0305 1102 // 2, 5, 8, 11;
RyoheiHagimoto 0:0e0631af0305 1103 // 3, 6, 9, 12]
RyoheiHagimoto 0:0e0631af0305 1104 @endcode
RyoheiHagimoto 0:0e0631af0305 1105 @param src1 first input array to be considered for horizontal concatenation.
RyoheiHagimoto 0:0e0631af0305 1106 @param src2 second input array to be considered for horizontal concatenation.
RyoheiHagimoto 0:0e0631af0305 1107 @param dst output array. It has the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2.
RyoheiHagimoto 0:0e0631af0305 1108 */
RyoheiHagimoto 0:0e0631af0305 1109 CV_EXPORTS void hconcat(InputArray src1, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1110 /** @overload
RyoheiHagimoto 0:0e0631af0305 1111 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1112 std::vector<cv::Mat> matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
RyoheiHagimoto 0:0e0631af0305 1113 cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
RyoheiHagimoto 0:0e0631af0305 1114 cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
RyoheiHagimoto 0:0e0631af0305 1115
RyoheiHagimoto 0:0e0631af0305 1116 cv::Mat out;
RyoheiHagimoto 0:0e0631af0305 1117 cv::hconcat( matrices, out );
RyoheiHagimoto 0:0e0631af0305 1118 //out:
RyoheiHagimoto 0:0e0631af0305 1119 //[1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1120 // 1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1121 // 1, 2, 3;
RyoheiHagimoto 0:0e0631af0305 1122 // 1, 2, 3]
RyoheiHagimoto 0:0e0631af0305 1123 @endcode
RyoheiHagimoto 0:0e0631af0305 1124 @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth.
RyoheiHagimoto 0:0e0631af0305 1125 @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src.
RyoheiHagimoto 0:0e0631af0305 1126 same depth.
RyoheiHagimoto 0:0e0631af0305 1127 */
RyoheiHagimoto 0:0e0631af0305 1128 CV_EXPORTS_W void hconcat(InputArrayOfArrays src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1129
RyoheiHagimoto 0:0e0631af0305 1130 /** @brief Applies vertical concatenation to given matrices.
RyoheiHagimoto 0:0e0631af0305 1131
RyoheiHagimoto 0:0e0631af0305 1132 The function vertically concatenates two or more cv::Mat matrices (with the same number of cols).
RyoheiHagimoto 0:0e0631af0305 1133 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1134 cv::Mat matArray[] = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
RyoheiHagimoto 0:0e0631af0305 1135 cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
RyoheiHagimoto 0:0e0631af0305 1136 cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
RyoheiHagimoto 0:0e0631af0305 1137
RyoheiHagimoto 0:0e0631af0305 1138 cv::Mat out;
RyoheiHagimoto 0:0e0631af0305 1139 cv::vconcat( matArray, 3, out );
RyoheiHagimoto 0:0e0631af0305 1140 //out:
RyoheiHagimoto 0:0e0631af0305 1141 //[1, 1, 1, 1;
RyoheiHagimoto 0:0e0631af0305 1142 // 2, 2, 2, 2;
RyoheiHagimoto 0:0e0631af0305 1143 // 3, 3, 3, 3]
RyoheiHagimoto 0:0e0631af0305 1144 @endcode
RyoheiHagimoto 0:0e0631af0305 1145 @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth.
RyoheiHagimoto 0:0e0631af0305 1146 @param nsrc number of matrices in src.
RyoheiHagimoto 0:0e0631af0305 1147 @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src.
RyoheiHagimoto 0:0e0631af0305 1148 @sa cv::hconcat(const Mat*, size_t, OutputArray), @sa cv::hconcat(InputArrayOfArrays, OutputArray) and @sa cv::hconcat(InputArray, InputArray, OutputArray)
RyoheiHagimoto 0:0e0631af0305 1149 */
RyoheiHagimoto 0:0e0631af0305 1150 CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1151 /** @overload
RyoheiHagimoto 0:0e0631af0305 1152 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1153 cv::Mat_<float> A = (cv::Mat_<float>(3, 2) << 1, 7,
RyoheiHagimoto 0:0e0631af0305 1154 2, 8,
RyoheiHagimoto 0:0e0631af0305 1155 3, 9);
RyoheiHagimoto 0:0e0631af0305 1156 cv::Mat_<float> B = (cv::Mat_<float>(3, 2) << 4, 10,
RyoheiHagimoto 0:0e0631af0305 1157 5, 11,
RyoheiHagimoto 0:0e0631af0305 1158 6, 12);
RyoheiHagimoto 0:0e0631af0305 1159
RyoheiHagimoto 0:0e0631af0305 1160 cv::Mat C;
RyoheiHagimoto 0:0e0631af0305 1161 cv::vconcat(A, B, C);
RyoheiHagimoto 0:0e0631af0305 1162 //C:
RyoheiHagimoto 0:0e0631af0305 1163 //[1, 7;
RyoheiHagimoto 0:0e0631af0305 1164 // 2, 8;
RyoheiHagimoto 0:0e0631af0305 1165 // 3, 9;
RyoheiHagimoto 0:0e0631af0305 1166 // 4, 10;
RyoheiHagimoto 0:0e0631af0305 1167 // 5, 11;
RyoheiHagimoto 0:0e0631af0305 1168 // 6, 12]
RyoheiHagimoto 0:0e0631af0305 1169 @endcode
RyoheiHagimoto 0:0e0631af0305 1170 @param src1 first input array to be considered for vertical concatenation.
RyoheiHagimoto 0:0e0631af0305 1171 @param src2 second input array to be considered for vertical concatenation.
RyoheiHagimoto 0:0e0631af0305 1172 @param dst output array. It has the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2.
RyoheiHagimoto 0:0e0631af0305 1173 */
RyoheiHagimoto 0:0e0631af0305 1174 CV_EXPORTS void vconcat(InputArray src1, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1175 /** @overload
RyoheiHagimoto 0:0e0631af0305 1176 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1177 std::vector<cv::Mat> matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
RyoheiHagimoto 0:0e0631af0305 1178 cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
RyoheiHagimoto 0:0e0631af0305 1179 cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
RyoheiHagimoto 0:0e0631af0305 1180
RyoheiHagimoto 0:0e0631af0305 1181 cv::Mat out;
RyoheiHagimoto 0:0e0631af0305 1182 cv::vconcat( matrices, out );
RyoheiHagimoto 0:0e0631af0305 1183 //out:
RyoheiHagimoto 0:0e0631af0305 1184 //[1, 1, 1, 1;
RyoheiHagimoto 0:0e0631af0305 1185 // 2, 2, 2, 2;
RyoheiHagimoto 0:0e0631af0305 1186 // 3, 3, 3, 3]
RyoheiHagimoto 0:0e0631af0305 1187 @endcode
RyoheiHagimoto 0:0e0631af0305 1188 @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth
RyoheiHagimoto 0:0e0631af0305 1189 @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src.
RyoheiHagimoto 0:0e0631af0305 1190 same depth.
RyoheiHagimoto 0:0e0631af0305 1191 */
RyoheiHagimoto 0:0e0631af0305 1192 CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1193
RyoheiHagimoto 0:0e0631af0305 1194 /** @brief computes bitwise conjunction of the two arrays (dst = src1 & src2)
RyoheiHagimoto 0:0e0631af0305 1195 Calculates the per-element bit-wise conjunction of two arrays or an
RyoheiHagimoto 0:0e0631af0305 1196 array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1197
RyoheiHagimoto 0:0e0631af0305 1198 The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
RyoheiHagimoto 0:0e0631af0305 1199 * Two arrays when src1 and src2 have the same size:
RyoheiHagimoto 0:0e0631af0305 1200 \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1201 * An array and a scalar when src2 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1202 the same number of elements as `src1.channels()`:
RyoheiHagimoto 0:0e0631af0305 1203 \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1204 * A scalar and an array when src1 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1205 the same number of elements as `src2.channels()`:
RyoheiHagimoto 0:0e0631af0305 1206 \f[\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1207 In case of floating-point arrays, their machine-specific bit
RyoheiHagimoto 0:0e0631af0305 1208 representations (usually IEEE754-compliant) are used for the operation.
RyoheiHagimoto 0:0e0631af0305 1209 In case of multi-channel arrays, each channel is processed
RyoheiHagimoto 0:0e0631af0305 1210 independently. In the second and third cases above, the scalar is first
RyoheiHagimoto 0:0e0631af0305 1211 converted to the array type.
RyoheiHagimoto 0:0e0631af0305 1212 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1213 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1214 @param dst output array that has the same size and type as the input
RyoheiHagimoto 0:0e0631af0305 1215 arrays.
RyoheiHagimoto 0:0e0631af0305 1216 @param mask optional operation mask, 8-bit single channel array, that
RyoheiHagimoto 0:0e0631af0305 1217 specifies elements of the output array to be changed.
RyoheiHagimoto 0:0e0631af0305 1218 */
RyoheiHagimoto 0:0e0631af0305 1219 CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 1220 OutputArray dst, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 1221
RyoheiHagimoto 0:0e0631af0305 1222 /** @brief Calculates the per-element bit-wise disjunction of two arrays or an
RyoheiHagimoto 0:0e0631af0305 1223 array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1224
RyoheiHagimoto 0:0e0631af0305 1225 The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
RyoheiHagimoto 0:0e0631af0305 1226 * Two arrays when src1 and src2 have the same size:
RyoheiHagimoto 0:0e0631af0305 1227 \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1228 * An array and a scalar when src2 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1229 the same number of elements as `src1.channels()`:
RyoheiHagimoto 0:0e0631af0305 1230 \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1231 * A scalar and an array when src1 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1232 the same number of elements as `src2.channels()`:
RyoheiHagimoto 0:0e0631af0305 1233 \f[\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1234 In case of floating-point arrays, their machine-specific bit
RyoheiHagimoto 0:0e0631af0305 1235 representations (usually IEEE754-compliant) are used for the operation.
RyoheiHagimoto 0:0e0631af0305 1236 In case of multi-channel arrays, each channel is processed
RyoheiHagimoto 0:0e0631af0305 1237 independently. In the second and third cases above, the scalar is first
RyoheiHagimoto 0:0e0631af0305 1238 converted to the array type.
RyoheiHagimoto 0:0e0631af0305 1239 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1240 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1241 @param dst output array that has the same size and type as the input
RyoheiHagimoto 0:0e0631af0305 1242 arrays.
RyoheiHagimoto 0:0e0631af0305 1243 @param mask optional operation mask, 8-bit single channel array, that
RyoheiHagimoto 0:0e0631af0305 1244 specifies elements of the output array to be changed.
RyoheiHagimoto 0:0e0631af0305 1245 */
RyoheiHagimoto 0:0e0631af0305 1246 CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 1247 OutputArray dst, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 1248
RyoheiHagimoto 0:0e0631af0305 1249 /** @brief Calculates the per-element bit-wise "exclusive or" operation on two
RyoheiHagimoto 0:0e0631af0305 1250 arrays or an array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1251
RyoheiHagimoto 0:0e0631af0305 1252 The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
RyoheiHagimoto 0:0e0631af0305 1253 operation for:
RyoheiHagimoto 0:0e0631af0305 1254 * Two arrays when src1 and src2 have the same size:
RyoheiHagimoto 0:0e0631af0305 1255 \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1256 * An array and a scalar when src2 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1257 the same number of elements as `src1.channels()`:
RyoheiHagimoto 0:0e0631af0305 1258 \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1259 * A scalar and an array when src1 is constructed from Scalar or has
RyoheiHagimoto 0:0e0631af0305 1260 the same number of elements as `src2.channels()`:
RyoheiHagimoto 0:0e0631af0305 1261 \f[\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
RyoheiHagimoto 0:0e0631af0305 1262 In case of floating-point arrays, their machine-specific bit
RyoheiHagimoto 0:0e0631af0305 1263 representations (usually IEEE754-compliant) are used for the operation.
RyoheiHagimoto 0:0e0631af0305 1264 In case of multi-channel arrays, each channel is processed
RyoheiHagimoto 0:0e0631af0305 1265 independently. In the 2nd and 3rd cases above, the scalar is first
RyoheiHagimoto 0:0e0631af0305 1266 converted to the array type.
RyoheiHagimoto 0:0e0631af0305 1267 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1268 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1269 @param dst output array that has the same size and type as the input
RyoheiHagimoto 0:0e0631af0305 1270 arrays.
RyoheiHagimoto 0:0e0631af0305 1271 @param mask optional operation mask, 8-bit single channel array, that
RyoheiHagimoto 0:0e0631af0305 1272 specifies elements of the output array to be changed.
RyoheiHagimoto 0:0e0631af0305 1273 */
RyoheiHagimoto 0:0e0631af0305 1274 CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 1275 OutputArray dst, InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 1276
RyoheiHagimoto 0:0e0631af0305 1277 /** @brief Inverts every bit of an array.
RyoheiHagimoto 0:0e0631af0305 1278
RyoheiHagimoto 0:0e0631af0305 1279 The function cv::bitwise_not calculates per-element bit-wise inversion of the input
RyoheiHagimoto 0:0e0631af0305 1280 array:
RyoheiHagimoto 0:0e0631af0305 1281 \f[\texttt{dst} (I) = \neg \texttt{src} (I)\f]
RyoheiHagimoto 0:0e0631af0305 1282 In case of a floating-point input array, its machine-specific bit
RyoheiHagimoto 0:0e0631af0305 1283 representation (usually IEEE754-compliant) is used for the operation. In
RyoheiHagimoto 0:0e0631af0305 1284 case of multi-channel arrays, each channel is processed independently.
RyoheiHagimoto 0:0e0631af0305 1285 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1286 @param dst output array that has the same size and type as the input
RyoheiHagimoto 0:0e0631af0305 1287 array.
RyoheiHagimoto 0:0e0631af0305 1288 @param mask optional operation mask, 8-bit single channel array, that
RyoheiHagimoto 0:0e0631af0305 1289 specifies elements of the output array to be changed.
RyoheiHagimoto 0:0e0631af0305 1290 */
RyoheiHagimoto 0:0e0631af0305 1291 CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst,
RyoheiHagimoto 0:0e0631af0305 1292 InputArray mask = noArray());
RyoheiHagimoto 0:0e0631af0305 1293
RyoheiHagimoto 0:0e0631af0305 1294 /** @brief Calculates the per-element absolute difference between two arrays or between an array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1295
RyoheiHagimoto 0:0e0631af0305 1296 The function cv::absdiff calculates:
RyoheiHagimoto 0:0e0631af0305 1297 * Absolute difference between two arrays when they have the same
RyoheiHagimoto 0:0e0631af0305 1298 size and type:
RyoheiHagimoto 0:0e0631af0305 1299 \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f]
RyoheiHagimoto 0:0e0631af0305 1300 * Absolute difference between an array and a scalar when the second
RyoheiHagimoto 0:0e0631af0305 1301 array is constructed from Scalar or has as many elements as the
RyoheiHagimoto 0:0e0631af0305 1302 number of channels in `src1`:
RyoheiHagimoto 0:0e0631af0305 1303 \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\f]
RyoheiHagimoto 0:0e0631af0305 1304 * Absolute difference between a scalar and an array when the first
RyoheiHagimoto 0:0e0631af0305 1305 array is constructed from Scalar or has as many elements as the
RyoheiHagimoto 0:0e0631af0305 1306 number of channels in `src2`:
RyoheiHagimoto 0:0e0631af0305 1307 \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\f]
RyoheiHagimoto 0:0e0631af0305 1308 where I is a multi-dimensional index of array elements. In case of
RyoheiHagimoto 0:0e0631af0305 1309 multi-channel arrays, each channel is processed independently.
RyoheiHagimoto 0:0e0631af0305 1310 @note Saturation is not applied when the arrays have the depth CV_32S.
RyoheiHagimoto 0:0e0631af0305 1311 You may even get a negative value in the case of overflow.
RyoheiHagimoto 0:0e0631af0305 1312 @param src1 first input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1313 @param src2 second input array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1314 @param dst output array that has the same size and type as input arrays.
RyoheiHagimoto 0:0e0631af0305 1315 @sa cv::abs(const Mat&)
RyoheiHagimoto 0:0e0631af0305 1316 */
RyoheiHagimoto 0:0e0631af0305 1317 CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1318
RyoheiHagimoto 0:0e0631af0305 1319 /** @brief Checks if array elements lie between the elements of two other arrays.
RyoheiHagimoto 0:0e0631af0305 1320
RyoheiHagimoto 0:0e0631af0305 1321 The function checks the range as follows:
RyoheiHagimoto 0:0e0631af0305 1322 - For every element of a single-channel input array:
RyoheiHagimoto 0:0e0631af0305 1323 \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0\f]
RyoheiHagimoto 0:0e0631af0305 1324 - For two-channel arrays:
RyoheiHagimoto 0:0e0631af0305 1325 \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 \leq \texttt{upperb} (I)_1\f]
RyoheiHagimoto 0:0e0631af0305 1326 - and so forth.
RyoheiHagimoto 0:0e0631af0305 1327
RyoheiHagimoto 0:0e0631af0305 1328 That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
RyoheiHagimoto 0:0e0631af0305 1329 specified 1D, 2D, 3D, ... box and 0 otherwise.
RyoheiHagimoto 0:0e0631af0305 1330
RyoheiHagimoto 0:0e0631af0305 1331 When the lower and/or upper boundary parameters are scalars, the indexes
RyoheiHagimoto 0:0e0631af0305 1332 (I) at lowerb and upperb in the above formulas should be omitted.
RyoheiHagimoto 0:0e0631af0305 1333 @param src first input array.
RyoheiHagimoto 0:0e0631af0305 1334 @param lowerb inclusive lower boundary array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1335 @param upperb inclusive upper boundary array or a scalar.
RyoheiHagimoto 0:0e0631af0305 1336 @param dst output array of the same size as src and CV_8U type.
RyoheiHagimoto 0:0e0631af0305 1337 */
RyoheiHagimoto 0:0e0631af0305 1338 CV_EXPORTS_W void inRange(InputArray src, InputArray lowerb,
RyoheiHagimoto 0:0e0631af0305 1339 InputArray upperb, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1340
RyoheiHagimoto 0:0e0631af0305 1341 /** @brief Performs the per-element comparison of two arrays or an array and scalar value.
RyoheiHagimoto 0:0e0631af0305 1342
RyoheiHagimoto 0:0e0631af0305 1343 The function compares:
RyoheiHagimoto 0:0e0631af0305 1344 * Elements of two arrays when src1 and src2 have the same size:
RyoheiHagimoto 0:0e0631af0305 1345 \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\f]
RyoheiHagimoto 0:0e0631af0305 1346 * Elements of src1 with a scalar src2 when src2 is constructed from
RyoheiHagimoto 0:0e0631af0305 1347 Scalar or has a single element:
RyoheiHagimoto 0:0e0631af0305 1348 \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f]
RyoheiHagimoto 0:0e0631af0305 1349 * src1 with elements of src2 when src1 is constructed from Scalar or
RyoheiHagimoto 0:0e0631af0305 1350 has a single element:
RyoheiHagimoto 0:0e0631af0305 1351 \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\f]
RyoheiHagimoto 0:0e0631af0305 1352 When the comparison result is true, the corresponding element of output
RyoheiHagimoto 0:0e0631af0305 1353 array is set to 255. The comparison operations can be replaced with the
RyoheiHagimoto 0:0e0631af0305 1354 equivalent matrix expressions:
RyoheiHagimoto 0:0e0631af0305 1355 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1356 Mat dst1 = src1 >= src2;
RyoheiHagimoto 0:0e0631af0305 1357 Mat dst2 = src1 < 8;
RyoheiHagimoto 0:0e0631af0305 1358 ...
RyoheiHagimoto 0:0e0631af0305 1359 @endcode
RyoheiHagimoto 0:0e0631af0305 1360 @param src1 first input array or a scalar; when it is an array, it must have a single channel.
RyoheiHagimoto 0:0e0631af0305 1361 @param src2 second input array or a scalar; when it is an array, it must have a single channel.
RyoheiHagimoto 0:0e0631af0305 1362 @param dst output array of type ref CV_8U that has the same size and the same number of channels as
RyoheiHagimoto 0:0e0631af0305 1363 the input arrays.
RyoheiHagimoto 0:0e0631af0305 1364 @param cmpop a flag, that specifies correspondence between the arrays (cv::CmpTypes)
RyoheiHagimoto 0:0e0631af0305 1365 @sa checkRange, min, max, threshold
RyoheiHagimoto 0:0e0631af0305 1366 */
RyoheiHagimoto 0:0e0631af0305 1367 CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop);
RyoheiHagimoto 0:0e0631af0305 1368
RyoheiHagimoto 0:0e0631af0305 1369 /** @brief Calculates per-element minimum of two arrays or an array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1370
RyoheiHagimoto 0:0e0631af0305 1371 The function cv::min calculates the per-element minimum of two arrays:
RyoheiHagimoto 0:0e0631af0305 1372 \f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f]
RyoheiHagimoto 0:0e0631af0305 1373 or array and a scalar:
RyoheiHagimoto 0:0e0631af0305 1374 \f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\f]
RyoheiHagimoto 0:0e0631af0305 1375 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 1376 @param src2 second input array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 1377 @param dst output array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 1378 @sa max, compare, inRange, minMaxLoc
RyoheiHagimoto 0:0e0631af0305 1379 */
RyoheiHagimoto 0:0e0631af0305 1380 CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1381 /** @overload
RyoheiHagimoto 0:0e0631af0305 1382 needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
RyoheiHagimoto 0:0e0631af0305 1383 */
RyoheiHagimoto 0:0e0631af0305 1384 CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst);
RyoheiHagimoto 0:0e0631af0305 1385 /** @overload
RyoheiHagimoto 0:0e0631af0305 1386 needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
RyoheiHagimoto 0:0e0631af0305 1387 */
RyoheiHagimoto 0:0e0631af0305 1388 CV_EXPORTS void min(const UMat& src1, const UMat& src2, UMat& dst);
RyoheiHagimoto 0:0e0631af0305 1389
RyoheiHagimoto 0:0e0631af0305 1390 /** @brief Calculates per-element maximum of two arrays or an array and a scalar.
RyoheiHagimoto 0:0e0631af0305 1391
RyoheiHagimoto 0:0e0631af0305 1392 The function cv::max calculates the per-element maximum of two arrays:
RyoheiHagimoto 0:0e0631af0305 1393 \f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f]
RyoheiHagimoto 0:0e0631af0305 1394 or array and a scalar:
RyoheiHagimoto 0:0e0631af0305 1395 \f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\f]
RyoheiHagimoto 0:0e0631af0305 1396 @param src1 first input array.
RyoheiHagimoto 0:0e0631af0305 1397 @param src2 second input array of the same size and type as src1 .
RyoheiHagimoto 0:0e0631af0305 1398 @param dst output array of the same size and type as src1.
RyoheiHagimoto 0:0e0631af0305 1399 @sa min, compare, inRange, minMaxLoc, @ref MatrixExpressions
RyoheiHagimoto 0:0e0631af0305 1400 */
RyoheiHagimoto 0:0e0631af0305 1401 CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1402 /** @overload
RyoheiHagimoto 0:0e0631af0305 1403 needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
RyoheiHagimoto 0:0e0631af0305 1404 */
RyoheiHagimoto 0:0e0631af0305 1405 CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst);
RyoheiHagimoto 0:0e0631af0305 1406 /** @overload
RyoheiHagimoto 0:0e0631af0305 1407 needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
RyoheiHagimoto 0:0e0631af0305 1408 */
RyoheiHagimoto 0:0e0631af0305 1409 CV_EXPORTS void max(const UMat& src1, const UMat& src2, UMat& dst);
RyoheiHagimoto 0:0e0631af0305 1410
RyoheiHagimoto 0:0e0631af0305 1411 /** @brief Calculates a square root of array elements.
RyoheiHagimoto 0:0e0631af0305 1412
RyoheiHagimoto 0:0e0631af0305 1413 The function cv::sqrt calculates a square root of each input array element.
RyoheiHagimoto 0:0e0631af0305 1414 In case of multi-channel arrays, each channel is processed
RyoheiHagimoto 0:0e0631af0305 1415 independently. The accuracy is approximately the same as of the built-in
RyoheiHagimoto 0:0e0631af0305 1416 std::sqrt .
RyoheiHagimoto 0:0e0631af0305 1417 @param src input floating-point array.
RyoheiHagimoto 0:0e0631af0305 1418 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1419 */
RyoheiHagimoto 0:0e0631af0305 1420 CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1421
RyoheiHagimoto 0:0e0631af0305 1422 /** @brief Raises every array element to a power.
RyoheiHagimoto 0:0e0631af0305 1423
RyoheiHagimoto 0:0e0631af0305 1424 The function cv::pow raises every element of the input array to power :
RyoheiHagimoto 0:0e0631af0305 1425 \f[\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\f]
RyoheiHagimoto 0:0e0631af0305 1426
RyoheiHagimoto 0:0e0631af0305 1427 So, for a non-integer power exponent, the absolute values of input array
RyoheiHagimoto 0:0e0631af0305 1428 elements are used. However, it is possible to get true values for
RyoheiHagimoto 0:0e0631af0305 1429 negative values using some extra operations. In the example below,
RyoheiHagimoto 0:0e0631af0305 1430 computing the 5th root of array src shows:
RyoheiHagimoto 0:0e0631af0305 1431 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1432 Mat mask = src < 0;
RyoheiHagimoto 0:0e0631af0305 1433 pow(src, 1./5, dst);
RyoheiHagimoto 0:0e0631af0305 1434 subtract(Scalar::all(0), dst, dst, mask);
RyoheiHagimoto 0:0e0631af0305 1435 @endcode
RyoheiHagimoto 0:0e0631af0305 1436 For some values of power, such as integer values, 0.5 and -0.5,
RyoheiHagimoto 0:0e0631af0305 1437 specialized faster algorithms are used.
RyoheiHagimoto 0:0e0631af0305 1438
RyoheiHagimoto 0:0e0631af0305 1439 Special values (NaN, Inf) are not handled.
RyoheiHagimoto 0:0e0631af0305 1440 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1441 @param power exponent of power.
RyoheiHagimoto 0:0e0631af0305 1442 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1443 @sa sqrt, exp, log, cartToPolar, polarToCart
RyoheiHagimoto 0:0e0631af0305 1444 */
RyoheiHagimoto 0:0e0631af0305 1445 CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1446
RyoheiHagimoto 0:0e0631af0305 1447 /** @brief Calculates the exponent of every array element.
RyoheiHagimoto 0:0e0631af0305 1448
RyoheiHagimoto 0:0e0631af0305 1449 The function cv::exp calculates the exponent of every element of the input
RyoheiHagimoto 0:0e0631af0305 1450 array:
RyoheiHagimoto 0:0e0631af0305 1451 \f[\texttt{dst} [I] = e^{ src(I) }\f]
RyoheiHagimoto 0:0e0631af0305 1452
RyoheiHagimoto 0:0e0631af0305 1453 The maximum relative error is about 7e-6 for single-precision input and
RyoheiHagimoto 0:0e0631af0305 1454 less than 1e-10 for double-precision input. Currently, the function
RyoheiHagimoto 0:0e0631af0305 1455 converts denormalized values to zeros on output. Special values (NaN,
RyoheiHagimoto 0:0e0631af0305 1456 Inf) are not handled.
RyoheiHagimoto 0:0e0631af0305 1457 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1458 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1459 @sa log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude
RyoheiHagimoto 0:0e0631af0305 1460 */
RyoheiHagimoto 0:0e0631af0305 1461 CV_EXPORTS_W void exp(InputArray src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1462
RyoheiHagimoto 0:0e0631af0305 1463 /** @brief Calculates the natural logarithm of every array element.
RyoheiHagimoto 0:0e0631af0305 1464
RyoheiHagimoto 0:0e0631af0305 1465 The function cv::log calculates the natural logarithm of every element of the input array:
RyoheiHagimoto 0:0e0631af0305 1466 \f[\texttt{dst} (I) = \log (\texttt{src}(I)) \f]
RyoheiHagimoto 0:0e0631af0305 1467
RyoheiHagimoto 0:0e0631af0305 1468 Output on zero, negative and special (NaN, Inf) values is undefined.
RyoheiHagimoto 0:0e0631af0305 1469
RyoheiHagimoto 0:0e0631af0305 1470 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1471 @param dst output array of the same size and type as src .
RyoheiHagimoto 0:0e0631af0305 1472 @sa exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
RyoheiHagimoto 0:0e0631af0305 1473 */
RyoheiHagimoto 0:0e0631af0305 1474 CV_EXPORTS_W void log(InputArray src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1475
RyoheiHagimoto 0:0e0631af0305 1476 /** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle.
RyoheiHagimoto 0:0e0631af0305 1477
RyoheiHagimoto 0:0e0631af0305 1478 The function cv::polarToCart calculates the Cartesian coordinates of each 2D
RyoheiHagimoto 0:0e0631af0305 1479 vector represented by the corresponding elements of magnitude and angle:
RyoheiHagimoto 0:0e0631af0305 1480 \f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 1481
RyoheiHagimoto 0:0e0631af0305 1482 The relative accuracy of the estimated coordinates is about 1e-6.
RyoheiHagimoto 0:0e0631af0305 1483 @param magnitude input floating-point array of magnitudes of 2D vectors;
RyoheiHagimoto 0:0e0631af0305 1484 it can be an empty matrix (=Mat()), in this case, the function assumes
RyoheiHagimoto 0:0e0631af0305 1485 that all the magnitudes are =1; if it is not empty, it must have the
RyoheiHagimoto 0:0e0631af0305 1486 same size and type as angle.
RyoheiHagimoto 0:0e0631af0305 1487 @param angle input floating-point array of angles of 2D vectors.
RyoheiHagimoto 0:0e0631af0305 1488 @param x output array of x-coordinates of 2D vectors; it has the same
RyoheiHagimoto 0:0e0631af0305 1489 size and type as angle.
RyoheiHagimoto 0:0e0631af0305 1490 @param y output array of y-coordinates of 2D vectors; it has the same
RyoheiHagimoto 0:0e0631af0305 1491 size and type as angle.
RyoheiHagimoto 0:0e0631af0305 1492 @param angleInDegrees when true, the input angles are measured in
RyoheiHagimoto 0:0e0631af0305 1493 degrees, otherwise, they are measured in radians.
RyoheiHagimoto 0:0e0631af0305 1494 @sa cartToPolar, magnitude, phase, exp, log, pow, sqrt
RyoheiHagimoto 0:0e0631af0305 1495 */
RyoheiHagimoto 0:0e0631af0305 1496 CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle,
RyoheiHagimoto 0:0e0631af0305 1497 OutputArray x, OutputArray y, bool angleInDegrees = false);
RyoheiHagimoto 0:0e0631af0305 1498
RyoheiHagimoto 0:0e0631af0305 1499 /** @brief Calculates the magnitude and angle of 2D vectors.
RyoheiHagimoto 0:0e0631af0305 1500
RyoheiHagimoto 0:0e0631af0305 1501 The function cv::cartToPolar calculates either the magnitude, angle, or both
RyoheiHagimoto 0:0e0631af0305 1502 for every 2D vector (x(I),y(I)):
RyoheiHagimoto 0:0e0631af0305 1503 \f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 1504
RyoheiHagimoto 0:0e0631af0305 1505 The angles are calculated with accuracy about 0.3 degrees. For the point
RyoheiHagimoto 0:0e0631af0305 1506 (0,0), the angle is set to 0.
RyoheiHagimoto 0:0e0631af0305 1507 @param x array of x-coordinates; this must be a single-precision or
RyoheiHagimoto 0:0e0631af0305 1508 double-precision floating-point array.
RyoheiHagimoto 0:0e0631af0305 1509 @param y array of y-coordinates, that must have the same size and same type as x.
RyoheiHagimoto 0:0e0631af0305 1510 @param magnitude output array of magnitudes of the same size and type as x.
RyoheiHagimoto 0:0e0631af0305 1511 @param angle output array of angles that has the same size and type as
RyoheiHagimoto 0:0e0631af0305 1512 x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
RyoheiHagimoto 0:0e0631af0305 1513 @param angleInDegrees a flag, indicating whether the angles are measured
RyoheiHagimoto 0:0e0631af0305 1514 in radians (which is by default), or in degrees.
RyoheiHagimoto 0:0e0631af0305 1515 @sa Sobel, Scharr
RyoheiHagimoto 0:0e0631af0305 1516 */
RyoheiHagimoto 0:0e0631af0305 1517 CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y,
RyoheiHagimoto 0:0e0631af0305 1518 OutputArray magnitude, OutputArray angle,
RyoheiHagimoto 0:0e0631af0305 1519 bool angleInDegrees = false);
RyoheiHagimoto 0:0e0631af0305 1520
RyoheiHagimoto 0:0e0631af0305 1521 /** @brief Calculates the rotation angle of 2D vectors.
RyoheiHagimoto 0:0e0631af0305 1522
RyoheiHagimoto 0:0e0631af0305 1523 The function cv::phase calculates the rotation angle of each 2D vector that
RyoheiHagimoto 0:0e0631af0305 1524 is formed from the corresponding elements of x and y :
RyoheiHagimoto 0:0e0631af0305 1525 \f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f]
RyoheiHagimoto 0:0e0631af0305 1526
RyoheiHagimoto 0:0e0631af0305 1527 The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
RyoheiHagimoto 0:0e0631af0305 1528 the corresponding angle(I) is set to 0.
RyoheiHagimoto 0:0e0631af0305 1529 @param x input floating-point array of x-coordinates of 2D vectors.
RyoheiHagimoto 0:0e0631af0305 1530 @param y input array of y-coordinates of 2D vectors; it must have the
RyoheiHagimoto 0:0e0631af0305 1531 same size and the same type as x.
RyoheiHagimoto 0:0e0631af0305 1532 @param angle output array of vector angles; it has the same size and
RyoheiHagimoto 0:0e0631af0305 1533 same type as x .
RyoheiHagimoto 0:0e0631af0305 1534 @param angleInDegrees when true, the function calculates the angle in
RyoheiHagimoto 0:0e0631af0305 1535 degrees, otherwise, they are measured in radians.
RyoheiHagimoto 0:0e0631af0305 1536 */
RyoheiHagimoto 0:0e0631af0305 1537 CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle,
RyoheiHagimoto 0:0e0631af0305 1538 bool angleInDegrees = false);
RyoheiHagimoto 0:0e0631af0305 1539
RyoheiHagimoto 0:0e0631af0305 1540 /** @brief Calculates the magnitude of 2D vectors.
RyoheiHagimoto 0:0e0631af0305 1541
RyoheiHagimoto 0:0e0631af0305 1542 The function cv::magnitude calculates the magnitude of 2D vectors formed
RyoheiHagimoto 0:0e0631af0305 1543 from the corresponding elements of x and y arrays:
RyoheiHagimoto 0:0e0631af0305 1544 \f[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\f]
RyoheiHagimoto 0:0e0631af0305 1545 @param x floating-point array of x-coordinates of the vectors.
RyoheiHagimoto 0:0e0631af0305 1546 @param y floating-point array of y-coordinates of the vectors; it must
RyoheiHagimoto 0:0e0631af0305 1547 have the same size as x.
RyoheiHagimoto 0:0e0631af0305 1548 @param magnitude output array of the same size and type as x.
RyoheiHagimoto 0:0e0631af0305 1549 @sa cartToPolar, polarToCart, phase, sqrt
RyoheiHagimoto 0:0e0631af0305 1550 */
RyoheiHagimoto 0:0e0631af0305 1551 CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude);
RyoheiHagimoto 0:0e0631af0305 1552
RyoheiHagimoto 0:0e0631af0305 1553 /** @brief Checks every element of an input array for invalid values.
RyoheiHagimoto 0:0e0631af0305 1554
RyoheiHagimoto 0:0e0631af0305 1555 The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal \>
RyoheiHagimoto 0:0e0631af0305 1556 -DBL_MAX and maxVal \< DBL_MAX, the function also checks that each value is between minVal and
RyoheiHagimoto 0:0e0631af0305 1557 maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
RyoheiHagimoto 0:0e0631af0305 1558 are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
RyoheiHagimoto 0:0e0631af0305 1559 function either returns false (when quiet=true) or throws an exception.
RyoheiHagimoto 0:0e0631af0305 1560 @param a input array.
RyoheiHagimoto 0:0e0631af0305 1561 @param quiet a flag, indicating whether the functions quietly return false when the array elements
RyoheiHagimoto 0:0e0631af0305 1562 are out of range or they throw an exception.
RyoheiHagimoto 0:0e0631af0305 1563 @param pos optional output parameter, when not NULL, must be a pointer to array of src.dims
RyoheiHagimoto 0:0e0631af0305 1564 elements.
RyoheiHagimoto 0:0e0631af0305 1565 @param minVal inclusive lower boundary of valid values range.
RyoheiHagimoto 0:0e0631af0305 1566 @param maxVal exclusive upper boundary of valid values range.
RyoheiHagimoto 0:0e0631af0305 1567 */
RyoheiHagimoto 0:0e0631af0305 1568 CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0,
RyoheiHagimoto 0:0e0631af0305 1569 double minVal = -DBL_MAX, double maxVal = DBL_MAX);
RyoheiHagimoto 0:0e0631af0305 1570
RyoheiHagimoto 0:0e0631af0305 1571 /** @brief converts NaN's to the given number
RyoheiHagimoto 0:0e0631af0305 1572 */
RyoheiHagimoto 0:0e0631af0305 1573 CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0);
RyoheiHagimoto 0:0e0631af0305 1574
RyoheiHagimoto 0:0e0631af0305 1575 /** @brief Performs generalized matrix multiplication.
RyoheiHagimoto 0:0e0631af0305 1576
RyoheiHagimoto 0:0e0631af0305 1577 The function cv::gemm performs generalized matrix multiplication similar to the
RyoheiHagimoto 0:0e0631af0305 1578 gemm functions in BLAS level 3. For example,
RyoheiHagimoto 0:0e0631af0305 1579 `gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`
RyoheiHagimoto 0:0e0631af0305 1580 corresponds to
RyoheiHagimoto 0:0e0631af0305 1581 \f[\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\f]
RyoheiHagimoto 0:0e0631af0305 1582
RyoheiHagimoto 0:0e0631af0305 1583 In case of complex (two-channel) data, performed a complex matrix
RyoheiHagimoto 0:0e0631af0305 1584 multiplication.
RyoheiHagimoto 0:0e0631af0305 1585
RyoheiHagimoto 0:0e0631af0305 1586 The function can be replaced with a matrix expression. For example, the
RyoheiHagimoto 0:0e0631af0305 1587 above call can be replaced with:
RyoheiHagimoto 0:0e0631af0305 1588 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 1589 dst = alpha*src1.t()*src2 + beta*src3.t();
RyoheiHagimoto 0:0e0631af0305 1590 @endcode
RyoheiHagimoto 0:0e0631af0305 1591 @param src1 first multiplied input matrix that could be real(CV_32FC1,
RyoheiHagimoto 0:0e0631af0305 1592 CV_64FC1) or complex(CV_32FC2, CV_64FC2).
RyoheiHagimoto 0:0e0631af0305 1593 @param src2 second multiplied input matrix of the same type as src1.
RyoheiHagimoto 0:0e0631af0305 1594 @param alpha weight of the matrix product.
RyoheiHagimoto 0:0e0631af0305 1595 @param src3 third optional delta matrix added to the matrix product; it
RyoheiHagimoto 0:0e0631af0305 1596 should have the same type as src1 and src2.
RyoheiHagimoto 0:0e0631af0305 1597 @param beta weight of src3.
RyoheiHagimoto 0:0e0631af0305 1598 @param dst output matrix; it has the proper size and the same type as
RyoheiHagimoto 0:0e0631af0305 1599 input matrices.
RyoheiHagimoto 0:0e0631af0305 1600 @param flags operation flags (cv::GemmFlags)
RyoheiHagimoto 0:0e0631af0305 1601 @sa mulTransposed , transform
RyoheiHagimoto 0:0e0631af0305 1602 */
RyoheiHagimoto 0:0e0631af0305 1603 CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
RyoheiHagimoto 0:0e0631af0305 1604 InputArray src3, double beta, OutputArray dst, int flags = 0);
RyoheiHagimoto 0:0e0631af0305 1605
RyoheiHagimoto 0:0e0631af0305 1606 /** @brief Calculates the product of a matrix and its transposition.
RyoheiHagimoto 0:0e0631af0305 1607
RyoheiHagimoto 0:0e0631af0305 1608 The function cv::mulTransposed calculates the product of src and its
RyoheiHagimoto 0:0e0631af0305 1609 transposition:
RyoheiHagimoto 0:0e0631af0305 1610 \f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\f]
RyoheiHagimoto 0:0e0631af0305 1611 if aTa=true , and
RyoheiHagimoto 0:0e0631af0305 1612 \f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\f]
RyoheiHagimoto 0:0e0631af0305 1613 otherwise. The function is used to calculate the covariance matrix. With
RyoheiHagimoto 0:0e0631af0305 1614 zero delta, it can be used as a faster substitute for general matrix
RyoheiHagimoto 0:0e0631af0305 1615 product A\*B when B=A'
RyoheiHagimoto 0:0e0631af0305 1616 @param src input single-channel matrix. Note that unlike gemm, the
RyoheiHagimoto 0:0e0631af0305 1617 function can multiply not only floating-point matrices.
RyoheiHagimoto 0:0e0631af0305 1618 @param dst output square matrix.
RyoheiHagimoto 0:0e0631af0305 1619 @param aTa Flag specifying the multiplication ordering. See the
RyoheiHagimoto 0:0e0631af0305 1620 description below.
RyoheiHagimoto 0:0e0631af0305 1621 @param delta Optional delta matrix subtracted from src before the
RyoheiHagimoto 0:0e0631af0305 1622 multiplication. When the matrix is empty ( delta=noArray() ), it is
RyoheiHagimoto 0:0e0631af0305 1623 assumed to be zero, that is, nothing is subtracted. If it has the same
RyoheiHagimoto 0:0e0631af0305 1624 size as src , it is simply subtracted. Otherwise, it is "repeated" (see
RyoheiHagimoto 0:0e0631af0305 1625 repeat ) to cover the full src and then subtracted. Type of the delta
RyoheiHagimoto 0:0e0631af0305 1626 matrix, when it is not empty, must be the same as the type of created
RyoheiHagimoto 0:0e0631af0305 1627 output matrix. See the dtype parameter description below.
RyoheiHagimoto 0:0e0631af0305 1628 @param scale Optional scale factor for the matrix product.
RyoheiHagimoto 0:0e0631af0305 1629 @param dtype Optional type of the output matrix. When it is negative,
RyoheiHagimoto 0:0e0631af0305 1630 the output matrix will have the same type as src . Otherwise, it will be
RyoheiHagimoto 0:0e0631af0305 1631 type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
RyoheiHagimoto 0:0e0631af0305 1632 @sa calcCovarMatrix, gemm, repeat, reduce
RyoheiHagimoto 0:0e0631af0305 1633 */
RyoheiHagimoto 0:0e0631af0305 1634 CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
RyoheiHagimoto 0:0e0631af0305 1635 InputArray delta = noArray(),
RyoheiHagimoto 0:0e0631af0305 1636 double scale = 1, int dtype = -1 );
RyoheiHagimoto 0:0e0631af0305 1637
RyoheiHagimoto 0:0e0631af0305 1638 /** @brief Transposes a matrix.
RyoheiHagimoto 0:0e0631af0305 1639
RyoheiHagimoto 0:0e0631af0305 1640 The function cv::transpose transposes the matrix src :
RyoheiHagimoto 0:0e0631af0305 1641 \f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
RyoheiHagimoto 0:0e0631af0305 1642 @note No complex conjugation is done in case of a complex matrix. It it
RyoheiHagimoto 0:0e0631af0305 1643 should be done separately if needed.
RyoheiHagimoto 0:0e0631af0305 1644 @param src input array.
RyoheiHagimoto 0:0e0631af0305 1645 @param dst output array of the same type as src.
RyoheiHagimoto 0:0e0631af0305 1646 */
RyoheiHagimoto 0:0e0631af0305 1647 CV_EXPORTS_W void transpose(InputArray src, OutputArray dst);
RyoheiHagimoto 0:0e0631af0305 1648
RyoheiHagimoto 0:0e0631af0305 1649 /** @brief Performs the matrix transformation of every array element.
RyoheiHagimoto 0:0e0631af0305 1650
RyoheiHagimoto 0:0e0631af0305 1651 The function cv::transform performs the matrix transformation of every
RyoheiHagimoto 0:0e0631af0305 1652 element of the array src and stores the results in dst :
RyoheiHagimoto 0:0e0631af0305 1653 \f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f]
RyoheiHagimoto 0:0e0631af0305 1654 (when m.cols=src.channels() ), or
RyoheiHagimoto 0:0e0631af0305 1655 \f[\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\f]
RyoheiHagimoto 0:0e0631af0305 1656 (when m.cols=src.channels()+1 )
RyoheiHagimoto 0:0e0631af0305 1657
RyoheiHagimoto 0:0e0631af0305 1658 Every element of the N -channel array src is interpreted as N -element
RyoheiHagimoto 0:0e0631af0305 1659 vector that is transformed using the M x N or M x (N+1) matrix m to
RyoheiHagimoto 0:0e0631af0305 1660 M-element vector - the corresponding element of the output array dst .
RyoheiHagimoto 0:0e0631af0305 1661
RyoheiHagimoto 0:0e0631af0305 1662 The function may be used for geometrical transformation of
RyoheiHagimoto 0:0e0631af0305 1663 N -dimensional points, arbitrary linear color space transformation (such
RyoheiHagimoto 0:0e0631af0305 1664 as various kinds of RGB to YUV transforms), shuffling the image
RyoheiHagimoto 0:0e0631af0305 1665 channels, and so forth.
RyoheiHagimoto 0:0e0631af0305 1666 @param src input array that must have as many channels (1 to 4) as
RyoheiHagimoto 0:0e0631af0305 1667 m.cols or m.cols-1.
RyoheiHagimoto 0:0e0631af0305 1668 @param dst output array of the same size and depth as src; it has as
RyoheiHagimoto 0:0e0631af0305 1669 many channels as m.rows.
RyoheiHagimoto 0:0e0631af0305 1670 @param m transformation 2x2 or 2x3 floating-point matrix.
RyoheiHagimoto 0:0e0631af0305 1671 @sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
RyoheiHagimoto 0:0e0631af0305 1672 */
RyoheiHagimoto 0:0e0631af0305 1673 CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m );
RyoheiHagimoto 0:0e0631af0305 1674
RyoheiHagimoto 0:0e0631af0305 1675 /** @brief Performs the perspective matrix transformation of vectors.
RyoheiHagimoto 0:0e0631af0305 1676
RyoheiHagimoto 0:0e0631af0305 1677 The function cv::perspectiveTransform transforms every element of src by
RyoheiHagimoto 0:0e0631af0305 1678 treating it as a 2D or 3D vector, in the following way:
RyoheiHagimoto 0:0e0631af0305 1679 \f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f]
RyoheiHagimoto 0:0e0631af0305 1680 where
RyoheiHagimoto 0:0e0631af0305 1681 \f[(x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}\f]
RyoheiHagimoto 0:0e0631af0305 1682 and
RyoheiHagimoto 0:0e0631af0305 1683 \f[w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\f]
RyoheiHagimoto 0:0e0631af0305 1684
RyoheiHagimoto 0:0e0631af0305 1685 Here a 3D vector transformation is shown. In case of a 2D vector
RyoheiHagimoto 0:0e0631af0305 1686 transformation, the z component is omitted.
RyoheiHagimoto 0:0e0631af0305 1687
RyoheiHagimoto 0:0e0631af0305 1688 @note The function transforms a sparse set of 2D or 3D vectors. If you
RyoheiHagimoto 0:0e0631af0305 1689 want to transform an image using perspective transformation, use
RyoheiHagimoto 0:0e0631af0305 1690 warpPerspective . If you have an inverse problem, that is, you want to
RyoheiHagimoto 0:0e0631af0305 1691 compute the most probable perspective transformation out of several
RyoheiHagimoto 0:0e0631af0305 1692 pairs of corresponding points, you can use getPerspectiveTransform or
RyoheiHagimoto 0:0e0631af0305 1693 findHomography .
RyoheiHagimoto 0:0e0631af0305 1694 @param src input two-channel or three-channel floating-point array; each
RyoheiHagimoto 0:0e0631af0305 1695 element is a 2D/3D vector to be transformed.
RyoheiHagimoto 0:0e0631af0305 1696 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1697 @param m 3x3 or 4x4 floating-point transformation matrix.
RyoheiHagimoto 0:0e0631af0305 1698 @sa transform, warpPerspective, getPerspectiveTransform, findHomography
RyoheiHagimoto 0:0e0631af0305 1699 */
RyoheiHagimoto 0:0e0631af0305 1700 CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArray m );
RyoheiHagimoto 0:0e0631af0305 1701
RyoheiHagimoto 0:0e0631af0305 1702 /** @brief Copies the lower or the upper half of a square matrix to another half.
RyoheiHagimoto 0:0e0631af0305 1703
RyoheiHagimoto 0:0e0631af0305 1704 The function cv::completeSymm copies the lower half of a square matrix to
RyoheiHagimoto 0:0e0631af0305 1705 its another half. The matrix diagonal remains unchanged:
RyoheiHagimoto 0:0e0631af0305 1706 * \f$\texttt{mtx}_{ij}=\texttt{mtx}_{ji}\f$ for \f$i > j\f$ if
RyoheiHagimoto 0:0e0631af0305 1707 lowerToUpper=false
RyoheiHagimoto 0:0e0631af0305 1708 * \f$\texttt{mtx}_{ij}=\texttt{mtx}_{ji}\f$ for \f$i < j\f$ if
RyoheiHagimoto 0:0e0631af0305 1709 lowerToUpper=true
RyoheiHagimoto 0:0e0631af0305 1710 @param mtx input-output floating-point square matrix.
RyoheiHagimoto 0:0e0631af0305 1711 @param lowerToUpper operation flag; if true, the lower half is copied to
RyoheiHagimoto 0:0e0631af0305 1712 the upper half. Otherwise, the upper half is copied to the lower half.
RyoheiHagimoto 0:0e0631af0305 1713 @sa flip, transpose
RyoheiHagimoto 0:0e0631af0305 1714 */
RyoheiHagimoto 0:0e0631af0305 1715 CV_EXPORTS_W void completeSymm(InputOutputArray mtx, bool lowerToUpper = false);
RyoheiHagimoto 0:0e0631af0305 1716
RyoheiHagimoto 0:0e0631af0305 1717 /** @brief Initializes a scaled identity matrix.
RyoheiHagimoto 0:0e0631af0305 1718
RyoheiHagimoto 0:0e0631af0305 1719 The function cv::setIdentity initializes a scaled identity matrix:
RyoheiHagimoto 0:0e0631af0305 1720 \f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f]
RyoheiHagimoto 0:0e0631af0305 1721
RyoheiHagimoto 0:0e0631af0305 1722 The function can also be emulated using the matrix initializers and the
RyoheiHagimoto 0:0e0631af0305 1723 matrix expressions:
RyoheiHagimoto 0:0e0631af0305 1724 @code
RyoheiHagimoto 0:0e0631af0305 1725 Mat A = Mat::eye(4, 3, CV_32F)*5;
RyoheiHagimoto 0:0e0631af0305 1726 // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
RyoheiHagimoto 0:0e0631af0305 1727 @endcode
RyoheiHagimoto 0:0e0631af0305 1728 @param mtx matrix to initialize (not necessarily square).
RyoheiHagimoto 0:0e0631af0305 1729 @param s value to assign to diagonal elements.
RyoheiHagimoto 0:0e0631af0305 1730 @sa Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
RyoheiHagimoto 0:0e0631af0305 1731 */
RyoheiHagimoto 0:0e0631af0305 1732 CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s = Scalar(1));
RyoheiHagimoto 0:0e0631af0305 1733
RyoheiHagimoto 0:0e0631af0305 1734 /** @brief Returns the determinant of a square floating-point matrix.
RyoheiHagimoto 0:0e0631af0305 1735
RyoheiHagimoto 0:0e0631af0305 1736 The function cv::determinant calculates and returns the determinant of the
RyoheiHagimoto 0:0e0631af0305 1737 specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the
RyoheiHagimoto 0:0e0631af0305 1738 direct method is used. For larger matrices, the function uses LU
RyoheiHagimoto 0:0e0631af0305 1739 factorization with partial pivoting.
RyoheiHagimoto 0:0e0631af0305 1740
RyoheiHagimoto 0:0e0631af0305 1741 For symmetric positively-determined matrices, it is also possible to use
RyoheiHagimoto 0:0e0631af0305 1742 eigen decomposition to calculate the determinant.
RyoheiHagimoto 0:0e0631af0305 1743 @param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and
RyoheiHagimoto 0:0e0631af0305 1744 square size.
RyoheiHagimoto 0:0e0631af0305 1745 @sa trace, invert, solve, eigen, @ref MatrixExpressions
RyoheiHagimoto 0:0e0631af0305 1746 */
RyoheiHagimoto 0:0e0631af0305 1747 CV_EXPORTS_W double determinant(InputArray mtx);
RyoheiHagimoto 0:0e0631af0305 1748
RyoheiHagimoto 0:0e0631af0305 1749 /** @brief Returns the trace of a matrix.
RyoheiHagimoto 0:0e0631af0305 1750
RyoheiHagimoto 0:0e0631af0305 1751 The function cv::trace returns the sum of the diagonal elements of the
RyoheiHagimoto 0:0e0631af0305 1752 matrix mtx .
RyoheiHagimoto 0:0e0631af0305 1753 \f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f]
RyoheiHagimoto 0:0e0631af0305 1754 @param mtx input matrix.
RyoheiHagimoto 0:0e0631af0305 1755 */
RyoheiHagimoto 0:0e0631af0305 1756 CV_EXPORTS_W Scalar trace(InputArray mtx);
RyoheiHagimoto 0:0e0631af0305 1757
RyoheiHagimoto 0:0e0631af0305 1758 /** @brief Finds the inverse or pseudo-inverse of a matrix.
RyoheiHagimoto 0:0e0631af0305 1759
RyoheiHagimoto 0:0e0631af0305 1760 The function cv::invert inverts the matrix src and stores the result in dst
RyoheiHagimoto 0:0e0631af0305 1761 . When the matrix src is singular or non-square, the function calculates
RyoheiHagimoto 0:0e0631af0305 1762 the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
RyoheiHagimoto 0:0e0631af0305 1763 minimal, where I is an identity matrix.
RyoheiHagimoto 0:0e0631af0305 1764
RyoheiHagimoto 0:0e0631af0305 1765 In case of the DECOMP_LU method, the function returns non-zero value if
RyoheiHagimoto 0:0e0631af0305 1766 the inverse has been successfully calculated and 0 if src is singular.
RyoheiHagimoto 0:0e0631af0305 1767
RyoheiHagimoto 0:0e0631af0305 1768 In case of the DECOMP_SVD method, the function returns the inverse
RyoheiHagimoto 0:0e0631af0305 1769 condition number of src (the ratio of the smallest singular value to the
RyoheiHagimoto 0:0e0631af0305 1770 largest singular value) and 0 if src is singular. The SVD method
RyoheiHagimoto 0:0e0631af0305 1771 calculates a pseudo-inverse matrix if src is singular.
RyoheiHagimoto 0:0e0631af0305 1772
RyoheiHagimoto 0:0e0631af0305 1773 Similarly to DECOMP_LU, the method DECOMP_CHOLESKY works only with
RyoheiHagimoto 0:0e0631af0305 1774 non-singular square matrices that should also be symmetrical and
RyoheiHagimoto 0:0e0631af0305 1775 positively defined. In this case, the function stores the inverted
RyoheiHagimoto 0:0e0631af0305 1776 matrix in dst and returns non-zero. Otherwise, it returns 0.
RyoheiHagimoto 0:0e0631af0305 1777
RyoheiHagimoto 0:0e0631af0305 1778 @param src input floating-point M x N matrix.
RyoheiHagimoto 0:0e0631af0305 1779 @param dst output matrix of N x M size and the same type as src.
RyoheiHagimoto 0:0e0631af0305 1780 @param flags inversion method (cv::DecompTypes)
RyoheiHagimoto 0:0e0631af0305 1781 @sa solve, SVD
RyoheiHagimoto 0:0e0631af0305 1782 */
RyoheiHagimoto 0:0e0631af0305 1783 CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_LU);
RyoheiHagimoto 0:0e0631af0305 1784
RyoheiHagimoto 0:0e0631af0305 1785 /** @brief Solves one or more linear systems or least-squares problems.
RyoheiHagimoto 0:0e0631af0305 1786
RyoheiHagimoto 0:0e0631af0305 1787 The function cv::solve solves a linear system or least-squares problem (the
RyoheiHagimoto 0:0e0631af0305 1788 latter is possible with SVD or QR methods, or by specifying the flag
RyoheiHagimoto 0:0e0631af0305 1789 DECOMP_NORMAL ):
RyoheiHagimoto 0:0e0631af0305 1790 \f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f]
RyoheiHagimoto 0:0e0631af0305 1791
RyoheiHagimoto 0:0e0631af0305 1792 If DECOMP_LU or DECOMP_CHOLESKY method is used, the function returns 1
RyoheiHagimoto 0:0e0631af0305 1793 if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise,
RyoheiHagimoto 0:0e0631af0305 1794 it returns 0. In the latter case, dst is not valid. Other methods find a
RyoheiHagimoto 0:0e0631af0305 1795 pseudo-solution in case of a singular left-hand side part.
RyoheiHagimoto 0:0e0631af0305 1796
RyoheiHagimoto 0:0e0631af0305 1797 @note If you want to find a unity-norm solution of an under-defined
RyoheiHagimoto 0:0e0631af0305 1798 singular system \f$\texttt{src1}\cdot\texttt{dst}=0\f$ , the function solve
RyoheiHagimoto 0:0e0631af0305 1799 will not do the work. Use SVD::solveZ instead.
RyoheiHagimoto 0:0e0631af0305 1800
RyoheiHagimoto 0:0e0631af0305 1801 @param src1 input matrix on the left-hand side of the system.
RyoheiHagimoto 0:0e0631af0305 1802 @param src2 input matrix on the right-hand side of the system.
RyoheiHagimoto 0:0e0631af0305 1803 @param dst output solution.
RyoheiHagimoto 0:0e0631af0305 1804 @param flags solution (matrix inversion) method (cv::DecompTypes)
RyoheiHagimoto 0:0e0631af0305 1805 @sa invert, SVD, eigen
RyoheiHagimoto 0:0e0631af0305 1806 */
RyoheiHagimoto 0:0e0631af0305 1807 CV_EXPORTS_W bool solve(InputArray src1, InputArray src2,
RyoheiHagimoto 0:0e0631af0305 1808 OutputArray dst, int flags = DECOMP_LU);
RyoheiHagimoto 0:0e0631af0305 1809
RyoheiHagimoto 0:0e0631af0305 1810 /** @brief Sorts each row or each column of a matrix.
RyoheiHagimoto 0:0e0631af0305 1811
RyoheiHagimoto 0:0e0631af0305 1812 The function cv::sort sorts each matrix row or each matrix column in
RyoheiHagimoto 0:0e0631af0305 1813 ascending or descending order. So you should pass two operation flags to
RyoheiHagimoto 0:0e0631af0305 1814 get desired behaviour. If you want to sort matrix rows or columns
RyoheiHagimoto 0:0e0631af0305 1815 lexicographically, you can use STL std::sort generic function with the
RyoheiHagimoto 0:0e0631af0305 1816 proper comparison predicate.
RyoheiHagimoto 0:0e0631af0305 1817
RyoheiHagimoto 0:0e0631af0305 1818 @param src input single-channel array.
RyoheiHagimoto 0:0e0631af0305 1819 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 1820 @param flags operation flags, a combination of cv::SortFlags
RyoheiHagimoto 0:0e0631af0305 1821 @sa sortIdx, randShuffle
RyoheiHagimoto 0:0e0631af0305 1822 */
RyoheiHagimoto 0:0e0631af0305 1823 CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags);
RyoheiHagimoto 0:0e0631af0305 1824
RyoheiHagimoto 0:0e0631af0305 1825 /** @brief Sorts each row or each column of a matrix.
RyoheiHagimoto 0:0e0631af0305 1826
RyoheiHagimoto 0:0e0631af0305 1827 The function cv::sortIdx sorts each matrix row or each matrix column in the
RyoheiHagimoto 0:0e0631af0305 1828 ascending or descending order. So you should pass two operation flags to
RyoheiHagimoto 0:0e0631af0305 1829 get desired behaviour. Instead of reordering the elements themselves, it
RyoheiHagimoto 0:0e0631af0305 1830 stores the indices of sorted elements in the output array. For example:
RyoheiHagimoto 0:0e0631af0305 1831 @code
RyoheiHagimoto 0:0e0631af0305 1832 Mat A = Mat::eye(3,3,CV_32F), B;
RyoheiHagimoto 0:0e0631af0305 1833 sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
RyoheiHagimoto 0:0e0631af0305 1834 // B will probably contain
RyoheiHagimoto 0:0e0631af0305 1835 // (because of equal elements in A some permutations are possible):
RyoheiHagimoto 0:0e0631af0305 1836 // [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
RyoheiHagimoto 0:0e0631af0305 1837 @endcode
RyoheiHagimoto 0:0e0631af0305 1838 @param src input single-channel array.
RyoheiHagimoto 0:0e0631af0305 1839 @param dst output integer array of the same size as src.
RyoheiHagimoto 0:0e0631af0305 1840 @param flags operation flags that could be a combination of cv::SortFlags
RyoheiHagimoto 0:0e0631af0305 1841 @sa sort, randShuffle
RyoheiHagimoto 0:0e0631af0305 1842 */
RyoheiHagimoto 0:0e0631af0305 1843 CV_EXPORTS_W void sortIdx(InputArray src, OutputArray dst, int flags);
RyoheiHagimoto 0:0e0631af0305 1844
RyoheiHagimoto 0:0e0631af0305 1845 /** @brief Finds the real roots of a cubic equation.
RyoheiHagimoto 0:0e0631af0305 1846
RyoheiHagimoto 0:0e0631af0305 1847 The function solveCubic finds the real roots of a cubic equation:
RyoheiHagimoto 0:0e0631af0305 1848 - if coeffs is a 4-element vector:
RyoheiHagimoto 0:0e0631af0305 1849 \f[\texttt{coeffs} [0] x^3 + \texttt{coeffs} [1] x^2 + \texttt{coeffs} [2] x + \texttt{coeffs} [3] = 0\f]
RyoheiHagimoto 0:0e0631af0305 1850 - if coeffs is a 3-element vector:
RyoheiHagimoto 0:0e0631af0305 1851 \f[x^3 + \texttt{coeffs} [0] x^2 + \texttt{coeffs} [1] x + \texttt{coeffs} [2] = 0\f]
RyoheiHagimoto 0:0e0631af0305 1852
RyoheiHagimoto 0:0e0631af0305 1853 The roots are stored in the roots array.
RyoheiHagimoto 0:0e0631af0305 1854 @param coeffs equation coefficients, an array of 3 or 4 elements.
RyoheiHagimoto 0:0e0631af0305 1855 @param roots output array of real roots that has 1 or 3 elements.
RyoheiHagimoto 0:0e0631af0305 1856 */
RyoheiHagimoto 0:0e0631af0305 1857 CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots);
RyoheiHagimoto 0:0e0631af0305 1858
RyoheiHagimoto 0:0e0631af0305 1859 /** @brief Finds the real or complex roots of a polynomial equation.
RyoheiHagimoto 0:0e0631af0305 1860
RyoheiHagimoto 0:0e0631af0305 1861 The function cv::solvePoly finds real and complex roots of a polynomial equation:
RyoheiHagimoto 0:0e0631af0305 1862 \f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f]
RyoheiHagimoto 0:0e0631af0305 1863 @param coeffs array of polynomial coefficients.
RyoheiHagimoto 0:0e0631af0305 1864 @param roots output (complex) array of roots.
RyoheiHagimoto 0:0e0631af0305 1865 @param maxIters maximum number of iterations the algorithm does.
RyoheiHagimoto 0:0e0631af0305 1866 */
RyoheiHagimoto 0:0e0631af0305 1867 CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters = 300);
RyoheiHagimoto 0:0e0631af0305 1868
RyoheiHagimoto 0:0e0631af0305 1869 /** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix.
RyoheiHagimoto 0:0e0631af0305 1870
RyoheiHagimoto 0:0e0631af0305 1871 The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
RyoheiHagimoto 0:0e0631af0305 1872 matrix src:
RyoheiHagimoto 0:0e0631af0305 1873 @code
RyoheiHagimoto 0:0e0631af0305 1874 src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
RyoheiHagimoto 0:0e0631af0305 1875 @endcode
RyoheiHagimoto 0:0e0631af0305 1876 @note in the new and the old interfaces different ordering of eigenvalues and eigenvectors
RyoheiHagimoto 0:0e0631af0305 1877 parameters is used.
RyoheiHagimoto 0:0e0631af0305 1878 @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
RyoheiHagimoto 0:0e0631af0305 1879 (src ^T^ == src).
RyoheiHagimoto 0:0e0631af0305 1880 @param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
RyoheiHagimoto 0:0e0631af0305 1881 in the descending order.
RyoheiHagimoto 0:0e0631af0305 1882 @param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the
RyoheiHagimoto 0:0e0631af0305 1883 eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
RyoheiHagimoto 0:0e0631af0305 1884 eigenvalues.
RyoheiHagimoto 0:0e0631af0305 1885 @sa completeSymm , PCA
RyoheiHagimoto 0:0e0631af0305 1886 */
RyoheiHagimoto 0:0e0631af0305 1887 CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues,
RyoheiHagimoto 0:0e0631af0305 1888 OutputArray eigenvectors = noArray());
RyoheiHagimoto 0:0e0631af0305 1889
RyoheiHagimoto 0:0e0631af0305 1890 /** @brief Calculates the covariance matrix of a set of vectors.
RyoheiHagimoto 0:0e0631af0305 1891
RyoheiHagimoto 0:0e0631af0305 1892 The function cv::calcCovarMatrix calculates the covariance matrix and, optionally, the mean vector of
RyoheiHagimoto 0:0e0631af0305 1893 the set of input vectors.
RyoheiHagimoto 0:0e0631af0305 1894 @param samples samples stored as separate matrices
RyoheiHagimoto 0:0e0631af0305 1895 @param nsamples number of samples
RyoheiHagimoto 0:0e0631af0305 1896 @param covar output covariance matrix of the type ctype and square size.
RyoheiHagimoto 0:0e0631af0305 1897 @param mean input or output (depending on the flags) array as the average value of the input vectors.
RyoheiHagimoto 0:0e0631af0305 1898 @param flags operation flags as a combination of cv::CovarFlags
RyoheiHagimoto 0:0e0631af0305 1899 @param ctype type of the matrixl; it equals 'CV_64F' by default.
RyoheiHagimoto 0:0e0631af0305 1900 @sa PCA, mulTransposed, Mahalanobis
RyoheiHagimoto 0:0e0631af0305 1901 @todo InputArrayOfArrays
RyoheiHagimoto 0:0e0631af0305 1902 */
RyoheiHagimoto 0:0e0631af0305 1903 CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean,
RyoheiHagimoto 0:0e0631af0305 1904 int flags, int ctype = CV_64F);
RyoheiHagimoto 0:0e0631af0305 1905
RyoheiHagimoto 0:0e0631af0305 1906 /** @overload
RyoheiHagimoto 0:0e0631af0305 1907 @note use cv::COVAR_ROWS or cv::COVAR_COLS flag
RyoheiHagimoto 0:0e0631af0305 1908 @param samples samples stored as rows/columns of a single matrix.
RyoheiHagimoto 0:0e0631af0305 1909 @param covar output covariance matrix of the type ctype and square size.
RyoheiHagimoto 0:0e0631af0305 1910 @param mean input or output (depending on the flags) array as the average value of the input vectors.
RyoheiHagimoto 0:0e0631af0305 1911 @param flags operation flags as a combination of cv::CovarFlags
RyoheiHagimoto 0:0e0631af0305 1912 @param ctype type of the matrixl; it equals 'CV_64F' by default.
RyoheiHagimoto 0:0e0631af0305 1913 */
RyoheiHagimoto 0:0e0631af0305 1914 CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar,
RyoheiHagimoto 0:0e0631af0305 1915 InputOutputArray mean, int flags, int ctype = CV_64F);
RyoheiHagimoto 0:0e0631af0305 1916
RyoheiHagimoto 0:0e0631af0305 1917 /** wrap PCA::operator() */
RyoheiHagimoto 0:0e0631af0305 1918 CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
RyoheiHagimoto 0:0e0631af0305 1919 OutputArray eigenvectors, int maxComponents = 0);
RyoheiHagimoto 0:0e0631af0305 1920
RyoheiHagimoto 0:0e0631af0305 1921 /** wrap PCA::operator() */
RyoheiHagimoto 0:0e0631af0305 1922 CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
RyoheiHagimoto 0:0e0631af0305 1923 OutputArray eigenvectors, double retainedVariance);
RyoheiHagimoto 0:0e0631af0305 1924
RyoheiHagimoto 0:0e0631af0305 1925 /** wrap PCA::project */
RyoheiHagimoto 0:0e0631af0305 1926 CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
RyoheiHagimoto 0:0e0631af0305 1927 InputArray eigenvectors, OutputArray result);
RyoheiHagimoto 0:0e0631af0305 1928
RyoheiHagimoto 0:0e0631af0305 1929 /** wrap PCA::backProject */
RyoheiHagimoto 0:0e0631af0305 1930 CV_EXPORTS_W void PCABackProject(InputArray data, InputArray mean,
RyoheiHagimoto 0:0e0631af0305 1931 InputArray eigenvectors, OutputArray result);
RyoheiHagimoto 0:0e0631af0305 1932
RyoheiHagimoto 0:0e0631af0305 1933 /** wrap SVD::compute */
RyoheiHagimoto 0:0e0631af0305 1934 CV_EXPORTS_W void SVDecomp( InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags = 0 );
RyoheiHagimoto 0:0e0631af0305 1935
RyoheiHagimoto 0:0e0631af0305 1936 /** wrap SVD::backSubst */
RyoheiHagimoto 0:0e0631af0305 1937 CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt,
RyoheiHagimoto 0:0e0631af0305 1938 InputArray rhs, OutputArray dst );
RyoheiHagimoto 0:0e0631af0305 1939
RyoheiHagimoto 0:0e0631af0305 1940 /** @brief Calculates the Mahalanobis distance between two vectors.
RyoheiHagimoto 0:0e0631af0305 1941
RyoheiHagimoto 0:0e0631af0305 1942 The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
RyoheiHagimoto 0:0e0631af0305 1943 \f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f]
RyoheiHagimoto 0:0e0631af0305 1944 The covariance matrix may be calculated using the cv::calcCovarMatrix function and then inverted using
RyoheiHagimoto 0:0e0631af0305 1945 the invert function (preferably using the cv::DECOMP_SVD method, as the most accurate).
RyoheiHagimoto 0:0e0631af0305 1946 @param v1 first 1D input vector.
RyoheiHagimoto 0:0e0631af0305 1947 @param v2 second 1D input vector.
RyoheiHagimoto 0:0e0631af0305 1948 @param icovar inverse covariance matrix.
RyoheiHagimoto 0:0e0631af0305 1949 */
RyoheiHagimoto 0:0e0631af0305 1950 CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar);
RyoheiHagimoto 0:0e0631af0305 1951
RyoheiHagimoto 0:0e0631af0305 1952 /** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
RyoheiHagimoto 0:0e0631af0305 1953
RyoheiHagimoto 0:0e0631af0305 1954 The function cv::dft performs one of the following:
RyoheiHagimoto 0:0e0631af0305 1955 - Forward the Fourier transform of a 1D vector of N elements:
RyoheiHagimoto 0:0e0631af0305 1956 \f[Y = F^{(N)} \cdot X,\f]
RyoheiHagimoto 0:0e0631af0305 1957 where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$
RyoheiHagimoto 0:0e0631af0305 1958 - Inverse the Fourier transform of a 1D vector of N elements:
RyoheiHagimoto 0:0e0631af0305 1959 \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 1960 where \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$
RyoheiHagimoto 0:0e0631af0305 1961 - Forward the 2D Fourier transform of a M x N matrix:
RyoheiHagimoto 0:0e0631af0305 1962 \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f]
RyoheiHagimoto 0:0e0631af0305 1963 - Inverse the 2D Fourier transform of a M x N matrix:
RyoheiHagimoto 0:0e0631af0305 1964 \f[\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\f]
RyoheiHagimoto 0:0e0631af0305 1965
RyoheiHagimoto 0:0e0631af0305 1966 In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
RyoheiHagimoto 0:0e0631af0305 1967 spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
RyoheiHagimoto 0:0e0631af0305 1968 (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
RyoheiHagimoto 0:0e0631af0305 1969 is how 2D *CCS* spectrum looks:
RyoheiHagimoto 0:0e0631af0305 1970 \f[\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\f]
RyoheiHagimoto 0:0e0631af0305 1971
RyoheiHagimoto 0:0e0631af0305 1972 In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
RyoheiHagimoto 0:0e0631af0305 1973
RyoheiHagimoto 0:0e0631af0305 1974 So, the function chooses an operation mode depending on the flags and size of the input array:
RyoheiHagimoto 0:0e0631af0305 1975 - If DFT_ROWS is set or the input array has a single row or single column, the function
RyoheiHagimoto 0:0e0631af0305 1976 performs a 1D forward or inverse transform of each row of a matrix when DFT_ROWS is set.
RyoheiHagimoto 0:0e0631af0305 1977 Otherwise, it performs a 2D transform.
RyoheiHagimoto 0:0e0631af0305 1978 - If the input array is real and DFT_INVERSE is not set, the function performs a forward 1D or
RyoheiHagimoto 0:0e0631af0305 1979 2D transform:
RyoheiHagimoto 0:0e0631af0305 1980 - When DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
RyoheiHagimoto 0:0e0631af0305 1981 input.
RyoheiHagimoto 0:0e0631af0305 1982 - When DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
RyoheiHagimoto 0:0e0631af0305 1983 input. In case of 2D transform, it uses the packed format as shown above. In case of a
RyoheiHagimoto 0:0e0631af0305 1984 single 1D transform, it looks like the first row of the matrix above. In case of
RyoheiHagimoto 0:0e0631af0305 1985 multiple 1D transforms (when using the DFT_ROWS flag), each row of the output matrix
RyoheiHagimoto 0:0e0631af0305 1986 looks like the first row of the matrix above.
RyoheiHagimoto 0:0e0631af0305 1987 - If the input array is complex and either DFT_INVERSE or DFT_REAL_OUTPUT are not set, the
RyoheiHagimoto 0:0e0631af0305 1988 output is a complex array of the same size as input. The function performs a forward or
RyoheiHagimoto 0:0e0631af0305 1989 inverse 1D or 2D transform of the whole input array or each row of the input array
RyoheiHagimoto 0:0e0631af0305 1990 independently, depending on the flags DFT_INVERSE and DFT_ROWS.
RyoheiHagimoto 0:0e0631af0305 1991 - When DFT_INVERSE is set and the input array is real, or it is complex but DFT_REAL_OUTPUT
RyoheiHagimoto 0:0e0631af0305 1992 is set, the output is a real array of the same size as input. The function performs a 1D or 2D
RyoheiHagimoto 0:0e0631af0305 1993 inverse transformation of the whole input array or each individual row, depending on the flags
RyoheiHagimoto 0:0e0631af0305 1994 DFT_INVERSE and DFT_ROWS.
RyoheiHagimoto 0:0e0631af0305 1995
RyoheiHagimoto 0:0e0631af0305 1996 If DFT_SCALE is set, the scaling is done after the transformation.
RyoheiHagimoto 0:0e0631af0305 1997
RyoheiHagimoto 0:0e0631af0305 1998 Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
RyoheiHagimoto 0:0e0631af0305 1999 efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
RyoheiHagimoto 0:0e0631af0305 2000 current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
RyoheiHagimoto 0:0e0631af0305 2001 method.
RyoheiHagimoto 0:0e0631af0305 2002
RyoheiHagimoto 0:0e0631af0305 2003 The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
RyoheiHagimoto 0:0e0631af0305 2004 @code
RyoheiHagimoto 0:0e0631af0305 2005 void convolveDFT(InputArray A, InputArray B, OutputArray C)
RyoheiHagimoto 0:0e0631af0305 2006 {
RyoheiHagimoto 0:0e0631af0305 2007 // reallocate the output array if needed
RyoheiHagimoto 0:0e0631af0305 2008 C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
RyoheiHagimoto 0:0e0631af0305 2009 Size dftSize;
RyoheiHagimoto 0:0e0631af0305 2010 // calculate the size of DFT transform
RyoheiHagimoto 0:0e0631af0305 2011 dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
RyoheiHagimoto 0:0e0631af0305 2012 dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
RyoheiHagimoto 0:0e0631af0305 2013
RyoheiHagimoto 0:0e0631af0305 2014 // allocate temporary buffers and initialize them with 0's
RyoheiHagimoto 0:0e0631af0305 2015 Mat tempA(dftSize, A.type(), Scalar::all(0));
RyoheiHagimoto 0:0e0631af0305 2016 Mat tempB(dftSize, B.type(), Scalar::all(0));
RyoheiHagimoto 0:0e0631af0305 2017
RyoheiHagimoto 0:0e0631af0305 2018 // copy A and B to the top-left corners of tempA and tempB, respectively
RyoheiHagimoto 0:0e0631af0305 2019 Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
RyoheiHagimoto 0:0e0631af0305 2020 A.copyTo(roiA);
RyoheiHagimoto 0:0e0631af0305 2021 Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
RyoheiHagimoto 0:0e0631af0305 2022 B.copyTo(roiB);
RyoheiHagimoto 0:0e0631af0305 2023
RyoheiHagimoto 0:0e0631af0305 2024 // now transform the padded A & B in-place;
RyoheiHagimoto 0:0e0631af0305 2025 // use "nonzeroRows" hint for faster processing
RyoheiHagimoto 0:0e0631af0305 2026 dft(tempA, tempA, 0, A.rows);
RyoheiHagimoto 0:0e0631af0305 2027 dft(tempB, tempB, 0, B.rows);
RyoheiHagimoto 0:0e0631af0305 2028
RyoheiHagimoto 0:0e0631af0305 2029 // multiply the spectrums;
RyoheiHagimoto 0:0e0631af0305 2030 // the function handles packed spectrum representations well
RyoheiHagimoto 0:0e0631af0305 2031 mulSpectrums(tempA, tempB, tempA);
RyoheiHagimoto 0:0e0631af0305 2032
RyoheiHagimoto 0:0e0631af0305 2033 // transform the product back from the frequency domain.
RyoheiHagimoto 0:0e0631af0305 2034 // Even though all the result rows will be non-zero,
RyoheiHagimoto 0:0e0631af0305 2035 // you need only the first C.rows of them, and thus you
RyoheiHagimoto 0:0e0631af0305 2036 // pass nonzeroRows == C.rows
RyoheiHagimoto 0:0e0631af0305 2037 dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
RyoheiHagimoto 0:0e0631af0305 2038
RyoheiHagimoto 0:0e0631af0305 2039 // now copy the result back to C.
RyoheiHagimoto 0:0e0631af0305 2040 tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
RyoheiHagimoto 0:0e0631af0305 2041
RyoheiHagimoto 0:0e0631af0305 2042 // all the temporary buffers will be deallocated automatically
RyoheiHagimoto 0:0e0631af0305 2043 }
RyoheiHagimoto 0:0e0631af0305 2044 @endcode
RyoheiHagimoto 0:0e0631af0305 2045 To optimize this sample, consider the following approaches:
RyoheiHagimoto 0:0e0631af0305 2046 - Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
RyoheiHagimoto 0:0e0631af0305 2047 the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
RyoheiHagimoto 0:0e0631af0305 2048 tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
RyoheiHagimoto 0:0e0631af0305 2049 rightmost columns of the matrices.
RyoheiHagimoto 0:0e0631af0305 2050 - This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
RyoheiHagimoto 0:0e0631af0305 2051 is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
RyoheiHagimoto 0:0e0631af0305 2052 To do this, you need to split the output array C into multiple tiles. For each tile, estimate
RyoheiHagimoto 0:0e0631af0305 2053 which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
RyoheiHagimoto 0:0e0631af0305 2054 too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
RyoheiHagimoto 0:0e0631af0305 2055 each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
RyoheiHagimoto 0:0e0631af0305 2056 algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
RyoheiHagimoto 0:0e0631af0305 2057 there is also a slowdown because of bad cache locality. So, there is an optimal tile size
RyoheiHagimoto 0:0e0631af0305 2058 somewhere in the middle.
RyoheiHagimoto 0:0e0631af0305 2059 - If different tiles in C can be calculated in parallel and, thus, the convolution is done by
RyoheiHagimoto 0:0e0631af0305 2060 parts, the loop can be threaded.
RyoheiHagimoto 0:0e0631af0305 2061
RyoheiHagimoto 0:0e0631af0305 2062 All of the above improvements have been implemented in matchTemplate and filter2D . Therefore, by
RyoheiHagimoto 0:0e0631af0305 2063 using them, you can get the performance even better than with the above theoretically optimal
RyoheiHagimoto 0:0e0631af0305 2064 implementation. Though, those two functions actually calculate cross-correlation, not convolution,
RyoheiHagimoto 0:0e0631af0305 2065 so you need to "flip" the second convolution operand B vertically and horizontally using flip .
RyoheiHagimoto 0:0e0631af0305 2066 @note
RyoheiHagimoto 0:0e0631af0305 2067 - An example using the discrete fourier transform can be found at
RyoheiHagimoto 0:0e0631af0305 2068 opencv_source_code/samples/cpp/dft.cpp
RyoheiHagimoto 0:0e0631af0305 2069 - (Python) An example using the dft functionality to perform Wiener deconvolution can be found
RyoheiHagimoto 0:0e0631af0305 2070 at opencv_source/samples/python/deconvolution.py
RyoheiHagimoto 0:0e0631af0305 2071 - (Python) An example rearranging the quadrants of a Fourier image can be found at
RyoheiHagimoto 0:0e0631af0305 2072 opencv_source/samples/python/dft.py
RyoheiHagimoto 0:0e0631af0305 2073 @param src input array that could be real or complex.
RyoheiHagimoto 0:0e0631af0305 2074 @param dst output array whose size and type depends on the flags .
RyoheiHagimoto 0:0e0631af0305 2075 @param flags transformation flags, representing a combination of the cv::DftFlags
RyoheiHagimoto 0:0e0631af0305 2076 @param nonzeroRows when the parameter is not zero, the function assumes that only the first
RyoheiHagimoto 0:0e0631af0305 2077 nonzeroRows rows of the input array (DFT_INVERSE is not set) or only the first nonzeroRows of the
RyoheiHagimoto 0:0e0631af0305 2078 output array (DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
RyoheiHagimoto 0:0e0631af0305 2079 rows more efficiently and save some time; this technique is very useful for calculating array
RyoheiHagimoto 0:0e0631af0305 2080 cross-correlation or convolution using DFT.
RyoheiHagimoto 0:0e0631af0305 2081 @sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
RyoheiHagimoto 0:0e0631af0305 2082 magnitude , phase
RyoheiHagimoto 0:0e0631af0305 2083 */
RyoheiHagimoto 0:0e0631af0305 2084 CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0);
RyoheiHagimoto 0:0e0631af0305 2085
RyoheiHagimoto 0:0e0631af0305 2086 /** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
RyoheiHagimoto 0:0e0631af0305 2087
RyoheiHagimoto 0:0e0631af0305 2088 idft(src, dst, flags) is equivalent to dft(src, dst, flags | DFT_INVERSE) .
RyoheiHagimoto 0:0e0631af0305 2089 @note None of dft and idft scales the result by default. So, you should pass DFT_SCALE to one of
RyoheiHagimoto 0:0e0631af0305 2090 dft or idft explicitly to make these transforms mutually inverse.
RyoheiHagimoto 0:0e0631af0305 2091 @sa dft, dct, idct, mulSpectrums, getOptimalDFTSize
RyoheiHagimoto 0:0e0631af0305 2092 @param src input floating-point real or complex array.
RyoheiHagimoto 0:0e0631af0305 2093 @param dst output array whose size and type depend on the flags.
RyoheiHagimoto 0:0e0631af0305 2094 @param flags operation flags (see dft and cv::DftFlags).
RyoheiHagimoto 0:0e0631af0305 2095 @param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see
RyoheiHagimoto 0:0e0631af0305 2096 the convolution sample in dft description.
RyoheiHagimoto 0:0e0631af0305 2097 */
RyoheiHagimoto 0:0e0631af0305 2098 CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0);
RyoheiHagimoto 0:0e0631af0305 2099
RyoheiHagimoto 0:0e0631af0305 2100 /** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
RyoheiHagimoto 0:0e0631af0305 2101
RyoheiHagimoto 0:0e0631af0305 2102 The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
RyoheiHagimoto 0:0e0631af0305 2103 floating-point array:
RyoheiHagimoto 0:0e0631af0305 2104 - Forward Cosine transform of a 1D vector of N elements:
RyoheiHagimoto 0:0e0631af0305 2105 \f[Y = C^{(N)} \cdot X\f]
RyoheiHagimoto 0:0e0631af0305 2106 where
RyoheiHagimoto 0:0e0631af0305 2107 \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\f]
RyoheiHagimoto 0:0e0631af0305 2108 and
RyoheiHagimoto 0:0e0631af0305 2109 \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for *j \> 0*.
RyoheiHagimoto 0:0e0631af0305 2110 - Inverse Cosine transform of a 1D vector of N elements:
RyoheiHagimoto 0:0e0631af0305 2111 \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\f]
RyoheiHagimoto 0:0e0631af0305 2112 (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot \left(C^{(N)}\right)^T = I\f$ )
RyoheiHagimoto 0:0e0631af0305 2113 - Forward 2D Cosine transform of M x N matrix:
RyoheiHagimoto 0:0e0631af0305 2114 \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f]
RyoheiHagimoto 0:0e0631af0305 2115 - Inverse 2D Cosine transform of M x N matrix:
RyoheiHagimoto 0:0e0631af0305 2116 \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f]
RyoheiHagimoto 0:0e0631af0305 2117
RyoheiHagimoto 0:0e0631af0305 2118 The function chooses the mode of operation by looking at the flags and size of the input array:
RyoheiHagimoto 0:0e0631af0305 2119 - If (flags & DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
RyoheiHagimoto 0:0e0631af0305 2120 is an inverse 1D or 2D transform.
RyoheiHagimoto 0:0e0631af0305 2121 - If (flags & DCT_ROWS) != 0 , the function performs a 1D transform of each row.
RyoheiHagimoto 0:0e0631af0305 2122 - If the array is a single column or a single row, the function performs a 1D transform.
RyoheiHagimoto 0:0e0631af0305 2123 - If none of the above is true, the function performs a 2D transform.
RyoheiHagimoto 0:0e0631af0305 2124
RyoheiHagimoto 0:0e0631af0305 2125 @note Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you
RyoheiHagimoto 0:0e0631af0305 2126 can pad the array when necessary.
RyoheiHagimoto 0:0e0631af0305 2127 Also, the function performance depends very much, and not monotonically, on the array size (see
RyoheiHagimoto 0:0e0631af0305 2128 getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT
RyoheiHagimoto 0:0e0631af0305 2129 of a vector of size N/2 . Thus, the optimal DCT size N1 \>= N can be calculated as:
RyoheiHagimoto 0:0e0631af0305 2130 @code
RyoheiHagimoto 0:0e0631af0305 2131 size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
RyoheiHagimoto 0:0e0631af0305 2132 N1 = getOptimalDCTSize(N);
RyoheiHagimoto 0:0e0631af0305 2133 @endcode
RyoheiHagimoto 0:0e0631af0305 2134 @param src input floating-point array.
RyoheiHagimoto 0:0e0631af0305 2135 @param dst output array of the same size and type as src .
RyoheiHagimoto 0:0e0631af0305 2136 @param flags transformation flags as a combination of cv::DftFlags (DCT_*)
RyoheiHagimoto 0:0e0631af0305 2137 @sa dft , getOptimalDFTSize , idct
RyoheiHagimoto 0:0e0631af0305 2138 */
RyoheiHagimoto 0:0e0631af0305 2139 CV_EXPORTS_W void dct(InputArray src, OutputArray dst, int flags = 0);
RyoheiHagimoto 0:0e0631af0305 2140
RyoheiHagimoto 0:0e0631af0305 2141 /** @brief Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
RyoheiHagimoto 0:0e0631af0305 2142
RyoheiHagimoto 0:0e0631af0305 2143 idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE).
RyoheiHagimoto 0:0e0631af0305 2144 @param src input floating-point single-channel array.
RyoheiHagimoto 0:0e0631af0305 2145 @param dst output array of the same size and type as src.
RyoheiHagimoto 0:0e0631af0305 2146 @param flags operation flags.
RyoheiHagimoto 0:0e0631af0305 2147 @sa dct, dft, idft, getOptimalDFTSize
RyoheiHagimoto 0:0e0631af0305 2148 */
RyoheiHagimoto 0:0e0631af0305 2149 CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0);
RyoheiHagimoto 0:0e0631af0305 2150
RyoheiHagimoto 0:0e0631af0305 2151 /** @brief Performs the per-element multiplication of two Fourier spectrums.
RyoheiHagimoto 0:0e0631af0305 2152
RyoheiHagimoto 0:0e0631af0305 2153 The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
RyoheiHagimoto 0:0e0631af0305 2154 matrices that are results of a real or complex Fourier transform.
RyoheiHagimoto 0:0e0631af0305 2155
RyoheiHagimoto 0:0e0631af0305 2156 The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
RyoheiHagimoto 0:0e0631af0305 2157 or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are
RyoheiHagimoto 0:0e0631af0305 2158 simply multiplied (per element) with an optional conjugation of the second-array elements. When the
RyoheiHagimoto 0:0e0631af0305 2159 arrays are real, they are assumed to be CCS-packed (see dft for details).
RyoheiHagimoto 0:0e0631af0305 2160 @param a first input array.
RyoheiHagimoto 0:0e0631af0305 2161 @param b second input array of the same size and type as src1 .
RyoheiHagimoto 0:0e0631af0305 2162 @param c output array of the same size and type as src1 .
RyoheiHagimoto 0:0e0631af0305 2163 @param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
RyoheiHagimoto 0:0e0631af0305 2164 each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0` as value.
RyoheiHagimoto 0:0e0631af0305 2165 @param conjB optional flag that conjugates the second input array before the multiplication (true)
RyoheiHagimoto 0:0e0631af0305 2166 or not (false).
RyoheiHagimoto 0:0e0631af0305 2167 */
RyoheiHagimoto 0:0e0631af0305 2168 CV_EXPORTS_W void mulSpectrums(InputArray a, InputArray b, OutputArray c,
RyoheiHagimoto 0:0e0631af0305 2169 int flags, bool conjB = false);
RyoheiHagimoto 0:0e0631af0305 2170
RyoheiHagimoto 0:0e0631af0305 2171 /** @brief Returns the optimal DFT size for a given vector size.
RyoheiHagimoto 0:0e0631af0305 2172
RyoheiHagimoto 0:0e0631af0305 2173 DFT performance is not a monotonic function of a vector size. Therefore, when you calculate
RyoheiHagimoto 0:0e0631af0305 2174 convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to
RyoheiHagimoto 0:0e0631af0305 2175 pad the input data with zeros to get a bit larger array that can be transformed much faster than the
RyoheiHagimoto 0:0e0631af0305 2176 original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process.
RyoheiHagimoto 0:0e0631af0305 2177 Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2)
RyoheiHagimoto 0:0e0631af0305 2178 are also processed quite efficiently.
RyoheiHagimoto 0:0e0631af0305 2179
RyoheiHagimoto 0:0e0631af0305 2180 The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
RyoheiHagimoto 0:0e0631af0305 2181 so that the DFT of a vector of size N can be processed efficiently. In the current implementation N
RyoheiHagimoto 0:0e0631af0305 2182 = 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r.
RyoheiHagimoto 0:0e0631af0305 2183
RyoheiHagimoto 0:0e0631af0305 2184 The function returns a negative number if vecsize is too large (very close to INT_MAX ).
RyoheiHagimoto 0:0e0631af0305 2185
RyoheiHagimoto 0:0e0631af0305 2186 While the function cannot be used directly to estimate the optimal vector size for DCT transform
RyoheiHagimoto 0:0e0631af0305 2187 (since the current DCT implementation supports only even-size vectors), it can be easily processed
RyoheiHagimoto 0:0e0631af0305 2188 as getOptimalDFTSize((vecsize+1)/2)\*2.
RyoheiHagimoto 0:0e0631af0305 2189 @param vecsize vector size.
RyoheiHagimoto 0:0e0631af0305 2190 @sa dft , dct , idft , idct , mulSpectrums
RyoheiHagimoto 0:0e0631af0305 2191 */
RyoheiHagimoto 0:0e0631af0305 2192 CV_EXPORTS_W int getOptimalDFTSize(int vecsize);
RyoheiHagimoto 0:0e0631af0305 2193
RyoheiHagimoto 0:0e0631af0305 2194 /** @brief Returns the default random number generator.
RyoheiHagimoto 0:0e0631af0305 2195
RyoheiHagimoto 0:0e0631af0305 2196 The function cv::theRNG returns the default random number generator. For each thread, there is a
RyoheiHagimoto 0:0e0631af0305 2197 separate random number generator, so you can use the function safely in multi-thread environments.
RyoheiHagimoto 0:0e0631af0305 2198 If you just need to get a single random number using this generator or initialize an array, you can
RyoheiHagimoto 0:0e0631af0305 2199 use randu or randn instead. But if you are going to generate many random numbers inside a loop, it
RyoheiHagimoto 0:0e0631af0305 2200 is much faster to use this function to retrieve the generator and then use RNG::operator _Tp() .
RyoheiHagimoto 0:0e0631af0305 2201 @sa RNG, randu, randn
RyoheiHagimoto 0:0e0631af0305 2202 */
RyoheiHagimoto 0:0e0631af0305 2203 CV_EXPORTS RNG& theRNG();
RyoheiHagimoto 0:0e0631af0305 2204
RyoheiHagimoto 0:0e0631af0305 2205 /** @brief Sets state of default random number generator.
RyoheiHagimoto 0:0e0631af0305 2206
RyoheiHagimoto 0:0e0631af0305 2207 The function cv::setRNGSeed sets state of default random number generator to custom value.
RyoheiHagimoto 0:0e0631af0305 2208 @param seed new state for default random number generator
RyoheiHagimoto 0:0e0631af0305 2209 @sa RNG, randu, randn
RyoheiHagimoto 0:0e0631af0305 2210 */
RyoheiHagimoto 0:0e0631af0305 2211 CV_EXPORTS_W void setRNGSeed(int seed);
RyoheiHagimoto 0:0e0631af0305 2212
RyoheiHagimoto 0:0e0631af0305 2213 /** @brief Generates a single uniformly-distributed random number or an array of random numbers.
RyoheiHagimoto 0:0e0631af0305 2214
RyoheiHagimoto 0:0e0631af0305 2215 Non-template variant of the function fills the matrix dst with uniformly-distributed
RyoheiHagimoto 0:0e0631af0305 2216 random numbers from the specified range:
RyoheiHagimoto 0:0e0631af0305 2217 \f[\texttt{low} _c \leq \texttt{dst} (I)_c < \texttt{high} _c\f]
RyoheiHagimoto 0:0e0631af0305 2218 @param dst output array of random numbers; the array must be pre-allocated.
RyoheiHagimoto 0:0e0631af0305 2219 @param low inclusive lower boundary of the generated random numbers.
RyoheiHagimoto 0:0e0631af0305 2220 @param high exclusive upper boundary of the generated random numbers.
RyoheiHagimoto 0:0e0631af0305 2221 @sa RNG, randn, theRNG
RyoheiHagimoto 0:0e0631af0305 2222 */
RyoheiHagimoto 0:0e0631af0305 2223 CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high);
RyoheiHagimoto 0:0e0631af0305 2224
RyoheiHagimoto 0:0e0631af0305 2225 /** @brief Fills the array with normally distributed random numbers.
RyoheiHagimoto 0:0e0631af0305 2226
RyoheiHagimoto 0:0e0631af0305 2227 The function cv::randn fills the matrix dst with normally distributed random numbers with the specified
RyoheiHagimoto 0:0e0631af0305 2228 mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the
RyoheiHagimoto 0:0e0631af0305 2229 value range of the output array data type.
RyoheiHagimoto 0:0e0631af0305 2230 @param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels.
RyoheiHagimoto 0:0e0631af0305 2231 @param mean mean value (expectation) of the generated random numbers.
RyoheiHagimoto 0:0e0631af0305 2232 @param stddev standard deviation of the generated random numbers; it can be either a vector (in
RyoheiHagimoto 0:0e0631af0305 2233 which case a diagonal standard deviation matrix is assumed) or a square matrix.
RyoheiHagimoto 0:0e0631af0305 2234 @sa RNG, randu
RyoheiHagimoto 0:0e0631af0305 2235 */
RyoheiHagimoto 0:0e0631af0305 2236 CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev);
RyoheiHagimoto 0:0e0631af0305 2237
RyoheiHagimoto 0:0e0631af0305 2238 /** @brief Shuffles the array elements randomly.
RyoheiHagimoto 0:0e0631af0305 2239
RyoheiHagimoto 0:0e0631af0305 2240 The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
RyoheiHagimoto 0:0e0631af0305 2241 swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
RyoheiHagimoto 0:0e0631af0305 2242 @param dst input/output numerical 1D array.
RyoheiHagimoto 0:0e0631af0305 2243 @param iterFactor scale factor that determines the number of random swap operations (see the details
RyoheiHagimoto 0:0e0631af0305 2244 below).
RyoheiHagimoto 0:0e0631af0305 2245 @param rng optional random number generator used for shuffling; if it is zero, theRNG () is used
RyoheiHagimoto 0:0e0631af0305 2246 instead.
RyoheiHagimoto 0:0e0631af0305 2247 @sa RNG, sort
RyoheiHagimoto 0:0e0631af0305 2248 */
RyoheiHagimoto 0:0e0631af0305 2249 CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0);
RyoheiHagimoto 0:0e0631af0305 2250
RyoheiHagimoto 0:0e0631af0305 2251 /** @brief Principal Component Analysis
RyoheiHagimoto 0:0e0631af0305 2252
RyoheiHagimoto 0:0e0631af0305 2253 The class is used to calculate a special basis for a set of vectors. The
RyoheiHagimoto 0:0e0631af0305 2254 basis will consist of eigenvectors of the covariance matrix calculated
RyoheiHagimoto 0:0e0631af0305 2255 from the input set of vectors. The class %PCA can also transform
RyoheiHagimoto 0:0e0631af0305 2256 vectors to/from the new coordinate space defined by the basis. Usually,
RyoheiHagimoto 0:0e0631af0305 2257 in this new coordinate system, each vector from the original set (and
RyoheiHagimoto 0:0e0631af0305 2258 any linear combination of such vectors) can be quite accurately
RyoheiHagimoto 0:0e0631af0305 2259 approximated by taking its first few components, corresponding to the
RyoheiHagimoto 0:0e0631af0305 2260 eigenvectors of the largest eigenvalues of the covariance matrix.
RyoheiHagimoto 0:0e0631af0305 2261 Geometrically it means that you calculate a projection of the vector to
RyoheiHagimoto 0:0e0631af0305 2262 a subspace formed by a few eigenvectors corresponding to the dominant
RyoheiHagimoto 0:0e0631af0305 2263 eigenvalues of the covariance matrix. And usually such a projection is
RyoheiHagimoto 0:0e0631af0305 2264 very close to the original vector. So, you can represent the original
RyoheiHagimoto 0:0e0631af0305 2265 vector from a high-dimensional space with a much shorter vector
RyoheiHagimoto 0:0e0631af0305 2266 consisting of the projected vector's coordinates in the subspace. Such a
RyoheiHagimoto 0:0e0631af0305 2267 transformation is also known as Karhunen-Loeve Transform, or KLT.
RyoheiHagimoto 0:0e0631af0305 2268 See http://en.wikipedia.org/wiki/Principal_component_analysis
RyoheiHagimoto 0:0e0631af0305 2269
RyoheiHagimoto 0:0e0631af0305 2270 The sample below is the function that takes two matrices. The first
RyoheiHagimoto 0:0e0631af0305 2271 function stores a set of vectors (a row per vector) that is used to
RyoheiHagimoto 0:0e0631af0305 2272 calculate PCA. The second function stores another "test" set of vectors
RyoheiHagimoto 0:0e0631af0305 2273 (a row per vector). First, these vectors are compressed with PCA, then
RyoheiHagimoto 0:0e0631af0305 2274 reconstructed back, and then the reconstruction error norm is computed
RyoheiHagimoto 0:0e0631af0305 2275 and printed for each vector. :
RyoheiHagimoto 0:0e0631af0305 2276
RyoheiHagimoto 0:0e0631af0305 2277 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 2278 using namespace cv;
RyoheiHagimoto 0:0e0631af0305 2279
RyoheiHagimoto 0:0e0631af0305 2280 PCA compressPCA(const Mat& pcaset, int maxComponents,
RyoheiHagimoto 0:0e0631af0305 2281 const Mat& testset, Mat& compressed)
RyoheiHagimoto 0:0e0631af0305 2282 {
RyoheiHagimoto 0:0e0631af0305 2283 PCA pca(pcaset, // pass the data
RyoheiHagimoto 0:0e0631af0305 2284 Mat(), // we do not have a pre-computed mean vector,
RyoheiHagimoto 0:0e0631af0305 2285 // so let the PCA engine to compute it
RyoheiHagimoto 0:0e0631af0305 2286 PCA::DATA_AS_ROW, // indicate that the vectors
RyoheiHagimoto 0:0e0631af0305 2287 // are stored as matrix rows
RyoheiHagimoto 0:0e0631af0305 2288 // (use PCA::DATA_AS_COL if the vectors are
RyoheiHagimoto 0:0e0631af0305 2289 // the matrix columns)
RyoheiHagimoto 0:0e0631af0305 2290 maxComponents // specify, how many principal components to retain
RyoheiHagimoto 0:0e0631af0305 2291 );
RyoheiHagimoto 0:0e0631af0305 2292 // if there is no test data, just return the computed basis, ready-to-use
RyoheiHagimoto 0:0e0631af0305 2293 if( !testset.data )
RyoheiHagimoto 0:0e0631af0305 2294 return pca;
RyoheiHagimoto 0:0e0631af0305 2295 CV_Assert( testset.cols == pcaset.cols );
RyoheiHagimoto 0:0e0631af0305 2296
RyoheiHagimoto 0:0e0631af0305 2297 compressed.create(testset.rows, maxComponents, testset.type());
RyoheiHagimoto 0:0e0631af0305 2298
RyoheiHagimoto 0:0e0631af0305 2299 Mat reconstructed;
RyoheiHagimoto 0:0e0631af0305 2300 for( int i = 0; i < testset.rows; i++ )
RyoheiHagimoto 0:0e0631af0305 2301 {
RyoheiHagimoto 0:0e0631af0305 2302 Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed;
RyoheiHagimoto 0:0e0631af0305 2303 // compress the vector, the result will be stored
RyoheiHagimoto 0:0e0631af0305 2304 // in the i-th row of the output matrix
RyoheiHagimoto 0:0e0631af0305 2305 pca.project(vec, coeffs);
RyoheiHagimoto 0:0e0631af0305 2306 // and then reconstruct it
RyoheiHagimoto 0:0e0631af0305 2307 pca.backProject(coeffs, reconstructed);
RyoheiHagimoto 0:0e0631af0305 2308 // and measure the error
RyoheiHagimoto 0:0e0631af0305 2309 printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2));
RyoheiHagimoto 0:0e0631af0305 2310 }
RyoheiHagimoto 0:0e0631af0305 2311 return pca;
RyoheiHagimoto 0:0e0631af0305 2312 }
RyoheiHagimoto 0:0e0631af0305 2313 @endcode
RyoheiHagimoto 0:0e0631af0305 2314 @sa calcCovarMatrix, mulTransposed, SVD, dft, dct
RyoheiHagimoto 0:0e0631af0305 2315 */
RyoheiHagimoto 0:0e0631af0305 2316 class CV_EXPORTS PCA
RyoheiHagimoto 0:0e0631af0305 2317 {
RyoheiHagimoto 0:0e0631af0305 2318 public:
RyoheiHagimoto 0:0e0631af0305 2319 enum Flags { DATA_AS_ROW = 0, //!< indicates that the input samples are stored as matrix rows
RyoheiHagimoto 0:0e0631af0305 2320 DATA_AS_COL = 1, //!< indicates that the input samples are stored as matrix columns
RyoheiHagimoto 0:0e0631af0305 2321 USE_AVG = 2 //!
RyoheiHagimoto 0:0e0631af0305 2322 };
RyoheiHagimoto 0:0e0631af0305 2323
RyoheiHagimoto 0:0e0631af0305 2324 /** @brief default constructor
RyoheiHagimoto 0:0e0631af0305 2325
RyoheiHagimoto 0:0e0631af0305 2326 The default constructor initializes an empty %PCA structure. The other
RyoheiHagimoto 0:0e0631af0305 2327 constructors initialize the structure and call PCA::operator()().
RyoheiHagimoto 0:0e0631af0305 2328 */
RyoheiHagimoto 0:0e0631af0305 2329 PCA();
RyoheiHagimoto 0:0e0631af0305 2330
RyoheiHagimoto 0:0e0631af0305 2331 /** @overload
RyoheiHagimoto 0:0e0631af0305 2332 @param data input samples stored as matrix rows or matrix columns.
RyoheiHagimoto 0:0e0631af0305 2333 @param mean optional mean value; if the matrix is empty (@c noArray()),
RyoheiHagimoto 0:0e0631af0305 2334 the mean is computed from the data.
RyoheiHagimoto 0:0e0631af0305 2335 @param flags operation flags; currently the parameter is only used to
RyoheiHagimoto 0:0e0631af0305 2336 specify the data layout (PCA::Flags)
RyoheiHagimoto 0:0e0631af0305 2337 @param maxComponents maximum number of components that %PCA should
RyoheiHagimoto 0:0e0631af0305 2338 retain; by default, all the components are retained.
RyoheiHagimoto 0:0e0631af0305 2339 */
RyoheiHagimoto 0:0e0631af0305 2340 PCA(InputArray data, InputArray mean, int flags, int maxComponents = 0);
RyoheiHagimoto 0:0e0631af0305 2341
RyoheiHagimoto 0:0e0631af0305 2342 /** @overload
RyoheiHagimoto 0:0e0631af0305 2343 @param data input samples stored as matrix rows or matrix columns.
RyoheiHagimoto 0:0e0631af0305 2344 @param mean optional mean value; if the matrix is empty (noArray()),
RyoheiHagimoto 0:0e0631af0305 2345 the mean is computed from the data.
RyoheiHagimoto 0:0e0631af0305 2346 @param flags operation flags; currently the parameter is only used to
RyoheiHagimoto 0:0e0631af0305 2347 specify the data layout (PCA::Flags)
RyoheiHagimoto 0:0e0631af0305 2348 @param retainedVariance Percentage of variance that PCA should retain.
RyoheiHagimoto 0:0e0631af0305 2349 Using this parameter will let the PCA decided how many components to
RyoheiHagimoto 0:0e0631af0305 2350 retain but it will always keep at least 2.
RyoheiHagimoto 0:0e0631af0305 2351 */
RyoheiHagimoto 0:0e0631af0305 2352 PCA(InputArray data, InputArray mean, int flags, double retainedVariance);
RyoheiHagimoto 0:0e0631af0305 2353
RyoheiHagimoto 0:0e0631af0305 2354 /** @brief performs %PCA
RyoheiHagimoto 0:0e0631af0305 2355
RyoheiHagimoto 0:0e0631af0305 2356 The operator performs %PCA of the supplied dataset. It is safe to reuse
RyoheiHagimoto 0:0e0631af0305 2357 the same PCA structure for multiple datasets. That is, if the structure
RyoheiHagimoto 0:0e0631af0305 2358 has been previously used with another dataset, the existing internal
RyoheiHagimoto 0:0e0631af0305 2359 data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref
RyoheiHagimoto 0:0e0631af0305 2360 mean are allocated and computed.
RyoheiHagimoto 0:0e0631af0305 2361
RyoheiHagimoto 0:0e0631af0305 2362 The computed @ref eigenvalues are sorted from the largest to the smallest and
RyoheiHagimoto 0:0e0631af0305 2363 the corresponding @ref eigenvectors are stored as eigenvectors rows.
RyoheiHagimoto 0:0e0631af0305 2364
RyoheiHagimoto 0:0e0631af0305 2365 @param data input samples stored as the matrix rows or as the matrix
RyoheiHagimoto 0:0e0631af0305 2366 columns.
RyoheiHagimoto 0:0e0631af0305 2367 @param mean optional mean value; if the matrix is empty (noArray()),
RyoheiHagimoto 0:0e0631af0305 2368 the mean is computed from the data.
RyoheiHagimoto 0:0e0631af0305 2369 @param flags operation flags; currently the parameter is only used to
RyoheiHagimoto 0:0e0631af0305 2370 specify the data layout. (Flags)
RyoheiHagimoto 0:0e0631af0305 2371 @param maxComponents maximum number of components that PCA should
RyoheiHagimoto 0:0e0631af0305 2372 retain; by default, all the components are retained.
RyoheiHagimoto 0:0e0631af0305 2373 */
RyoheiHagimoto 0:0e0631af0305 2374 PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents = 0);
RyoheiHagimoto 0:0e0631af0305 2375
RyoheiHagimoto 0:0e0631af0305 2376 /** @overload
RyoheiHagimoto 0:0e0631af0305 2377 @param data input samples stored as the matrix rows or as the matrix
RyoheiHagimoto 0:0e0631af0305 2378 columns.
RyoheiHagimoto 0:0e0631af0305 2379 @param mean optional mean value; if the matrix is empty (noArray()),
RyoheiHagimoto 0:0e0631af0305 2380 the mean is computed from the data.
RyoheiHagimoto 0:0e0631af0305 2381 @param flags operation flags; currently the parameter is only used to
RyoheiHagimoto 0:0e0631af0305 2382 specify the data layout. (PCA::Flags)
RyoheiHagimoto 0:0e0631af0305 2383 @param retainedVariance Percentage of variance that %PCA should retain.
RyoheiHagimoto 0:0e0631af0305 2384 Using this parameter will let the %PCA decided how many components to
RyoheiHagimoto 0:0e0631af0305 2385 retain but it will always keep at least 2.
RyoheiHagimoto 0:0e0631af0305 2386 */
RyoheiHagimoto 0:0e0631af0305 2387 PCA& operator()(InputArray data, InputArray mean, int flags, double retainedVariance);
RyoheiHagimoto 0:0e0631af0305 2388
RyoheiHagimoto 0:0e0631af0305 2389 /** @brief Projects vector(s) to the principal component subspace.
RyoheiHagimoto 0:0e0631af0305 2390
RyoheiHagimoto 0:0e0631af0305 2391 The methods project one or more vectors to the principal component
RyoheiHagimoto 0:0e0631af0305 2392 subspace, where each vector projection is represented by coefficients in
RyoheiHagimoto 0:0e0631af0305 2393 the principal component basis. The first form of the method returns the
RyoheiHagimoto 0:0e0631af0305 2394 matrix that the second form writes to the result. So the first form can
RyoheiHagimoto 0:0e0631af0305 2395 be used as a part of expression while the second form can be more
RyoheiHagimoto 0:0e0631af0305 2396 efficient in a processing loop.
RyoheiHagimoto 0:0e0631af0305 2397 @param vec input vector(s); must have the same dimensionality and the
RyoheiHagimoto 0:0e0631af0305 2398 same layout as the input data used at %PCA phase, that is, if
RyoheiHagimoto 0:0e0631af0305 2399 DATA_AS_ROW are specified, then `vec.cols==data.cols`
RyoheiHagimoto 0:0e0631af0305 2400 (vector dimensionality) and `vec.rows` is the number of vectors to
RyoheiHagimoto 0:0e0631af0305 2401 project, and the same is true for the PCA::DATA_AS_COL case.
RyoheiHagimoto 0:0e0631af0305 2402 */
RyoheiHagimoto 0:0e0631af0305 2403 Mat project(InputArray vec) const;
RyoheiHagimoto 0:0e0631af0305 2404
RyoheiHagimoto 0:0e0631af0305 2405 /** @overload
RyoheiHagimoto 0:0e0631af0305 2406 @param vec input vector(s); must have the same dimensionality and the
RyoheiHagimoto 0:0e0631af0305 2407 same layout as the input data used at PCA phase, that is, if
RyoheiHagimoto 0:0e0631af0305 2408 DATA_AS_ROW are specified, then `vec.cols==data.cols`
RyoheiHagimoto 0:0e0631af0305 2409 (vector dimensionality) and `vec.rows` is the number of vectors to
RyoheiHagimoto 0:0e0631af0305 2410 project, and the same is true for the PCA::DATA_AS_COL case.
RyoheiHagimoto 0:0e0631af0305 2411 @param result output vectors; in case of PCA::DATA_AS_COL, the
RyoheiHagimoto 0:0e0631af0305 2412 output matrix has as many columns as the number of input vectors, this
RyoheiHagimoto 0:0e0631af0305 2413 means that `result.cols==vec.cols` and the number of rows match the
RyoheiHagimoto 0:0e0631af0305 2414 number of principal components (for example, `maxComponents` parameter
RyoheiHagimoto 0:0e0631af0305 2415 passed to the constructor).
RyoheiHagimoto 0:0e0631af0305 2416 */
RyoheiHagimoto 0:0e0631af0305 2417 void project(InputArray vec, OutputArray result) const;
RyoheiHagimoto 0:0e0631af0305 2418
RyoheiHagimoto 0:0e0631af0305 2419 /** @brief Reconstructs vectors from their PC projections.
RyoheiHagimoto 0:0e0631af0305 2420
RyoheiHagimoto 0:0e0631af0305 2421 The methods are inverse operations to PCA::project. They take PC
RyoheiHagimoto 0:0e0631af0305 2422 coordinates of projected vectors and reconstruct the original vectors.
RyoheiHagimoto 0:0e0631af0305 2423 Unless all the principal components have been retained, the
RyoheiHagimoto 0:0e0631af0305 2424 reconstructed vectors are different from the originals. But typically,
RyoheiHagimoto 0:0e0631af0305 2425 the difference is small if the number of components is large enough (but
RyoheiHagimoto 0:0e0631af0305 2426 still much smaller than the original vector dimensionality). As a
RyoheiHagimoto 0:0e0631af0305 2427 result, PCA is used.
RyoheiHagimoto 0:0e0631af0305 2428 @param vec coordinates of the vectors in the principal component
RyoheiHagimoto 0:0e0631af0305 2429 subspace, the layout and size are the same as of PCA::project output
RyoheiHagimoto 0:0e0631af0305 2430 vectors.
RyoheiHagimoto 0:0e0631af0305 2431 */
RyoheiHagimoto 0:0e0631af0305 2432 Mat backProject(InputArray vec) const;
RyoheiHagimoto 0:0e0631af0305 2433
RyoheiHagimoto 0:0e0631af0305 2434 /** @overload
RyoheiHagimoto 0:0e0631af0305 2435 @param vec coordinates of the vectors in the principal component
RyoheiHagimoto 0:0e0631af0305 2436 subspace, the layout and size are the same as of PCA::project output
RyoheiHagimoto 0:0e0631af0305 2437 vectors.
RyoheiHagimoto 0:0e0631af0305 2438 @param result reconstructed vectors; the layout and size are the same as
RyoheiHagimoto 0:0e0631af0305 2439 of PCA::project input vectors.
RyoheiHagimoto 0:0e0631af0305 2440 */
RyoheiHagimoto 0:0e0631af0305 2441 void backProject(InputArray vec, OutputArray result) const;
RyoheiHagimoto 0:0e0631af0305 2442
RyoheiHagimoto 0:0e0631af0305 2443 /** @brief write PCA objects
RyoheiHagimoto 0:0e0631af0305 2444
RyoheiHagimoto 0:0e0631af0305 2445 Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage
RyoheiHagimoto 0:0e0631af0305 2446 */
RyoheiHagimoto 0:0e0631af0305 2447 void write(FileStorage& fs) const;
RyoheiHagimoto 0:0e0631af0305 2448
RyoheiHagimoto 0:0e0631af0305 2449 /** @brief load PCA objects
RyoheiHagimoto 0:0e0631af0305 2450
RyoheiHagimoto 0:0e0631af0305 2451 Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode
RyoheiHagimoto 0:0e0631af0305 2452 */
RyoheiHagimoto 0:0e0631af0305 2453 void read(const FileNode& fn);
RyoheiHagimoto 0:0e0631af0305 2454
RyoheiHagimoto 0:0e0631af0305 2455 Mat eigenvectors; //!< eigenvectors of the covariation matrix
RyoheiHagimoto 0:0e0631af0305 2456 Mat eigenvalues; //!< eigenvalues of the covariation matrix
RyoheiHagimoto 0:0e0631af0305 2457 Mat mean; //!< mean value subtracted before the projection and added after the back projection
RyoheiHagimoto 0:0e0631af0305 2458 };
RyoheiHagimoto 0:0e0631af0305 2459
RyoheiHagimoto 0:0e0631af0305 2460 /** @example pca.cpp
RyoheiHagimoto 0:0e0631af0305 2461 An example using %PCA for dimensionality reduction while maintaining an amount of variance
RyoheiHagimoto 0:0e0631af0305 2462 */
RyoheiHagimoto 0:0e0631af0305 2463
RyoheiHagimoto 0:0e0631af0305 2464 /**
RyoheiHagimoto 0:0e0631af0305 2465 @brief Linear Discriminant Analysis
RyoheiHagimoto 0:0e0631af0305 2466 @todo document this class
RyoheiHagimoto 0:0e0631af0305 2467 */
RyoheiHagimoto 0:0e0631af0305 2468 class CV_EXPORTS LDA
RyoheiHagimoto 0:0e0631af0305 2469 {
RyoheiHagimoto 0:0e0631af0305 2470 public:
RyoheiHagimoto 0:0e0631af0305 2471 /** @brief constructor
RyoheiHagimoto 0:0e0631af0305 2472 Initializes a LDA with num_components (default 0).
RyoheiHagimoto 0:0e0631af0305 2473 */
RyoheiHagimoto 0:0e0631af0305 2474 explicit LDA(int num_components = 0);
RyoheiHagimoto 0:0e0631af0305 2475
RyoheiHagimoto 0:0e0631af0305 2476 /** Initializes and performs a Discriminant Analysis with Fisher's
RyoheiHagimoto 0:0e0631af0305 2477 Optimization Criterion on given data in src and corresponding labels
RyoheiHagimoto 0:0e0631af0305 2478 in labels. If 0 (or less) number of components are given, they are
RyoheiHagimoto 0:0e0631af0305 2479 automatically determined for given data in computation.
RyoheiHagimoto 0:0e0631af0305 2480 */
RyoheiHagimoto 0:0e0631af0305 2481 LDA(InputArrayOfArrays src, InputArray labels, int num_components = 0);
RyoheiHagimoto 0:0e0631af0305 2482
RyoheiHagimoto 0:0e0631af0305 2483 /** Serializes this object to a given filename.
RyoheiHagimoto 0:0e0631af0305 2484 */
RyoheiHagimoto 0:0e0631af0305 2485 void save(const String& filename) const;
RyoheiHagimoto 0:0e0631af0305 2486
RyoheiHagimoto 0:0e0631af0305 2487 /** Deserializes this object from a given filename.
RyoheiHagimoto 0:0e0631af0305 2488 */
RyoheiHagimoto 0:0e0631af0305 2489 void load(const String& filename);
RyoheiHagimoto 0:0e0631af0305 2490
RyoheiHagimoto 0:0e0631af0305 2491 /** Serializes this object to a given cv::FileStorage.
RyoheiHagimoto 0:0e0631af0305 2492 */
RyoheiHagimoto 0:0e0631af0305 2493 void save(FileStorage& fs) const;
RyoheiHagimoto 0:0e0631af0305 2494
RyoheiHagimoto 0:0e0631af0305 2495 /** Deserializes this object from a given cv::FileStorage.
RyoheiHagimoto 0:0e0631af0305 2496 */
RyoheiHagimoto 0:0e0631af0305 2497 void load(const FileStorage& node);
RyoheiHagimoto 0:0e0631af0305 2498
RyoheiHagimoto 0:0e0631af0305 2499 /** destructor
RyoheiHagimoto 0:0e0631af0305 2500 */
RyoheiHagimoto 0:0e0631af0305 2501 ~LDA();
RyoheiHagimoto 0:0e0631af0305 2502
RyoheiHagimoto 0:0e0631af0305 2503 /** Compute the discriminants for data in src (row aligned) and labels.
RyoheiHagimoto 0:0e0631af0305 2504 */
RyoheiHagimoto 0:0e0631af0305 2505 void compute(InputArrayOfArrays src, InputArray labels);
RyoheiHagimoto 0:0e0631af0305 2506
RyoheiHagimoto 0:0e0631af0305 2507 /** Projects samples into the LDA subspace.
RyoheiHagimoto 0:0e0631af0305 2508 src may be one or more row aligned samples.
RyoheiHagimoto 0:0e0631af0305 2509 */
RyoheiHagimoto 0:0e0631af0305 2510 Mat project(InputArray src);
RyoheiHagimoto 0:0e0631af0305 2511
RyoheiHagimoto 0:0e0631af0305 2512 /** Reconstructs projections from the LDA subspace.
RyoheiHagimoto 0:0e0631af0305 2513 src may be one or more row aligned projections.
RyoheiHagimoto 0:0e0631af0305 2514 */
RyoheiHagimoto 0:0e0631af0305 2515 Mat reconstruct(InputArray src);
RyoheiHagimoto 0:0e0631af0305 2516
RyoheiHagimoto 0:0e0631af0305 2517 /** Returns the eigenvectors of this LDA.
RyoheiHagimoto 0:0e0631af0305 2518 */
RyoheiHagimoto 0:0e0631af0305 2519 Mat eigenvectors() const { return _eigenvectors; }
RyoheiHagimoto 0:0e0631af0305 2520
RyoheiHagimoto 0:0e0631af0305 2521 /** Returns the eigenvalues of this LDA.
RyoheiHagimoto 0:0e0631af0305 2522 */
RyoheiHagimoto 0:0e0631af0305 2523 Mat eigenvalues() const { return _eigenvalues; }
RyoheiHagimoto 0:0e0631af0305 2524
RyoheiHagimoto 0:0e0631af0305 2525 static Mat subspaceProject(InputArray W, InputArray mean, InputArray src);
RyoheiHagimoto 0:0e0631af0305 2526 static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
RyoheiHagimoto 0:0e0631af0305 2527
RyoheiHagimoto 0:0e0631af0305 2528 protected:
RyoheiHagimoto 0:0e0631af0305 2529 bool _dataAsRow; // unused, but needed for 3.0 ABI compatibility.
RyoheiHagimoto 0:0e0631af0305 2530 int _num_components;
RyoheiHagimoto 0:0e0631af0305 2531 Mat _eigenvectors;
RyoheiHagimoto 0:0e0631af0305 2532 Mat _eigenvalues;
RyoheiHagimoto 0:0e0631af0305 2533 void lda(InputArrayOfArrays src, InputArray labels);
RyoheiHagimoto 0:0e0631af0305 2534 };
RyoheiHagimoto 0:0e0631af0305 2535
RyoheiHagimoto 0:0e0631af0305 2536 /** @brief Singular Value Decomposition
RyoheiHagimoto 0:0e0631af0305 2537
RyoheiHagimoto 0:0e0631af0305 2538 Class for computing Singular Value Decomposition of a floating-point
RyoheiHagimoto 0:0e0631af0305 2539 matrix. The Singular Value Decomposition is used to solve least-square
RyoheiHagimoto 0:0e0631af0305 2540 problems, under-determined linear systems, invert matrices, compute
RyoheiHagimoto 0:0e0631af0305 2541 condition numbers, and so on.
RyoheiHagimoto 0:0e0631af0305 2542
RyoheiHagimoto 0:0e0631af0305 2543 If you want to compute a condition number of a matrix or an absolute value of
RyoheiHagimoto 0:0e0631af0305 2544 its determinant, you do not need `u` and `vt`. You can pass
RyoheiHagimoto 0:0e0631af0305 2545 flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u
RyoheiHagimoto 0:0e0631af0305 2546 and vt must be computed, which is not necessary most of the time.
RyoheiHagimoto 0:0e0631af0305 2547
RyoheiHagimoto 0:0e0631af0305 2548 @sa invert, solve, eigen, determinant
RyoheiHagimoto 0:0e0631af0305 2549 */
RyoheiHagimoto 0:0e0631af0305 2550 class CV_EXPORTS SVD
RyoheiHagimoto 0:0e0631af0305 2551 {
RyoheiHagimoto 0:0e0631af0305 2552 public:
RyoheiHagimoto 0:0e0631af0305 2553 enum Flags {
RyoheiHagimoto 0:0e0631af0305 2554 /** allow the algorithm to modify the decomposed matrix; it can save space and speed up
RyoheiHagimoto 0:0e0631af0305 2555 processing. currently ignored. */
RyoheiHagimoto 0:0e0631af0305 2556 MODIFY_A = 1,
RyoheiHagimoto 0:0e0631af0305 2557 /** indicates that only a vector of singular values `w` is to be processed, while u and vt
RyoheiHagimoto 0:0e0631af0305 2558 will be set to empty matrices */
RyoheiHagimoto 0:0e0631af0305 2559 NO_UV = 2,
RyoheiHagimoto 0:0e0631af0305 2560 /** when the matrix is not square, by default the algorithm produces u and vt matrices of
RyoheiHagimoto 0:0e0631af0305 2561 sufficiently large size for the further A reconstruction; if, however, FULL_UV flag is
RyoheiHagimoto 0:0e0631af0305 2562 specified, u and vt will be full-size square orthogonal matrices.*/
RyoheiHagimoto 0:0e0631af0305 2563 FULL_UV = 4
RyoheiHagimoto 0:0e0631af0305 2564 };
RyoheiHagimoto 0:0e0631af0305 2565
RyoheiHagimoto 0:0e0631af0305 2566 /** @brief the default constructor
RyoheiHagimoto 0:0e0631af0305 2567
RyoheiHagimoto 0:0e0631af0305 2568 initializes an empty SVD structure
RyoheiHagimoto 0:0e0631af0305 2569 */
RyoheiHagimoto 0:0e0631af0305 2570 SVD();
RyoheiHagimoto 0:0e0631af0305 2571
RyoheiHagimoto 0:0e0631af0305 2572 /** @overload
RyoheiHagimoto 0:0e0631af0305 2573 initializes an empty SVD structure and then calls SVD::operator()
RyoheiHagimoto 0:0e0631af0305 2574 @param src decomposed matrix.
RyoheiHagimoto 0:0e0631af0305 2575 @param flags operation flags (SVD::Flags)
RyoheiHagimoto 0:0e0631af0305 2576 */
RyoheiHagimoto 0:0e0631af0305 2577 SVD( InputArray src, int flags = 0 );
RyoheiHagimoto 0:0e0631af0305 2578
RyoheiHagimoto 0:0e0631af0305 2579 /** @brief the operator that performs SVD. The previously allocated u, w and vt are released.
RyoheiHagimoto 0:0e0631af0305 2580
RyoheiHagimoto 0:0e0631af0305 2581 The operator performs the singular value decomposition of the supplied
RyoheiHagimoto 0:0e0631af0305 2582 matrix. The u,`vt` , and the vector of singular values w are stored in
RyoheiHagimoto 0:0e0631af0305 2583 the structure. The same SVD structure can be reused many times with
RyoheiHagimoto 0:0e0631af0305 2584 different matrices. Each time, if needed, the previous u,`vt` , and w
RyoheiHagimoto 0:0e0631af0305 2585 are reclaimed and the new matrices are created, which is all handled by
RyoheiHagimoto 0:0e0631af0305 2586 Mat::create.
RyoheiHagimoto 0:0e0631af0305 2587 @param src decomposed matrix.
RyoheiHagimoto 0:0e0631af0305 2588 @param flags operation flags (SVD::Flags)
RyoheiHagimoto 0:0e0631af0305 2589 */
RyoheiHagimoto 0:0e0631af0305 2590 SVD& operator ()( InputArray src, int flags = 0 );
RyoheiHagimoto 0:0e0631af0305 2591
RyoheiHagimoto 0:0e0631af0305 2592 /** @brief decomposes matrix and stores the results to user-provided matrices
RyoheiHagimoto 0:0e0631af0305 2593
RyoheiHagimoto 0:0e0631af0305 2594 The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor
RyoheiHagimoto 0:0e0631af0305 2595 and SVD::operator(), they store the results to the user-provided
RyoheiHagimoto 0:0e0631af0305 2596 matrices:
RyoheiHagimoto 0:0e0631af0305 2597
RyoheiHagimoto 0:0e0631af0305 2598 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 2599 Mat A, w, u, vt;
RyoheiHagimoto 0:0e0631af0305 2600 SVD::compute(A, w, u, vt);
RyoheiHagimoto 0:0e0631af0305 2601 @endcode
RyoheiHagimoto 0:0e0631af0305 2602
RyoheiHagimoto 0:0e0631af0305 2603 @param src decomposed matrix
RyoheiHagimoto 0:0e0631af0305 2604 @param w calculated singular values
RyoheiHagimoto 0:0e0631af0305 2605 @param u calculated left singular vectors
RyoheiHagimoto 0:0e0631af0305 2606 @param vt transposed matrix of right singular values
RyoheiHagimoto 0:0e0631af0305 2607 @param flags operation flags - see SVD::SVD.
RyoheiHagimoto 0:0e0631af0305 2608 */
RyoheiHagimoto 0:0e0631af0305 2609 static void compute( InputArray src, OutputArray w,
RyoheiHagimoto 0:0e0631af0305 2610 OutputArray u, OutputArray vt, int flags = 0 );
RyoheiHagimoto 0:0e0631af0305 2611
RyoheiHagimoto 0:0e0631af0305 2612 /** @overload
RyoheiHagimoto 0:0e0631af0305 2613 computes singular values of a matrix
RyoheiHagimoto 0:0e0631af0305 2614 @param src decomposed matrix
RyoheiHagimoto 0:0e0631af0305 2615 @param w calculated singular values
RyoheiHagimoto 0:0e0631af0305 2616 @param flags operation flags - see SVD::Flags.
RyoheiHagimoto 0:0e0631af0305 2617 */
RyoheiHagimoto 0:0e0631af0305 2618 static void compute( InputArray src, OutputArray w, int flags = 0 );
RyoheiHagimoto 0:0e0631af0305 2619
RyoheiHagimoto 0:0e0631af0305 2620 /** @brief performs back substitution
RyoheiHagimoto 0:0e0631af0305 2621 */
RyoheiHagimoto 0:0e0631af0305 2622 static void backSubst( InputArray w, InputArray u,
RyoheiHagimoto 0:0e0631af0305 2623 InputArray vt, InputArray rhs,
RyoheiHagimoto 0:0e0631af0305 2624 OutputArray dst );
RyoheiHagimoto 0:0e0631af0305 2625
RyoheiHagimoto 0:0e0631af0305 2626 /** @brief solves an under-determined singular linear system
RyoheiHagimoto 0:0e0631af0305 2627
RyoheiHagimoto 0:0e0631af0305 2628 The method finds a unit-length solution x of a singular linear system
RyoheiHagimoto 0:0e0631af0305 2629 A\*x = 0. Depending on the rank of A, there can be no solutions, a
RyoheiHagimoto 0:0e0631af0305 2630 single solution or an infinite number of solutions. In general, the
RyoheiHagimoto 0:0e0631af0305 2631 algorithm solves the following problem:
RyoheiHagimoto 0:0e0631af0305 2632 \f[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\f]
RyoheiHagimoto 0:0e0631af0305 2633 @param src left-hand-side matrix.
RyoheiHagimoto 0:0e0631af0305 2634 @param dst found solution.
RyoheiHagimoto 0:0e0631af0305 2635 */
RyoheiHagimoto 0:0e0631af0305 2636 static void solveZ( InputArray src, OutputArray dst );
RyoheiHagimoto 0:0e0631af0305 2637
RyoheiHagimoto 0:0e0631af0305 2638 /** @brief performs a singular value back substitution.
RyoheiHagimoto 0:0e0631af0305 2639
RyoheiHagimoto 0:0e0631af0305 2640 The method calculates a back substitution for the specified right-hand
RyoheiHagimoto 0:0e0631af0305 2641 side:
RyoheiHagimoto 0:0e0631af0305 2642
RyoheiHagimoto 0:0e0631af0305 2643 \f[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\f]
RyoheiHagimoto 0:0e0631af0305 2644
RyoheiHagimoto 0:0e0631af0305 2645 Using this technique you can either get a very accurate solution of the
RyoheiHagimoto 0:0e0631af0305 2646 convenient linear system, or the best (in the least-squares terms)
RyoheiHagimoto 0:0e0631af0305 2647 pseudo-solution of an overdetermined linear system.
RyoheiHagimoto 0:0e0631af0305 2648
RyoheiHagimoto 0:0e0631af0305 2649 @param rhs right-hand side of a linear system (u\*w\*v')\*dst = rhs to
RyoheiHagimoto 0:0e0631af0305 2650 be solved, where A has been previously decomposed.
RyoheiHagimoto 0:0e0631af0305 2651
RyoheiHagimoto 0:0e0631af0305 2652 @param dst found solution of the system.
RyoheiHagimoto 0:0e0631af0305 2653
RyoheiHagimoto 0:0e0631af0305 2654 @note Explicit SVD with the further back substitution only makes sense
RyoheiHagimoto 0:0e0631af0305 2655 if you need to solve many linear systems with the same left-hand side
RyoheiHagimoto 0:0e0631af0305 2656 (for example, src ). If all you need is to solve a single system
RyoheiHagimoto 0:0e0631af0305 2657 (possibly with multiple rhs immediately available), simply call solve
RyoheiHagimoto 0:0e0631af0305 2658 add pass DECOMP_SVD there. It does absolutely the same thing.
RyoheiHagimoto 0:0e0631af0305 2659 */
RyoheiHagimoto 0:0e0631af0305 2660 void backSubst( InputArray rhs, OutputArray dst ) const;
RyoheiHagimoto 0:0e0631af0305 2661
RyoheiHagimoto 0:0e0631af0305 2662 /** @todo document */
RyoheiHagimoto 0:0e0631af0305 2663 template<typename _Tp, int m, int n, int nm> static
RyoheiHagimoto 0:0e0631af0305 2664 void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt );
RyoheiHagimoto 0:0e0631af0305 2665
RyoheiHagimoto 0:0e0631af0305 2666 /** @todo document */
RyoheiHagimoto 0:0e0631af0305 2667 template<typename _Tp, int m, int n, int nm> static
RyoheiHagimoto 0:0e0631af0305 2668 void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w );
RyoheiHagimoto 0:0e0631af0305 2669
RyoheiHagimoto 0:0e0631af0305 2670 /** @todo document */
RyoheiHagimoto 0:0e0631af0305 2671 template<typename _Tp, int m, int n, int nm, int nb> static
RyoheiHagimoto 0:0e0631af0305 2672 void backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, Matx<_Tp, n, nb>& dst );
RyoheiHagimoto 0:0e0631af0305 2673
RyoheiHagimoto 0:0e0631af0305 2674 Mat u, w, vt;
RyoheiHagimoto 0:0e0631af0305 2675 };
RyoheiHagimoto 0:0e0631af0305 2676
RyoheiHagimoto 0:0e0631af0305 2677 /** @brief Random Number Generator
RyoheiHagimoto 0:0e0631af0305 2678
RyoheiHagimoto 0:0e0631af0305 2679 Random number generator. It encapsulates the state (currently, a 64-bit
RyoheiHagimoto 0:0e0631af0305 2680 integer) and has methods to return scalar random values and to fill
RyoheiHagimoto 0:0e0631af0305 2681 arrays with random values. Currently it supports uniform and Gaussian
RyoheiHagimoto 0:0e0631af0305 2682 (normal) distributions. The generator uses Multiply-With-Carry
RyoheiHagimoto 0:0e0631af0305 2683 algorithm, introduced by G. Marsaglia (
RyoheiHagimoto 0:0e0631af0305 2684 <http://en.wikipedia.org/wiki/Multiply-with-carry> ).
RyoheiHagimoto 0:0e0631af0305 2685 Gaussian-distribution random numbers are generated using the Ziggurat
RyoheiHagimoto 0:0e0631af0305 2686 algorithm ( <http://en.wikipedia.org/wiki/Ziggurat_algorithm> ),
RyoheiHagimoto 0:0e0631af0305 2687 introduced by G. Marsaglia and W. W. Tsang.
RyoheiHagimoto 0:0e0631af0305 2688 */
RyoheiHagimoto 0:0e0631af0305 2689 class CV_EXPORTS RNG
RyoheiHagimoto 0:0e0631af0305 2690 {
RyoheiHagimoto 0:0e0631af0305 2691 public:
RyoheiHagimoto 0:0e0631af0305 2692 enum { UNIFORM = 0,
RyoheiHagimoto 0:0e0631af0305 2693 NORMAL = 1
RyoheiHagimoto 0:0e0631af0305 2694 };
RyoheiHagimoto 0:0e0631af0305 2695
RyoheiHagimoto 0:0e0631af0305 2696 /** @brief constructor
RyoheiHagimoto 0:0e0631af0305 2697
RyoheiHagimoto 0:0e0631af0305 2698 These are the RNG constructors. The first form sets the state to some
RyoheiHagimoto 0:0e0631af0305 2699 pre-defined value, equal to 2\*\*32-1 in the current implementation. The
RyoheiHagimoto 0:0e0631af0305 2700 second form sets the state to the specified value. If you passed state=0
RyoheiHagimoto 0:0e0631af0305 2701 , the constructor uses the above default value instead to avoid the
RyoheiHagimoto 0:0e0631af0305 2702 singular random number sequence, consisting of all zeros.
RyoheiHagimoto 0:0e0631af0305 2703 */
RyoheiHagimoto 0:0e0631af0305 2704 RNG();
RyoheiHagimoto 0:0e0631af0305 2705 /** @overload
RyoheiHagimoto 0:0e0631af0305 2706 @param state 64-bit value used to initialize the RNG.
RyoheiHagimoto 0:0e0631af0305 2707 */
RyoheiHagimoto 0:0e0631af0305 2708 RNG(uint64 state);
RyoheiHagimoto 0:0e0631af0305 2709 /**The method updates the state using the MWC algorithm and returns the
RyoheiHagimoto 0:0e0631af0305 2710 next 32-bit random number.*/
RyoheiHagimoto 0:0e0631af0305 2711 unsigned next();
RyoheiHagimoto 0:0e0631af0305 2712
RyoheiHagimoto 0:0e0631af0305 2713 /**Each of the methods updates the state using the MWC algorithm and
RyoheiHagimoto 0:0e0631af0305 2714 returns the next random number of the specified type. In case of integer
RyoheiHagimoto 0:0e0631af0305 2715 types, the returned number is from the available value range for the
RyoheiHagimoto 0:0e0631af0305 2716 specified type. In case of floating-point types, the returned value is
RyoheiHagimoto 0:0e0631af0305 2717 from [0,1) range.
RyoheiHagimoto 0:0e0631af0305 2718 */
RyoheiHagimoto 0:0e0631af0305 2719 operator uchar();
RyoheiHagimoto 0:0e0631af0305 2720 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2721 operator schar();
RyoheiHagimoto 0:0e0631af0305 2722 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2723 operator ushort();
RyoheiHagimoto 0:0e0631af0305 2724 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2725 operator short();
RyoheiHagimoto 0:0e0631af0305 2726 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2727 operator unsigned();
RyoheiHagimoto 0:0e0631af0305 2728 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2729 operator int();
RyoheiHagimoto 0:0e0631af0305 2730 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2731 operator float();
RyoheiHagimoto 0:0e0631af0305 2732 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2733 operator double();
RyoheiHagimoto 0:0e0631af0305 2734
RyoheiHagimoto 0:0e0631af0305 2735 /** @brief returns a random integer sampled uniformly from [0, N).
RyoheiHagimoto 0:0e0631af0305 2736
RyoheiHagimoto 0:0e0631af0305 2737 The methods transform the state using the MWC algorithm and return the
RyoheiHagimoto 0:0e0631af0305 2738 next random number. The first form is equivalent to RNG::next . The
RyoheiHagimoto 0:0e0631af0305 2739 second form returns the random number modulo N , which means that the
RyoheiHagimoto 0:0e0631af0305 2740 result is in the range [0, N) .
RyoheiHagimoto 0:0e0631af0305 2741 */
RyoheiHagimoto 0:0e0631af0305 2742 unsigned operator ()();
RyoheiHagimoto 0:0e0631af0305 2743 /** @overload
RyoheiHagimoto 0:0e0631af0305 2744 @param N upper non-inclusive boundary of the returned random number.
RyoheiHagimoto 0:0e0631af0305 2745 */
RyoheiHagimoto 0:0e0631af0305 2746 unsigned operator ()(unsigned N);
RyoheiHagimoto 0:0e0631af0305 2747
RyoheiHagimoto 0:0e0631af0305 2748 /** @brief returns uniformly distributed integer random number from [a,b) range
RyoheiHagimoto 0:0e0631af0305 2749
RyoheiHagimoto 0:0e0631af0305 2750 The methods transform the state using the MWC algorithm and return the
RyoheiHagimoto 0:0e0631af0305 2751 next uniformly-distributed random number of the specified type, deduced
RyoheiHagimoto 0:0e0631af0305 2752 from the input parameter type, from the range [a, b) . There is a nuance
RyoheiHagimoto 0:0e0631af0305 2753 illustrated by the following sample:
RyoheiHagimoto 0:0e0631af0305 2754
RyoheiHagimoto 0:0e0631af0305 2755 @code{.cpp}
RyoheiHagimoto 0:0e0631af0305 2756 RNG rng;
RyoheiHagimoto 0:0e0631af0305 2757
RyoheiHagimoto 0:0e0631af0305 2758 // always produces 0
RyoheiHagimoto 0:0e0631af0305 2759 double a = rng.uniform(0, 1);
RyoheiHagimoto 0:0e0631af0305 2760
RyoheiHagimoto 0:0e0631af0305 2761 // produces double from [0, 1)
RyoheiHagimoto 0:0e0631af0305 2762 double a1 = rng.uniform((double)0, (double)1);
RyoheiHagimoto 0:0e0631af0305 2763
RyoheiHagimoto 0:0e0631af0305 2764 // produces float from [0, 1)
RyoheiHagimoto 0:0e0631af0305 2765 double b = rng.uniform(0.f, 1.f);
RyoheiHagimoto 0:0e0631af0305 2766
RyoheiHagimoto 0:0e0631af0305 2767 // produces double from [0, 1)
RyoheiHagimoto 0:0e0631af0305 2768 double c = rng.uniform(0., 1.);
RyoheiHagimoto 0:0e0631af0305 2769
RyoheiHagimoto 0:0e0631af0305 2770 // may cause compiler error because of ambiguity:
RyoheiHagimoto 0:0e0631af0305 2771 // RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)?
RyoheiHagimoto 0:0e0631af0305 2772 double d = rng.uniform(0, 0.999999);
RyoheiHagimoto 0:0e0631af0305 2773 @endcode
RyoheiHagimoto 0:0e0631af0305 2774
RyoheiHagimoto 0:0e0631af0305 2775 The compiler does not take into account the type of the variable to
RyoheiHagimoto 0:0e0631af0305 2776 which you assign the result of RNG::uniform . The only thing that
RyoheiHagimoto 0:0e0631af0305 2777 matters to the compiler is the type of a and b parameters. So, if you
RyoheiHagimoto 0:0e0631af0305 2778 want a floating-point random number, but the range boundaries are
RyoheiHagimoto 0:0e0631af0305 2779 integer numbers, either put dots in the end, if they are constants, or
RyoheiHagimoto 0:0e0631af0305 2780 use explicit type cast operators, as in the a1 initialization above.
RyoheiHagimoto 0:0e0631af0305 2781 @param a lower inclusive boundary of the returned random numbers.
RyoheiHagimoto 0:0e0631af0305 2782 @param b upper non-inclusive boundary of the returned random numbers.
RyoheiHagimoto 0:0e0631af0305 2783 */
RyoheiHagimoto 0:0e0631af0305 2784 int uniform(int a, int b);
RyoheiHagimoto 0:0e0631af0305 2785 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2786 float uniform(float a, float b);
RyoheiHagimoto 0:0e0631af0305 2787 /** @overload */
RyoheiHagimoto 0:0e0631af0305 2788 double uniform(double a, double b);
RyoheiHagimoto 0:0e0631af0305 2789
RyoheiHagimoto 0:0e0631af0305 2790 /** @brief Fills arrays with random numbers.
RyoheiHagimoto 0:0e0631af0305 2791
RyoheiHagimoto 0:0e0631af0305 2792 @param mat 2D or N-dimensional matrix; currently matrices with more than
RyoheiHagimoto 0:0e0631af0305 2793 4 channels are not supported by the methods, use Mat::reshape as a
RyoheiHagimoto 0:0e0631af0305 2794 possible workaround.
RyoheiHagimoto 0:0e0631af0305 2795 @param distType distribution type, RNG::UNIFORM or RNG::NORMAL.
RyoheiHagimoto 0:0e0631af0305 2796 @param a first distribution parameter; in case of the uniform
RyoheiHagimoto 0:0e0631af0305 2797 distribution, this is an inclusive lower boundary, in case of the normal
RyoheiHagimoto 0:0e0631af0305 2798 distribution, this is a mean value.
RyoheiHagimoto 0:0e0631af0305 2799 @param b second distribution parameter; in case of the uniform
RyoheiHagimoto 0:0e0631af0305 2800 distribution, this is a non-inclusive upper boundary, in case of the
RyoheiHagimoto 0:0e0631af0305 2801 normal distribution, this is a standard deviation (diagonal of the
RyoheiHagimoto 0:0e0631af0305 2802 standard deviation matrix or the full standard deviation matrix).
RyoheiHagimoto 0:0e0631af0305 2803 @param saturateRange pre-saturation flag; for uniform distribution only;
RyoheiHagimoto 0:0e0631af0305 2804 if true, the method will first convert a and b to the acceptable value
RyoheiHagimoto 0:0e0631af0305 2805 range (according to the mat datatype) and then will generate uniformly
RyoheiHagimoto 0:0e0631af0305 2806 distributed random numbers within the range [saturate(a), saturate(b)),
RyoheiHagimoto 0:0e0631af0305 2807 if saturateRange=false, the method will generate uniformly distributed
RyoheiHagimoto 0:0e0631af0305 2808 random numbers in the original range [a, b) and then will saturate them,
RyoheiHagimoto 0:0e0631af0305 2809 it means, for example, that
RyoheiHagimoto 0:0e0631af0305 2810 <tt>theRNG().fill(mat_8u, RNG::UNIFORM, -DBL_MAX, DBL_MAX)</tt> will likely
RyoheiHagimoto 0:0e0631af0305 2811 produce array mostly filled with 0's and 255's, since the range (0, 255)
RyoheiHagimoto 0:0e0631af0305 2812 is significantly smaller than [-DBL_MAX, DBL_MAX).
RyoheiHagimoto 0:0e0631af0305 2813
RyoheiHagimoto 0:0e0631af0305 2814 Each of the methods fills the matrix with the random values from the
RyoheiHagimoto 0:0e0631af0305 2815 specified distribution. As the new numbers are generated, the RNG state
RyoheiHagimoto 0:0e0631af0305 2816 is updated accordingly. In case of multiple-channel images, every
RyoheiHagimoto 0:0e0631af0305 2817 channel is filled independently, which means that RNG cannot generate
RyoheiHagimoto 0:0e0631af0305 2818 samples from the multi-dimensional Gaussian distribution with
RyoheiHagimoto 0:0e0631af0305 2819 non-diagonal covariance matrix directly. To do that, the method
RyoheiHagimoto 0:0e0631af0305 2820 generates samples from multi-dimensional standard Gaussian distribution
RyoheiHagimoto 0:0e0631af0305 2821 with zero mean and identity covariation matrix, and then transforms them
RyoheiHagimoto 0:0e0631af0305 2822 using transform to get samples from the specified Gaussian distribution.
RyoheiHagimoto 0:0e0631af0305 2823 */
RyoheiHagimoto 0:0e0631af0305 2824 void fill( InputOutputArray mat, int distType, InputArray a, InputArray b, bool saturateRange = false );
RyoheiHagimoto 0:0e0631af0305 2825
RyoheiHagimoto 0:0e0631af0305 2826 /** @brief Returns the next random number sampled from the Gaussian distribution
RyoheiHagimoto 0:0e0631af0305 2827 @param sigma standard deviation of the distribution.
RyoheiHagimoto 0:0e0631af0305 2828
RyoheiHagimoto 0:0e0631af0305 2829 The method transforms the state using the MWC algorithm and returns the
RyoheiHagimoto 0:0e0631af0305 2830 next random number from the Gaussian distribution N(0,sigma) . That is,
RyoheiHagimoto 0:0e0631af0305 2831 the mean value of the returned random numbers is zero and the standard
RyoheiHagimoto 0:0e0631af0305 2832 deviation is the specified sigma .
RyoheiHagimoto 0:0e0631af0305 2833 */
RyoheiHagimoto 0:0e0631af0305 2834 double gaussian(double sigma);
RyoheiHagimoto 0:0e0631af0305 2835
RyoheiHagimoto 0:0e0631af0305 2836 uint64 state;
RyoheiHagimoto 0:0e0631af0305 2837 };
RyoheiHagimoto 0:0e0631af0305 2838
RyoheiHagimoto 0:0e0631af0305 2839 /** @brief Mersenne Twister random number generator
RyoheiHagimoto 0:0e0631af0305 2840
RyoheiHagimoto 0:0e0631af0305 2841 Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
RyoheiHagimoto 0:0e0631af0305 2842 @todo document
RyoheiHagimoto 0:0e0631af0305 2843 */
RyoheiHagimoto 0:0e0631af0305 2844 class CV_EXPORTS RNG_MT19937
RyoheiHagimoto 0:0e0631af0305 2845 {
RyoheiHagimoto 0:0e0631af0305 2846 public:
RyoheiHagimoto 0:0e0631af0305 2847 RNG_MT19937();
RyoheiHagimoto 0:0e0631af0305 2848 RNG_MT19937(unsigned s);
RyoheiHagimoto 0:0e0631af0305 2849 void seed(unsigned s);
RyoheiHagimoto 0:0e0631af0305 2850
RyoheiHagimoto 0:0e0631af0305 2851 unsigned next();
RyoheiHagimoto 0:0e0631af0305 2852
RyoheiHagimoto 0:0e0631af0305 2853 operator int();
RyoheiHagimoto 0:0e0631af0305 2854 operator unsigned();
RyoheiHagimoto 0:0e0631af0305 2855 operator float();
RyoheiHagimoto 0:0e0631af0305 2856 operator double();
RyoheiHagimoto 0:0e0631af0305 2857
RyoheiHagimoto 0:0e0631af0305 2858 unsigned operator ()(unsigned N);
RyoheiHagimoto 0:0e0631af0305 2859 unsigned operator ()();
RyoheiHagimoto 0:0e0631af0305 2860
RyoheiHagimoto 0:0e0631af0305 2861 /** @brief returns uniformly distributed integer random number from [a,b) range
RyoheiHagimoto 0:0e0631af0305 2862
RyoheiHagimoto 0:0e0631af0305 2863 */
RyoheiHagimoto 0:0e0631af0305 2864 int uniform(int a, int b);
RyoheiHagimoto 0:0e0631af0305 2865 /** @brief returns uniformly distributed floating-point random number from [a,b) range
RyoheiHagimoto 0:0e0631af0305 2866
RyoheiHagimoto 0:0e0631af0305 2867 */
RyoheiHagimoto 0:0e0631af0305 2868 float uniform(float a, float b);
RyoheiHagimoto 0:0e0631af0305 2869 /** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range
RyoheiHagimoto 0:0e0631af0305 2870
RyoheiHagimoto 0:0e0631af0305 2871 */
RyoheiHagimoto 0:0e0631af0305 2872 double uniform(double a, double b);
RyoheiHagimoto 0:0e0631af0305 2873
RyoheiHagimoto 0:0e0631af0305 2874 private:
RyoheiHagimoto 0:0e0631af0305 2875 enum PeriodParameters {N = 624, M = 397};
RyoheiHagimoto 0:0e0631af0305 2876 unsigned state[N];
RyoheiHagimoto 0:0e0631af0305 2877 int mti;
RyoheiHagimoto 0:0e0631af0305 2878 };
RyoheiHagimoto 0:0e0631af0305 2879
RyoheiHagimoto 0:0e0631af0305 2880 //! @} core_array
RyoheiHagimoto 0:0e0631af0305 2881
RyoheiHagimoto 0:0e0631af0305 2882 //! @addtogroup core_cluster
RyoheiHagimoto 0:0e0631af0305 2883 //! @{
RyoheiHagimoto 0:0e0631af0305 2884
RyoheiHagimoto 0:0e0631af0305 2885 /** @example kmeans.cpp
RyoheiHagimoto 0:0e0631af0305 2886 An example on K-means clustering
RyoheiHagimoto 0:0e0631af0305 2887 */
RyoheiHagimoto 0:0e0631af0305 2888
RyoheiHagimoto 0:0e0631af0305 2889 /** @brief Finds centers of clusters and groups input samples around the clusters.
RyoheiHagimoto 0:0e0631af0305 2890
RyoheiHagimoto 0:0e0631af0305 2891 The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
RyoheiHagimoto 0:0e0631af0305 2892 and groups the input samples around the clusters. As an output, \f$\texttt{labels}_i\f$ contains a
RyoheiHagimoto 0:0e0631af0305 2893 0-based cluster index for the sample stored in the \f$i^{th}\f$ row of the samples matrix.
RyoheiHagimoto 0:0e0631af0305 2894
RyoheiHagimoto 0:0e0631af0305 2895 @note
RyoheiHagimoto 0:0e0631af0305 2896 - (Python) An example on K-means clustering can be found at
RyoheiHagimoto 0:0e0631af0305 2897 opencv_source_code/samples/python/kmeans.py
RyoheiHagimoto 0:0e0631af0305 2898 @param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
RyoheiHagimoto 0:0e0631af0305 2899 Examples of this array can be:
RyoheiHagimoto 0:0e0631af0305 2900 - Mat points(count, 2, CV_32F);
RyoheiHagimoto 0:0e0631af0305 2901 - Mat points(count, 1, CV_32FC2);
RyoheiHagimoto 0:0e0631af0305 2902 - Mat points(1, count, CV_32FC2);
RyoheiHagimoto 0:0e0631af0305 2903 - std::vector\<cv::Point2f\> points(sampleCount);
RyoheiHagimoto 0:0e0631af0305 2904 @param K Number of clusters to split the set by.
RyoheiHagimoto 0:0e0631af0305 2905 @param bestLabels Input/output integer array that stores the cluster indices for every sample.
RyoheiHagimoto 0:0e0631af0305 2906 @param criteria The algorithm termination criteria, that is, the maximum number of iterations and/or
RyoheiHagimoto 0:0e0631af0305 2907 the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster
RyoheiHagimoto 0:0e0631af0305 2908 centers moves by less than criteria.epsilon on some iteration, the algorithm stops.
RyoheiHagimoto 0:0e0631af0305 2909 @param attempts Flag to specify the number of times the algorithm is executed using different
RyoheiHagimoto 0:0e0631af0305 2910 initial labellings. The algorithm returns the labels that yield the best compactness (see the last
RyoheiHagimoto 0:0e0631af0305 2911 function parameter).
RyoheiHagimoto 0:0e0631af0305 2912 @param flags Flag that can take values of cv::KmeansFlags
RyoheiHagimoto 0:0e0631af0305 2913 @param centers Output matrix of the cluster centers, one row per each cluster center.
RyoheiHagimoto 0:0e0631af0305 2914 @return The function returns the compactness measure that is computed as
RyoheiHagimoto 0:0e0631af0305 2915 \f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\f]
RyoheiHagimoto 0:0e0631af0305 2916 after every attempt. The best (minimum) value is chosen and the corresponding labels and the
RyoheiHagimoto 0:0e0631af0305 2917 compactness value are returned by the function. Basically, you can use only the core of the
RyoheiHagimoto 0:0e0631af0305 2918 function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
RyoheiHagimoto 0:0e0631af0305 2919 pass them with the ( flags = KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
RyoheiHagimoto 0:0e0631af0305 2920 (most-compact) clustering.
RyoheiHagimoto 0:0e0631af0305 2921 */
RyoheiHagimoto 0:0e0631af0305 2922 CV_EXPORTS_W double kmeans( InputArray data, int K, InputOutputArray bestLabels,
RyoheiHagimoto 0:0e0631af0305 2923 TermCriteria criteria, int attempts,
RyoheiHagimoto 0:0e0631af0305 2924 int flags, OutputArray centers = noArray() );
RyoheiHagimoto 0:0e0631af0305 2925
RyoheiHagimoto 0:0e0631af0305 2926 //! @} core_cluster
RyoheiHagimoto 0:0e0631af0305 2927
RyoheiHagimoto 0:0e0631af0305 2928 //! @addtogroup core_basic
RyoheiHagimoto 0:0e0631af0305 2929 //! @{
RyoheiHagimoto 0:0e0631af0305 2930
RyoheiHagimoto 0:0e0631af0305 2931 /////////////////////////////// Formatted output of cv::Mat ///////////////////////////
RyoheiHagimoto 0:0e0631af0305 2932
RyoheiHagimoto 0:0e0631af0305 2933 /** @todo document */
RyoheiHagimoto 0:0e0631af0305 2934 class CV_EXPORTS Formatted
RyoheiHagimoto 0:0e0631af0305 2935 {
RyoheiHagimoto 0:0e0631af0305 2936 public:
RyoheiHagimoto 0:0e0631af0305 2937 virtual const char* next() = 0;
RyoheiHagimoto 0:0e0631af0305 2938 virtual void reset() = 0;
RyoheiHagimoto 0:0e0631af0305 2939 virtual ~Formatted();
RyoheiHagimoto 0:0e0631af0305 2940 };
RyoheiHagimoto 0:0e0631af0305 2941
RyoheiHagimoto 0:0e0631af0305 2942 /** @todo document */
RyoheiHagimoto 0:0e0631af0305 2943 class CV_EXPORTS Formatter
RyoheiHagimoto 0:0e0631af0305 2944 {
RyoheiHagimoto 0:0e0631af0305 2945 public:
RyoheiHagimoto 0:0e0631af0305 2946 enum { FMT_DEFAULT = 0,
RyoheiHagimoto 0:0e0631af0305 2947 FMT_MATLAB = 1,
RyoheiHagimoto 0:0e0631af0305 2948 FMT_CSV = 2,
RyoheiHagimoto 0:0e0631af0305 2949 FMT_PYTHON = 3,
RyoheiHagimoto 0:0e0631af0305 2950 FMT_NUMPY = 4,
RyoheiHagimoto 0:0e0631af0305 2951 FMT_C = 5
RyoheiHagimoto 0:0e0631af0305 2952 };
RyoheiHagimoto 0:0e0631af0305 2953
RyoheiHagimoto 0:0e0631af0305 2954 virtual ~Formatter();
RyoheiHagimoto 0:0e0631af0305 2955
RyoheiHagimoto 0:0e0631af0305 2956 virtual Ptr<Formatted> format(const Mat& mtx) const = 0;
RyoheiHagimoto 0:0e0631af0305 2957
RyoheiHagimoto 0:0e0631af0305 2958 virtual void set32fPrecision(int p = 8) = 0;
RyoheiHagimoto 0:0e0631af0305 2959 virtual void set64fPrecision(int p = 16) = 0;
RyoheiHagimoto 0:0e0631af0305 2960 virtual void setMultiline(bool ml = true) = 0;
RyoheiHagimoto 0:0e0631af0305 2961
RyoheiHagimoto 0:0e0631af0305 2962 static Ptr<Formatter> get(int fmt = FMT_DEFAULT);
RyoheiHagimoto 0:0e0631af0305 2963
RyoheiHagimoto 0:0e0631af0305 2964 };
RyoheiHagimoto 0:0e0631af0305 2965
RyoheiHagimoto 0:0e0631af0305 2966 static inline
RyoheiHagimoto 0:0e0631af0305 2967 String& operator << (String& out, Ptr<Formatted> fmtd)
RyoheiHagimoto 0:0e0631af0305 2968 {
RyoheiHagimoto 0:0e0631af0305 2969 fmtd->reset();
RyoheiHagimoto 0:0e0631af0305 2970 for(const char* str = fmtd->next(); str; str = fmtd->next())
RyoheiHagimoto 0:0e0631af0305 2971 out += cv::String(str);
RyoheiHagimoto 0:0e0631af0305 2972 return out;
RyoheiHagimoto 0:0e0631af0305 2973 }
RyoheiHagimoto 0:0e0631af0305 2974
RyoheiHagimoto 0:0e0631af0305 2975 static inline
RyoheiHagimoto 0:0e0631af0305 2976 String& operator << (String& out, const Mat& mtx)
RyoheiHagimoto 0:0e0631af0305 2977 {
RyoheiHagimoto 0:0e0631af0305 2978 return out << Formatter::get()->format(mtx);
RyoheiHagimoto 0:0e0631af0305 2979 }
RyoheiHagimoto 0:0e0631af0305 2980
RyoheiHagimoto 0:0e0631af0305 2981 //////////////////////////////////////// Algorithm ////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2982
RyoheiHagimoto 0:0e0631af0305 2983 class CV_EXPORTS Algorithm;
RyoheiHagimoto 0:0e0631af0305 2984
RyoheiHagimoto 0:0e0631af0305 2985 template<typename _Tp> struct ParamType {};
RyoheiHagimoto 0:0e0631af0305 2986
RyoheiHagimoto 0:0e0631af0305 2987
RyoheiHagimoto 0:0e0631af0305 2988 /** @brief This is a base class for all more or less complex algorithms in OpenCV
RyoheiHagimoto 0:0e0631af0305 2989
RyoheiHagimoto 0:0e0631af0305 2990 especially for classes of algorithms, for which there can be multiple implementations. The examples
RyoheiHagimoto 0:0e0631af0305 2991 are stereo correspondence (for which there are algorithms like block matching, semi-global block
RyoheiHagimoto 0:0e0631af0305 2992 matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians
RyoheiHagimoto 0:0e0631af0305 2993 models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck
RyoheiHagimoto 0:0e0631af0305 2994 etc.).
RyoheiHagimoto 0:0e0631af0305 2995
RyoheiHagimoto 0:0e0631af0305 2996 Here is example of SIFT use in your application via Algorithm interface:
RyoheiHagimoto 0:0e0631af0305 2997 @code
RyoheiHagimoto 0:0e0631af0305 2998 #include "opencv2/opencv.hpp"
RyoheiHagimoto 0:0e0631af0305 2999 #include "opencv2/xfeatures2d.hpp"
RyoheiHagimoto 0:0e0631af0305 3000 using namespace cv::xfeatures2d;
RyoheiHagimoto 0:0e0631af0305 3001
RyoheiHagimoto 0:0e0631af0305 3002 Ptr<Feature2D> sift = SIFT::create();
RyoheiHagimoto 0:0e0631af0305 3003 FileStorage fs("sift_params.xml", FileStorage::READ);
RyoheiHagimoto 0:0e0631af0305 3004 if( fs.isOpened() ) // if we have file with parameters, read them
RyoheiHagimoto 0:0e0631af0305 3005 {
RyoheiHagimoto 0:0e0631af0305 3006 sift->read(fs["sift_params"]);
RyoheiHagimoto 0:0e0631af0305 3007 fs.release();
RyoheiHagimoto 0:0e0631af0305 3008 }
RyoheiHagimoto 0:0e0631af0305 3009 else // else modify the parameters and store them; user can later edit the file to use different parameters
RyoheiHagimoto 0:0e0631af0305 3010 {
RyoheiHagimoto 0:0e0631af0305 3011 sift->setContrastThreshold(0.01f); // lower the contrast threshold, compared to the default value
RyoheiHagimoto 0:0e0631af0305 3012 {
RyoheiHagimoto 0:0e0631af0305 3013 WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);
RyoheiHagimoto 0:0e0631af0305 3014 sift->write(fs);
RyoheiHagimoto 0:0e0631af0305 3015 }
RyoheiHagimoto 0:0e0631af0305 3016 }
RyoheiHagimoto 0:0e0631af0305 3017 Mat image = imread("myimage.png", 0), descriptors;
RyoheiHagimoto 0:0e0631af0305 3018 vector<KeyPoint> keypoints;
RyoheiHagimoto 0:0e0631af0305 3019 sift->detectAndCompute(image, noArray(), keypoints, descriptors);
RyoheiHagimoto 0:0e0631af0305 3020 @endcode
RyoheiHagimoto 0:0e0631af0305 3021 */
RyoheiHagimoto 0:0e0631af0305 3022 class CV_EXPORTS_W Algorithm
RyoheiHagimoto 0:0e0631af0305 3023 {
RyoheiHagimoto 0:0e0631af0305 3024 public:
RyoheiHagimoto 0:0e0631af0305 3025 Algorithm();
RyoheiHagimoto 0:0e0631af0305 3026 virtual ~Algorithm();
RyoheiHagimoto 0:0e0631af0305 3027
RyoheiHagimoto 0:0e0631af0305 3028 /** @brief Clears the algorithm state
RyoheiHagimoto 0:0e0631af0305 3029 */
RyoheiHagimoto 0:0e0631af0305 3030 CV_WRAP virtual void clear() {}
RyoheiHagimoto 0:0e0631af0305 3031
RyoheiHagimoto 0:0e0631af0305 3032 /** @brief Stores algorithm parameters in a file storage
RyoheiHagimoto 0:0e0631af0305 3033 */
RyoheiHagimoto 0:0e0631af0305 3034 virtual void write(FileStorage& fs) const { (void)fs; }
RyoheiHagimoto 0:0e0631af0305 3035
RyoheiHagimoto 0:0e0631af0305 3036 /** @brief Reads algorithm parameters from a file storage
RyoheiHagimoto 0:0e0631af0305 3037 */
RyoheiHagimoto 0:0e0631af0305 3038 virtual void read(const FileNode& fn) { (void)fn; }
RyoheiHagimoto 0:0e0631af0305 3039
RyoheiHagimoto 0:0e0631af0305 3040 /** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
RyoheiHagimoto 0:0e0631af0305 3041 */
RyoheiHagimoto 0:0e0631af0305 3042 virtual bool empty() const { return false; }
RyoheiHagimoto 0:0e0631af0305 3043
RyoheiHagimoto 0:0e0631af0305 3044 /** @brief Reads algorithm from the file node
RyoheiHagimoto 0:0e0631af0305 3045
RyoheiHagimoto 0:0e0631af0305 3046 This is static template method of Algorithm. It's usage is following (in the case of SVM):
RyoheiHagimoto 0:0e0631af0305 3047 @code
RyoheiHagimoto 0:0e0631af0305 3048 cv::FileStorage fsRead("example.xml", FileStorage::READ);
RyoheiHagimoto 0:0e0631af0305 3049 Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
RyoheiHagimoto 0:0e0631af0305 3050 @endcode
RyoheiHagimoto 0:0e0631af0305 3051 In order to make this method work, the derived class must overwrite Algorithm::read(const
RyoheiHagimoto 0:0e0631af0305 3052 FileNode& fn) and also have static create() method without parameters
RyoheiHagimoto 0:0e0631af0305 3053 (or with all the optional parameters)
RyoheiHagimoto 0:0e0631af0305 3054 */
RyoheiHagimoto 0:0e0631af0305 3055 template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
RyoheiHagimoto 0:0e0631af0305 3056 {
RyoheiHagimoto 0:0e0631af0305 3057 Ptr<_Tp> obj = _Tp::create();
RyoheiHagimoto 0:0e0631af0305 3058 obj->read(fn);
RyoheiHagimoto 0:0e0631af0305 3059 return !obj->empty() ? obj : Ptr<_Tp>();
RyoheiHagimoto 0:0e0631af0305 3060 }
RyoheiHagimoto 0:0e0631af0305 3061
RyoheiHagimoto 0:0e0631af0305 3062 /** @brief Loads algorithm from the file
RyoheiHagimoto 0:0e0631af0305 3063
RyoheiHagimoto 0:0e0631af0305 3064 @param filename Name of the file to read.
RyoheiHagimoto 0:0e0631af0305 3065 @param objname The optional name of the node to read (if empty, the first top-level node will be used)
RyoheiHagimoto 0:0e0631af0305 3066
RyoheiHagimoto 0:0e0631af0305 3067 This is static template method of Algorithm. It's usage is following (in the case of SVM):
RyoheiHagimoto 0:0e0631af0305 3068 @code
RyoheiHagimoto 0:0e0631af0305 3069 Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
RyoheiHagimoto 0:0e0631af0305 3070 @endcode
RyoheiHagimoto 0:0e0631af0305 3071 In order to make this method work, the derived class must overwrite Algorithm::read(const
RyoheiHagimoto 0:0e0631af0305 3072 FileNode& fn).
RyoheiHagimoto 0:0e0631af0305 3073 */
RyoheiHagimoto 0:0e0631af0305 3074 template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
RyoheiHagimoto 0:0e0631af0305 3075 {
RyoheiHagimoto 0:0e0631af0305 3076 FileStorage fs(filename, FileStorage::READ);
RyoheiHagimoto 0:0e0631af0305 3077 FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
RyoheiHagimoto 0:0e0631af0305 3078 if (fn.empty()) return Ptr<_Tp>();
RyoheiHagimoto 0:0e0631af0305 3079 Ptr<_Tp> obj = _Tp::create();
RyoheiHagimoto 0:0e0631af0305 3080 obj->read(fn);
RyoheiHagimoto 0:0e0631af0305 3081 return !obj->empty() ? obj : Ptr<_Tp>();
RyoheiHagimoto 0:0e0631af0305 3082 }
RyoheiHagimoto 0:0e0631af0305 3083
RyoheiHagimoto 0:0e0631af0305 3084 /** @brief Loads algorithm from a String
RyoheiHagimoto 0:0e0631af0305 3085
RyoheiHagimoto 0:0e0631af0305 3086 @param strModel The string variable containing the model you want to load.
RyoheiHagimoto 0:0e0631af0305 3087 @param objname The optional name of the node to read (if empty, the first top-level node will be used)
RyoheiHagimoto 0:0e0631af0305 3088
RyoheiHagimoto 0:0e0631af0305 3089 This is static template method of Algorithm. It's usage is following (in the case of SVM):
RyoheiHagimoto 0:0e0631af0305 3090 @code
RyoheiHagimoto 0:0e0631af0305 3091 Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
RyoheiHagimoto 0:0e0631af0305 3092 @endcode
RyoheiHagimoto 0:0e0631af0305 3093 */
RyoheiHagimoto 0:0e0631af0305 3094 template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
RyoheiHagimoto 0:0e0631af0305 3095 {
RyoheiHagimoto 0:0e0631af0305 3096 FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
RyoheiHagimoto 0:0e0631af0305 3097 FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
RyoheiHagimoto 0:0e0631af0305 3098 Ptr<_Tp> obj = _Tp::create();
RyoheiHagimoto 0:0e0631af0305 3099 obj->read(fn);
RyoheiHagimoto 0:0e0631af0305 3100 return !obj->empty() ? obj : Ptr<_Tp>();
RyoheiHagimoto 0:0e0631af0305 3101 }
RyoheiHagimoto 0:0e0631af0305 3102
RyoheiHagimoto 0:0e0631af0305 3103 /** Saves the algorithm to a file.
RyoheiHagimoto 0:0e0631af0305 3104 In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
RyoheiHagimoto 0:0e0631af0305 3105 CV_WRAP virtual void save(const String& filename) const;
RyoheiHagimoto 0:0e0631af0305 3106
RyoheiHagimoto 0:0e0631af0305 3107 /** Returns the algorithm string identifier.
RyoheiHagimoto 0:0e0631af0305 3108 This string is used as top level xml/yml node tag when the object is saved to a file or string. */
RyoheiHagimoto 0:0e0631af0305 3109 CV_WRAP virtual String getDefaultName() const;
RyoheiHagimoto 0:0e0631af0305 3110
RyoheiHagimoto 0:0e0631af0305 3111 protected:
RyoheiHagimoto 0:0e0631af0305 3112 void writeFormat(FileStorage& fs) const;
RyoheiHagimoto 0:0e0631af0305 3113 };
RyoheiHagimoto 0:0e0631af0305 3114
RyoheiHagimoto 0:0e0631af0305 3115 struct Param {
RyoheiHagimoto 0:0e0631af0305 3116 enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
RyoheiHagimoto 0:0e0631af0305 3117 UNSIGNED_INT=8, UINT64=9, UCHAR=11 };
RyoheiHagimoto 0:0e0631af0305 3118 };
RyoheiHagimoto 0:0e0631af0305 3119
RyoheiHagimoto 0:0e0631af0305 3120
RyoheiHagimoto 0:0e0631af0305 3121
RyoheiHagimoto 0:0e0631af0305 3122 template<> struct ParamType<bool>
RyoheiHagimoto 0:0e0631af0305 3123 {
RyoheiHagimoto 0:0e0631af0305 3124 typedef bool const_param_type;
RyoheiHagimoto 0:0e0631af0305 3125 typedef bool member_type;
RyoheiHagimoto 0:0e0631af0305 3126
RyoheiHagimoto 0:0e0631af0305 3127 enum { type = Param::BOOLEAN };
RyoheiHagimoto 0:0e0631af0305 3128 };
RyoheiHagimoto 0:0e0631af0305 3129
RyoheiHagimoto 0:0e0631af0305 3130 template<> struct ParamType<int>
RyoheiHagimoto 0:0e0631af0305 3131 {
RyoheiHagimoto 0:0e0631af0305 3132 typedef int const_param_type;
RyoheiHagimoto 0:0e0631af0305 3133 typedef int member_type;
RyoheiHagimoto 0:0e0631af0305 3134
RyoheiHagimoto 0:0e0631af0305 3135 enum { type = Param::INT };
RyoheiHagimoto 0:0e0631af0305 3136 };
RyoheiHagimoto 0:0e0631af0305 3137
RyoheiHagimoto 0:0e0631af0305 3138 template<> struct ParamType<double>
RyoheiHagimoto 0:0e0631af0305 3139 {
RyoheiHagimoto 0:0e0631af0305 3140 typedef double const_param_type;
RyoheiHagimoto 0:0e0631af0305 3141 typedef double member_type;
RyoheiHagimoto 0:0e0631af0305 3142
RyoheiHagimoto 0:0e0631af0305 3143 enum { type = Param::REAL };
RyoheiHagimoto 0:0e0631af0305 3144 };
RyoheiHagimoto 0:0e0631af0305 3145
RyoheiHagimoto 0:0e0631af0305 3146 template<> struct ParamType<String>
RyoheiHagimoto 0:0e0631af0305 3147 {
RyoheiHagimoto 0:0e0631af0305 3148 typedef const String& const_param_type;
RyoheiHagimoto 0:0e0631af0305 3149 typedef String member_type;
RyoheiHagimoto 0:0e0631af0305 3150
RyoheiHagimoto 0:0e0631af0305 3151 enum { type = Param::STRING };
RyoheiHagimoto 0:0e0631af0305 3152 };
RyoheiHagimoto 0:0e0631af0305 3153
RyoheiHagimoto 0:0e0631af0305 3154 template<> struct ParamType<Mat>
RyoheiHagimoto 0:0e0631af0305 3155 {
RyoheiHagimoto 0:0e0631af0305 3156 typedef const Mat& const_param_type;
RyoheiHagimoto 0:0e0631af0305 3157 typedef Mat member_type;
RyoheiHagimoto 0:0e0631af0305 3158
RyoheiHagimoto 0:0e0631af0305 3159 enum { type = Param::MAT };
RyoheiHagimoto 0:0e0631af0305 3160 };
RyoheiHagimoto 0:0e0631af0305 3161
RyoheiHagimoto 0:0e0631af0305 3162 template<> struct ParamType<std::vector<Mat> >
RyoheiHagimoto 0:0e0631af0305 3163 {
RyoheiHagimoto 0:0e0631af0305 3164 typedef const std::vector<Mat>& const_param_type;
RyoheiHagimoto 0:0e0631af0305 3165 typedef std::vector<Mat> member_type;
RyoheiHagimoto 0:0e0631af0305 3166
RyoheiHagimoto 0:0e0631af0305 3167 enum { type = Param::MAT_VECTOR };
RyoheiHagimoto 0:0e0631af0305 3168 };
RyoheiHagimoto 0:0e0631af0305 3169
RyoheiHagimoto 0:0e0631af0305 3170 template<> struct ParamType<Algorithm>
RyoheiHagimoto 0:0e0631af0305 3171 {
RyoheiHagimoto 0:0e0631af0305 3172 typedef const Ptr<Algorithm>& const_param_type;
RyoheiHagimoto 0:0e0631af0305 3173 typedef Ptr<Algorithm> member_type;
RyoheiHagimoto 0:0e0631af0305 3174
RyoheiHagimoto 0:0e0631af0305 3175 enum { type = Param::ALGORITHM };
RyoheiHagimoto 0:0e0631af0305 3176 };
RyoheiHagimoto 0:0e0631af0305 3177
RyoheiHagimoto 0:0e0631af0305 3178 template<> struct ParamType<float>
RyoheiHagimoto 0:0e0631af0305 3179 {
RyoheiHagimoto 0:0e0631af0305 3180 typedef float const_param_type;
RyoheiHagimoto 0:0e0631af0305 3181 typedef float member_type;
RyoheiHagimoto 0:0e0631af0305 3182
RyoheiHagimoto 0:0e0631af0305 3183 enum { type = Param::FLOAT };
RyoheiHagimoto 0:0e0631af0305 3184 };
RyoheiHagimoto 0:0e0631af0305 3185
RyoheiHagimoto 0:0e0631af0305 3186 template<> struct ParamType<unsigned>
RyoheiHagimoto 0:0e0631af0305 3187 {
RyoheiHagimoto 0:0e0631af0305 3188 typedef unsigned const_param_type;
RyoheiHagimoto 0:0e0631af0305 3189 typedef unsigned member_type;
RyoheiHagimoto 0:0e0631af0305 3190
RyoheiHagimoto 0:0e0631af0305 3191 enum { type = Param::UNSIGNED_INT };
RyoheiHagimoto 0:0e0631af0305 3192 };
RyoheiHagimoto 0:0e0631af0305 3193
RyoheiHagimoto 0:0e0631af0305 3194 template<> struct ParamType<uint64>
RyoheiHagimoto 0:0e0631af0305 3195 {
RyoheiHagimoto 0:0e0631af0305 3196 typedef uint64 const_param_type;
RyoheiHagimoto 0:0e0631af0305 3197 typedef uint64 member_type;
RyoheiHagimoto 0:0e0631af0305 3198
RyoheiHagimoto 0:0e0631af0305 3199 enum { type = Param::UINT64 };
RyoheiHagimoto 0:0e0631af0305 3200 };
RyoheiHagimoto 0:0e0631af0305 3201
RyoheiHagimoto 0:0e0631af0305 3202 template<> struct ParamType<uchar>
RyoheiHagimoto 0:0e0631af0305 3203 {
RyoheiHagimoto 0:0e0631af0305 3204 typedef uchar const_param_type;
RyoheiHagimoto 0:0e0631af0305 3205 typedef uchar member_type;
RyoheiHagimoto 0:0e0631af0305 3206
RyoheiHagimoto 0:0e0631af0305 3207 enum { type = Param::UCHAR };
RyoheiHagimoto 0:0e0631af0305 3208 };
RyoheiHagimoto 0:0e0631af0305 3209
RyoheiHagimoto 0:0e0631af0305 3210 //! @} core_basic
RyoheiHagimoto 0:0e0631af0305 3211
RyoheiHagimoto 0:0e0631af0305 3212 } //namespace cv
RyoheiHagimoto 0:0e0631af0305 3213
RyoheiHagimoto 0:0e0631af0305 3214 #include "opencv2/core/operations.hpp"
RyoheiHagimoto 0:0e0631af0305 3215 #include "opencv2/core/cvstd.inl.hpp"
RyoheiHagimoto 0:0e0631af0305 3216 #include "opencv2/core/utility.hpp"
RyoheiHagimoto 0:0e0631af0305 3217 #include "opencv2/core/optim.hpp"
RyoheiHagimoto 0:0e0631af0305 3218 #include "opencv2/core/ovx.hpp"
RyoheiHagimoto 0:0e0631af0305 3219
RyoheiHagimoto 0:0e0631af0305 3220 #endif /*OPENCV_CORE_HPP*/