]> rtime.felk.cvut.cz Git - opencv.git/blobdiff - opencv/doc/cxcore_array_operations.tex
fixed several documentation bugs
[opencv.git] / opencv / doc / cxcore_array_operations.tex
index b5d2a36b5c0ee220721368a5b6bc24b6cb424573..167e3dacb3bc6ca0d4c0643d2fb3c28f6b6aad92 100644 (file)
@@ -163,6 +163,7 @@ dst(I)=src(I)&value if mask(I)!=0
 
 Prior to the actual operation, the scalar is converted to the same type as that of the array(s). In the case of floating-point arrays their bit representations are used for the operation. All the arrays must have the same type, except the mask, and the same size.
 
+\ifC
 The following sample demonstrates how to calculate the absolute value of floating-point array elements by clearing the most-significant bit:
 
 \begin{lstlisting}
@@ -179,7 +180,7 @@ The code should print:
 \begin{lstlisting}
 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
 \end{lstlisting}
-
+\fi
 
 \cvCPyFunc{Avg}
 Calculates average (mean) of array elements.
@@ -197,7 +198,7 @@ The function calculates the average value \texttt{M} of array elements, independ
 \[
 \begin{array}{l}
 N = \sum_I (\texttt{mask}(I) \ne 0)\\
-M_c = \frac{\sum_{ I, \, \texttt{mask}(I) \ne 0} \texttt{arr}(I)_c}{N}
+M_c = \frac{\sum_{I, \, \texttt{mask}(I) \ne 0} \texttt{arr}(I)_c}{N}
 \end{array}
 \]
 
@@ -369,6 +370,7 @@ Creates full copy of a multi-dimensional array and returns a pointer to the copy
 \end{description}
 
 
+\ifC % {
 \cvCPyFunc{CloneSparseMat}
 Creates full copy of sparse array.
 
@@ -380,6 +382,7 @@ Creates full copy of sparse array.
 \end{description}
 
 The function creates a copy of the input array and returns pointer to the copy.
+\fi % }
 
 \cvCPyFunc{Cmp}
 Performs per-element comparison of two arrays.
@@ -441,17 +444,40 @@ where \texttt{op} is $=,\; >,\; \ge,\; <,\; \le\; or\; \ne$.
 
 \texttt{dst(I)} is set to 0xff (all \texttt{1}-bits) if the specific relation between the elements is true and 0 otherwise. All the arrays must have the same size (or ROI size).
 
+\ifPy % {
+\cvCPyFunc{Convert}
+Converts one array to another.
+
+\cvdefPy{Convert(src,dst)-> None}
+
+\begin{description}
+\cvarg{src}{Source array}
+\cvarg{dst}{Destination array}
+\end{description}
+
+
+The type of conversion is done with rounding and saturation, that is if the
+result of scaling + conversion can not be represented exactly by a value
+of the destination array element type, it is set to the nearest representable
+value on the real axis.
+
+All the channels of multi-channel arrays are processed independently.
+
+\fi % }
+
 \cvCPyFunc{ConvertScale}
 Converts one array to another with optional linear transformation.
 
 \cvdefC{void cvConvertScale(const CvArr* src, CvArr* dst, double scale=1, double shift=0);}
 \cvdefPy{ConvertScale(src,dst,scale=1.0,shift=0.0)-> None}
 
+\ifC
 \begin{lstlisting}
 #define cvCvtScale cvConvertScale
 #define cvScale  cvConvertScale
 #define cvConvert(src, dst )  cvConvertScale((src), (dst), 1, 0 )
 \end{lstlisting}
+\fi
 
 \begin{description}
 \cvarg{src}{Source array}
@@ -480,15 +506,33 @@ source and destination array types have equal types, this is also a
 special case that can be used to scale and shift a matrix or an image
 and that is caled \cvCPyCross{Scale}.
 
+
 \cvCPyFunc{ConvertScaleAbs}
 Converts input array elements to another 8-bit unsigned integer with optional linear transformation.
 
 \cvdefC{void cvConvertScaleAbs(const CvArr* src, CvArr* dst, double scale=1, double shift=0);}
 \cvdefPy{ConvertScaleAbs(src,dst,scale=1.0,shift=0.0)-> None}
 
-\begin{lstlisting}
-#define cvCvtScaleAbs cvConvertScaleAbs
-\end{lstlisting}
+\begin{description}
+\cvarg{src}{Source array}
+\cvarg{dst}{Destination array (should have 8u depth)}
+\cvarg{scale}{ScaleAbs factor}
+\cvarg{shift}{Value added to the scaled source array elements}
+\end{description}
+
+The function is similar to \cvCPyCross{ConvertScale}, but it stores absolute values of the conversion results:
+
+\[
+\texttt{dst}(I) = |\texttt{scale} \texttt{src}(I) + (\texttt{shift}_0,\texttt{shift}_1,...)|
+\]
+
+The function supports only destination arrays of 8u (8-bit unsigned integers) type; for other types the function can be emulated by a combination of \cvCPyCross{ConvertScale} and \cvCPyCross{Abs} functions.
+
+\cvCPyFunc{CvtScaleAbs}
+Converts input array elements to another 8-bit unsigned integer with optional linear transformation.
+
+\cvdefC{void cvCvtScaleAbs(const CvArr* src, CvArr* dst, double scale=1, double shift=0);}
+\cvdefPy{CvtScaleAbs(src,dst,scale=1.0,shift=0.0)-> None}
 
 \begin{description}
 \cvarg{src}{Source array}
@@ -498,6 +542,7 @@ Converts input array elements to another 8-bit unsigned integer with optional li
 \end{description}
 
 
+
 The function is similar to \cvCPyCross{ConvertScale}, but it stores absolute values of the conversion results:
 
 \[
@@ -577,12 +622,13 @@ Creates an image header and allocates the image data.
 \cvarg{channels}{Number of channels per pixel. See \cross{IplImage} for details. This function only creates images with interleaved channels.}
 \end{description}
 
+\ifC
 This call is a shortened form of
 \begin{lstlisting}
 header = cvCreateImageHeader(size, depth, channels);
 cvCreateData(header);
 \end{lstlisting}
-
+\fi
 
 \cvCPyFunc{CreateImageHeader}
 Creates an image header but does not allocate the image data.
@@ -596,6 +642,7 @@ Creates an image header but does not allocate the image data.
 \cvarg{channels}{Number of channels (see \cvCPyCross{CreateImage})}
 \end{description}
 
+\ifC
 This call is an analogue of
 \begin{lstlisting}
 hdr=iplCreateImageHeader(channels, 0, depth,
@@ -607,6 +654,7 @@ hdr=iplCreateImageHeader(channels, 0, depth,
                       0,0,0,0);
 \end{lstlisting}
 but it does not use IPL functions by default (see the \texttt{CV\_TURN\_ON\_IPL\_COMPATIBILITY} macro).
+\fi
 
 \cvCPyFunc{CreateMat}\label{cvCreateMat}
 Creates a matrix header and allocates the matrix data. 
@@ -620,12 +668,14 @@ Creates a matrix header and allocates the matrix data.
 \cvarg{type}{The type of the matrix elements in the form \texttt{CV\_<bit depth><S|U|F>C<number of channels>}, where S=signed, U=unsigned, F=float. For example, CV\_8UC1 means the elements are 8-bit unsigned and the there is 1 channel, and CV\_32SC2 means the elements are 32-bit signed and there are 2 channels.}
 \end{description}
 
+\ifC
 This is the concise form for:
 
 \begin{lstlisting}
 CvMat* mat = cvCreateMatHeader(rows, cols, type);
 cvCreateData(mat);
 \end{lstlisting}
+\fi
 
 \cvCPyFunc{CreateMatHeader}
 Creates a matrix header but does not allocate the matrix data.
@@ -659,10 +709,12 @@ Creates the header and allocates the data for a multi-dimensional dense array.
 
 This is a short form for:
 
+\ifC
 \begin{lstlisting}
 CvMatND* mat = cvCreateMatNDHeader(dims, sizes, type);
 cvCreateData(mat);
 \end{lstlisting}
+\fi
 
 \cvCPyFunc{CreateMatNDHeader}
 Creates a new matrix header but does not allocate the matrix data.
@@ -682,6 +734,7 @@ Creates a new matrix header but does not allocate the matrix data.
 
 The function allocates a header for a multi-dimensional dense array. The array data can further be allocated using \cvCPyCross{CreateData} or set explicitly to user-allocated data via \cvCPyCross{SetData}.
 
+\ifC % {
 \cvCPyFunc{CreateSparseMat}
 Creates sparse array.
 
@@ -699,7 +752,7 @@ Creates sparse array.
 \end{description}
 
 The function allocates a multi-dimensional sparse array. Initially the array contain no elements, that is \cvCPyCross{Get} or \cvCPyCross{GetReal} returns zero for every index.
-
+\fi % }
 
 \cvCPyFunc{CrossProduct}
 Calculates the cross product of two 3D vectors.
@@ -726,18 +779,16 @@ or:
 \end{array}
 \]
 
+\subsection{CvtPixToPlane}
+
+Synonym for \cross{Split}.
+
 \cvCPyFunc{DCT}
 Performs a forward or inverse Discrete Cosine transform of a 1D or 2D floating-point array.
 
 \cvdefC{void cvDCT(const CvArr* src, CvArr* dst, int flags);}
 \cvdefPy{DCT(src,dst,flags)-> None}
 
-\begin{lstlisting}
-#define CV_DXT_FORWARD  0
-#define CV_DXT_INVERSE  1
-#define CV_DXT_ROWS     4
-\end{lstlisting}
-
 \begin{description}
 \cvarg{src}{Source array, real 1D or 2D array}
 \cvarg{dst}{Destination array of the same size and same type as the source}
@@ -774,15 +825,6 @@ Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-
 \cvdefC{void cvDFT(const CvArr* src, CvArr* dst, int flags, int nonzeroRows=0);}
 \cvdefPy{DFT(src,dst,flags,nonzeroRows=0)-> None}
 
-\begin{lstlisting}
-#define CV_DXT_FORWARD  0
-#define CV_DXT_INVERSE  1
-#define CV_DXT_SCALE    2
-#define CV_DXT_ROWS     4
-#define CV_DXT_INV_SCALE (CV_DXT_SCALE|CV_DXT_INVERSE)
-#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE
-\end{lstlisting}
-
 \begin{description}
 \cvarg{src}{Source array, real or complex}
 \cvarg{dst}{Destination array of the same size and same type as the source}
@@ -792,6 +834,7 @@ Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-
 \cvarg{CV\_DXT\_INVERSE}{do an inverse 1D or 2D transform. The result is not scaled. \texttt{CV\_DXT\_FORWARD} and \texttt{CV\_DXT\_INVERSE} are mutually exclusive, of course.}
 \cvarg{CV\_DXT\_SCALE}{scale the result: divide it by the number of array elements. Usually, it is combined with \texttt{CV\_DXT\_INVERSE}, and one may use a shortcut \texttt{CV\_DXT\_INV\_SCALE}.}
 \cvarg{CV\_DXT\_ROWS}{do a forward or inverse transform of every individual row of the input matrix. This flag allows the user to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself), to do 3D and higher-dimensional transforms and so forth.}
+\cvarg{CV\_DXT\_INVERSE\_SCALE}{same as \texttt{CV\_DXT\_INVERSE + CV\_DXT\_SCALE}}
 \end{description}}
 \cvarg{nonzeroRows}{Number of nonzero rows in the source array
 (in the case of a forward 2d transform), or a number of rows of interest in
@@ -839,6 +882,7 @@ In the case of 1D real transform the result looks like the first row of the abov
 
 Here is the example of how to compute 2D convolution using DFT.
 
+\ifC
 \begin{lstlisting}
 CvMat* A = cvCreateMat(M1, N1, CVg32F);
 CvMat* B = cvCreateMat(M2, N2, A->type);
@@ -887,6 +931,7 @@ cvGetSubRect(dftgA, &tmp, cvRect(0,0,conv->cols,conv->rows));
 
 cvCopy(&tmp, conv);
 \end{lstlisting}
+\fi
 
 \ifC
 
@@ -973,7 +1018,7 @@ Computes eigenvalues and eigenvectors of a symmetric matrix.
 
 \cvdefC{
 void cvEigenVV(\par CvArr* mat,\par CvArr* evects,\par CvArr* evals,\par double eps=0,
-\par int lowindex = 0, \par int highindex = 0);}
+\par int lowindex = -1, \par int highindex = -1);}
 \cvdefPy{EigenVV(mat,evects,evals,eps,lowindex,highindex)-> None}
 
 \begin{description}
@@ -996,8 +1041,8 @@ mat*evects(i,:)' = evals(i)*evects(i,:)' (in MATLAB notation)
 \end{lstlisting}
 
 If either low- or highindex is supplied the other is required, too.
-Indexing is 1-based. Example: To calculate the largest eigenvector/-value set
-lowindex = highindex = 1.
+Indexing is 0-based. Example: To calculate the largest eigenvector/-value set
+\texttt{lowindex=highindex=0}. To calculate all the eigenvalues, leave \texttt{lowindex=highindex=-1}.
 For legacy reasons this function always returns a square matrix the same size
 as the source matrix with eigenvectors and a vector the length of the source
 matrix with eigenvalues. The selected eigenvectors/-values are always in the
@@ -1052,10 +1097,6 @@ Flip a 2D array around vertical, horizontal or both axes.
 \cvdefC{void  cvFlip(const CvArr* src, CvArr* dst=NULL, int flipMode=0);}
 \cvdefPy{Flip(src,dst=NULL,flipMode=0)-> None}
 
-\begin{lstlisting}
-#define cvMirror cvFlip
-\end{lstlisting}
-
 \begin{description}
 \cvarg{src}{Source array}
 \cvarg{dst}{Destination array.
@@ -1081,6 +1122,47 @@ The example scenarios of function use are:
   \item reversing the order of 1d point arrays (flipMode > 0)
 \end{itemize}
 
+\ifPy
+
+\cvCPyFunc{fromarray}
+
+Create a CvMat from an object that supports the array interface.
+
+\cvdefPy{fromarray(object, allowND = False) -> CvMat}
+
+\begin{description}
+\cvarg{object}{Any object that supports the array interface}
+\cvarg{allowND}{If true, will return a CvMatND}
+\end{description}
+
+If the object supports the
+\href{http://docs.scipy.org/doc/numpy/reference/arrays.interface.html}{array interface},
+return a \cross{CvMat} (\texttt{allowND = False}) or \cross{CvMatND} (\texttt{allowND = True}).
+
+If \texttt{allowND = False}, then the object's array must be either 2D or 3D.  If it is 2D, then the returned CvMat has a single channel.  If it is 3D, then the returned CvMat will have N channels, where N is the last dimension of the array. In this case, N cannot be greater than OpenCV's channel limit, \texttt{CV\_CN\_MAX}.
+
+If \texttt{allowND = True}, then \texttt{fromarray} returns a single-channel \cross{CvMatND} with the same shape as the original array.
+
+For example, \href{http://numpy.scipy.org/}{NumPy} arrays support the array interface, so can be converted to OpenCV objects:
+
+\begin{lstlisting}
+>>> import cv, numpy
+>>> a = numpy.ones((480, 640))
+>>> mat = cv.fromarray(a)
+>>> print cv.GetDims(mat), cv.CV_MAT_CN(cv.GetElemType(mat))
+(480, 640) 1
+>>> a = numpy.ones((480, 640, 3))
+>>> mat = cv.fromarray(a)
+>>> print cv.GetDims(mat), cv.CV_MAT_CN(cv.GetElemType(mat))
+(480, 640) 3
+>>> a = numpy.ones((480, 640, 3))
+>>> mat = cv.fromarray(a, allowND = True)
+>>> print cv.GetDims(mat), cv.CV_MAT_CN(cv.GetElemType(mat))
+(480, 640, 3) 1
+\end{lstlisting}
+
+\fi
+
 \cvCPyFunc{GEMM}
 Performs generalized matrix multiplication.
 
@@ -1143,7 +1225,7 @@ The functions return a specific array element. In the case of a sparse array the
 \cvCPyFunc{Get1D}
 Return a specific array element.
 
-\cvdefPy{ Get1D(arr, idx) -> scalar }
+\cvdefPy{Get1D(arr, idx) -> scalar}
 
 \begin{description}
 \cvarg{arr}{Input array}
@@ -1383,15 +1465,15 @@ If there is no ROI set, \texttt{cvRect(0,0,image->width,image->height)} is retur
 Returns matrix header for arbitrary array.
 
 \cvdefC{CvMat* cvGetMat(const CvArr* arr, CvMat* header, int* coi=NULL, int allowND=0);}
-\cvdefPy{GetMat(arr) -> cvmat }
+\cvdefPy{GetMat(arr, allowND=0) -> cvmat }
 
 \begin{description}
 \cvarg{arr}{Input array}
 \ifC
 \cvarg{header}{Pointer to \cross{CvMat} structure used as a temporary buffer}
 \cvarg{coi}{Optional output parameter for storing COI}
-\cvarg{allowND}{If non-zero, the function accepts multi-dimensional dense arrays (CvMatND*) and returns 2D (if CvMatND has two dimensions) or 1D matrix (when CvMatND has 1 dimension or more than 2 dimensions). The array must be continuous.}
 \fi
+\cvarg{allowND}{If non-zero, the function accepts multi-dimensional dense arrays (CvMatND*) and returns 2D (if CvMatND has two dimensions) or 1D matrix (when CvMatND has 1 dimension or more than 2 dimensions). The array must be continuous.}
 \end{description}
 
 The function returns a matrix header for the input array that can be a matrix - 
@@ -1500,12 +1582,12 @@ for(y = 0; y < size.height; y++, data += step )
 \cvCPyFunc{GetReal?D}
 Return a specific element of single-channel array.
 
-\begin{lstlisting}
-double cvGetReal1D(const CvArr* arr, int idx0);
-double cvGetReal2D(const CvArr* arr, int idx0, int idx1);
-double cvGetReal3D(const CvArr* arr, int idx0, int idx1, int idx2);
+\cvdefC{
+double cvGetReal1D(const CvArr* arr, int idx0); \newline
+double cvGetReal2D(const CvArr* arr, int idx0, int idx1); \newline
+double cvGetReal3D(const CvArr* arr, int idx0, int idx1, int idx2); \newline
 double cvGetRealND(const CvArr* arr, int* idx);
-\end{lstlisting}
+}
 
 \begin{description}
 \cvarg{arr}{Input array. Must have a single channel.}
@@ -1789,14 +1871,15 @@ Calculates the inverse square root.
 
 The function calculates the inverse square root of the argument, and normally it is faster than \texttt{1./sqrt(value)}. If the argument is zero or negative, the result is not determined. Special values ($\pm \infty $ , NaN) are not handled.
 
+\cvCPyFunc{Inv}
+
+Synonym for \cross{Invert}
+
 \cvCPyFunc{Invert}
 Finds the inverse or pseudo-inverse of a matrix.
 
 \cvdefC{double cvInvert(const CvArr* src, CvArr* dst, int method=CV\_LU);}
 \cvdefPy{Invert(src,dst,method=CV\_LU)-> double}
-\begin{lstlisting}
-#define cvInv cvInvert
-\end{lstlisting}
 
 \begin{description}
 \cvarg{src}{The source matrix}
@@ -2064,6 +2147,9 @@ The function calculates minimum of an array and a scalar:
 All the arrays must have a single channel, the same data type and the same size (or ROI size).
 
 
+\subsection{Mirror}
+Synonym for \cross{Flip}.
+
 \cvCPyFunc{MixChannels}
 Copies several channels from input arrays to certain channels of output arrays
 
@@ -2128,6 +2214,10 @@ BGR (i.e. with R and B swapped) and separate alpha channel image:
 \end{lstlisting}
 \fi
 
+\subsection{MulAddS}
+
+Synonym for \cross{ScaleAdd}.
+
 \cvCPyFunc{Mul}
 Calculates the per-element product of two arrays.
 
@@ -2287,10 +2377,10 @@ In the case of floating-point arrays their bit representations are used for the
 Calculates a per-element bit-wise disjunction of an array and a scalar.
 
 \cvdefC{void cvOrS(const CvArr* src, CvScalar value, CvArr* dst, const CvArr* mask=NULL);}
-\cvdefPy{OrS(src1,value,dst,mask=NULL)-> None}
+\cvdefPy{OrS(src,value,dst,mask=NULL)-> None}
 
 \begin{description}
-\cvarg{src1}{The source array}
+\cvarg{src}{The source array}
 \cvarg{value}{Scalar to use in the operation}
 \cvarg{dst}{The destination array}
 \cvarg{mask}{Operation mask, 8-bit single channel array; specifies elements of the destination array to be changed}
@@ -2378,14 +2468,26 @@ The function raises every element of the input array to \texttt{p}:
 
 That is, for a non-integer power exponent the absolute values of input array elements are used. However, it is possible to get true values for negative values using some extra operations, as the following example, computing the cube root of array elements, shows:
 
+\ifC
 \begin{lstlisting}
 CvSize size = cvGetSize(src);
-CvMat* mask = cvCreateMat(size.height, size.width, CVg8UC1);
-cvCmpS(src, 0, mask, CVgCMPgLT); /* find negative elements */
+CvMat* mask = cvCreateMat(size.height, size.width, CV_8UC1);
+cvCmpS(src, 0, mask, CV_CMP_LT); /* find negative elements */
 cvPow(src, dst, 1./3);
 cvSubRS(dst, cvScalarAll(0), dst, mask); /* negate the results of negative inputs */
 cvReleaseMat(&mask);
 \end{lstlisting}
+\else
+\begin{lstlisting}
+>>> import cv
+>>> src = cv.CreateMat(1, 10, cv.CV_32FC1)
+>>> mask = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
+>>> dst = cv.CreateMat(src.rows, src.cols, cv.CV_32FC1)
+>>> cv.CmpS(src, 0, mask, cv.CV_CMP_LT)         # find negative elements
+>>> cv.Pow(src, dst, 1. / 3)
+>>> cv.SubRS(dst, cv.ScalarAll(0), dst, mask)   # negate the results of negative inputs
+\end{lstlisting}
+\fi
 
 For some values of \texttt{power}, such as integer values, 0.5, and -0.5, specialized faster algorithms are used.
 
@@ -2393,12 +2495,12 @@ For some values of \texttt{power}, such as integer values, 0.5, and -0.5, specia
 \cvCPyFunc{Ptr?D}
 Return pointer to a particular array element.
 
-\begin{lstlisting}
-uchar* cvPtr1D(const CvArr* arr, int idx0, int* type=NULL);
-uchar* cvPtr2D(const CvArr* arr, int idx0, int idx1, int* type=NULL);
-uchar* cvPtr3D(const CvArr* arr, int idx0, int idx1, int idx2, int* type=NULL);
+\cvdefC{
+uchar* cvPtr1D(const CvArr* arr, int idx0, int* type=NULL); \newline
+uchar* cvPtr2D(const CvArr* arr, int idx0, int idx1, int* type=NULL); \newline
+uchar* cvPtr3D(const CvArr* arr, int idx0, int idx1, int idx2, int* type=NULL); \newline
 uchar* cvPtrND(const CvArr* arr, int* idx, int* type=NULL, int createNode=1, unsigned* precalcHashval=NULL);
-\end{lstlisting}
+}
 
 \begin{description}
 \cvarg{arr}{Input array}
@@ -2723,12 +2825,21 @@ Resets the image ROI to include the entire image and releases the ROI structure.
 \cvarg{image}{A pointer to the image header}
 \end{description}
 
-This produces a similar result to the following, but in addition it releases the ROI structure.
+This produces a similar result to the following
+\ifC
+, but in addition it releases the ROI structure.
 
 \begin{lstlisting}
 cvSetImageROI(image, cvRect(0, 0, image->width, image->height ));
 cvSetImageCOI(image, 0);
 \end{lstlisting}
+\else
+
+\begin{lstlisting}
+cv.SetImageROI(image, (0, 0, image.width, image.height))
+cv.SetImageCOI(image, 0)
+\end{lstlisting}
+\fi
 
 
 \cvCPyFunc{Reshape}
@@ -2794,13 +2905,15 @@ Changes the shape of a multi-dimensional array without copying the data.
 \cvarg{newSizes}{Array of new dimension sizes. Only $\texttt{newDims}-1$ values are used, because the total number of elements must remain the same.
 Thus, if $\texttt{newDims} = 1$, \texttt{newSizes} array is not used.}
 \else
+\cvarg{newCn}{New number of channels. $\texttt{newCn} = 0$ means that the number of channels remains unchanged.}
 \cvarg{newDims}{List of new dimensions.}
 \fi
 \end{description}
 
-The function is an advanced version of \cvCPyCross{Reshape} that can work with multi-dimensional arrays as well (though it can work with ordinary images and matrices) and change the number of dimensions.
 
 \ifC
+The function is an advanced version of \cvCPyCross{Reshape} that can work with multi-dimensional arrays as well (though it can work with ordinary images and matrices) and change the number of dimensions.
+
 Below are the two samples from the \cvCPyCross{Reshape} description rewritten using \cvCPyCross{ReshapeMatND}:
 
 \begin{lstlisting}
@@ -2820,6 +2933,24 @@ row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0);
 \end{lstlisting}
 \fi
 
+\ifPy
+Returns a new \cross{CvMatND} that shares the same data as \texttt{arr}
+but has different dimensions or number of channels.  The only requirement
+is that the total length of the data is unchanged.
+
+\begin{lstlisting}
+>>> import cv
+>>> mat = cv.CreateMatND([24], cv.CV_32FC1)
+>>> print cv.GetDims(cv.ReshapeMatND(mat, 0, [8, 3]))
+(8, 3)
+>>> m2 = cv.ReshapeMatND(mat, 4, [3, 2])
+>>> print cv.GetDims(m2)
+(3, 2)
+>>> print m2.channels
+4
+\end{lstlisting}
+\fi
+
 \ifC
 \cvfunc{cvRound, cvFloor, cvCeil}\label{cvRound}
 
@@ -2849,7 +2980,7 @@ are not handled.
 
 \else
 
-\cvfunc{Round}
+\cvCPyFunc{Round}
 
 Converts a floating-point number to the nearest integer value.
 
@@ -2864,7 +2995,7 @@ operations. If the absolute value of the argument is greater than
 $2^{31}$, the result is not determined. Special values ($\pm \infty$ , NaN)
 are not handled.
 
-\cvfunc{Floor}
+\cvCPyFunc{Floor}
 
 Converts a floating-point number to the nearest integer value that is not larger than the argument.
 
@@ -2879,7 +3010,7 @@ operations. If the absolute value of the argument is greater than
 $2^{31}$, the result is not determined. Special values ($\pm \infty$ , NaN)
 are not handled.
 
-\cvfunc{Ceil}
+\cvCPyFunc{Ceil}
 
 Converts a floating-point number to the nearest integer value that is not smaller than the argument.
 
@@ -2910,10 +3041,6 @@ Calculates the sum of a scaled array and another array.
 \cvarg{dst}{The destination array}
 \end{description}
 
-\begin{lstlisting}
-#define cvMulAddS cvScaleAdd
-\end{lstlisting}
-
 The function calculates the sum of a scaled array and another array:
 
 \[
@@ -2947,12 +3074,12 @@ If array \texttt{arr} is of \texttt{IplImage} type, then is ROI used, but COI mu
 \cvCPyFunc{Set?D}
 Change the particular array element.
 
-\begin{lstlisting}
-void cvSet1D(CvArr* arr, int idx0, CvScalar value);
-void cvSet2D(CvArr* arr, int idx0, int idx1, CvScalar value);
-void cvSet3D(CvArr* arr, int idx0, int idx1, int idx2, CvScalar value);
+\cvdefC{
+void cvSet1D(CvArr* arr, int idx0, CvScalar value); \newline
+void cvSet2D(CvArr* arr, int idx0, int idx1, CvScalar value); \newline
+void cvSet3D(CvArr* arr, int idx0, int idx1, int idx2, CvScalar value); \newline
 void cvSetND(CvArr* arr, int* idx, CvScalar value);
-\end{lstlisting}
+}
 
 \begin{description}
 \cvarg{arr}{Input array}
@@ -3087,16 +3214,16 @@ If the original image ROI was \texttt{NULL} and the \texttt{rect} is not the who
 
 Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the ROI, not the original image.
 
-\if % {
+\ifC % {
 \cvCPyFunc{SetReal?D}
 Change a specific array element.
 
-\begin{lstlisting}
-void cvSetReal1D(CvArr* arr, int idx0, double value);
-void cvSetReal2D(CvArr* arr, int idx0, int idx1, double value);
-void cvSetReal3D(CvArr* arr, int idx0, int idx1, int idx2, double value);
+\cvdefC{
+void cvSetReal1D(CvArr* arr, int idx0, double value); \newline
+void cvSetReal2D(CvArr* arr, int idx0, int idx1, double value); \newline
+void cvSetReal3D(CvArr* arr, int idx0, int idx1, int idx2, double value); \newline
 void cvSetRealND(CvArr* arr, int* idx, double value);
-\end{lstlisting}
+}
 
 \begin{description}
 \cvarg{arr}{Input array}
@@ -3254,10 +3381,6 @@ Divides multi-channel array into several single-channel arrays or extracts a sin
               CvArr* dst2, CvArr* dst3);}
 \cvdefPy{Split(src,dst0,dst1,dst2,dst3)-> None}
 
-\begin{lstlisting}
-#define cvCvtPixToPlane cvSplit
-\end{lstlisting}
-
 \begin{description}
 \cvarg{src}{Source array}
 \cvarg{dst0}{Destination channel 0}
@@ -3516,10 +3639,6 @@ Transposes a matrix.
 \cvdefC{void cvTranspose(const CvArr* src, CvArr* dst);}
 \cvdefPy{Transpose(src,dst)-> None}
 
-\begin{lstlisting}
-#define cvT cvTranspose
-\end{lstlisting}
-
 \begin{description}
 \cvarg{src}{The source matrix}
 \cvarg{dst}{The destination matrix}
@@ -3576,6 +3695,7 @@ dst(I)=src(I)^value if mask(I)!=0
 
 Prior to the actual operation, the scalar is converted to the same type as that of the array(s). In the case of floating-point arrays their bit representations are used for the operation. All the arrays must have the same type, except the mask, and the same size
 
+\ifC
 The following sample demonstrates how to conjugate complex vector by switching the most-significant bit of imaging part:
 
 \begin{lstlisting}
@@ -3585,7 +3705,7 @@ CvMat A = cvMat(4, 1, CV\_32FC2, &a);
 int i, negMask = 0x80000000;
 cvXorS(&A, cvScalar(0, *(float*)&negMask, 0, 0 ), &A, 0);
 for(i = 0; i < 4; i++ )
-    printf("(%.1f, %.1f) ", a[i*2], a[i*2+1]);
+    printf("(\%.1f, \%.1f) ", a[i*2], a[i*2+1]);
 
 \end{lstlisting}
 
@@ -3594,6 +3714,7 @@ The code should print:
 \begin{lstlisting}
 (1.0,0.0) (0.0,-1.0) (-1.0,0.0) (0.0,1.0)
 \end{lstlisting}
+\fi
 
 \cvCPyFunc{mGet}
 Returns the particular element of single-channel floating-point matrix.
@@ -3762,7 +3883,7 @@ In the case of multi-channel arrays each channel is processed independently.
 See also: \cvCppCross{add}, \cvCppCross{subtract}, \cvCppCross{scaleAdd}, \cvCppCross{convertScale},
 \cross{Matrix Expressions}, \hyperref[cppfunc.saturatecast]{saturate\_cast}.
 
-\subsection{cv::bitwise\_and}\label{cppfunc.bitwise.and}
+\cvfunc{bitwise\_and}\label{cppfunc.bitwise.and}
 Calculates per-element bit-wise conjunction of two arrays and an array and a scalar.
 
 \cvdefCpp{void bitwise\_and(const Mat\& src1, const Mat\& src2,\par Mat\& dst, const Mat\& mask=Mat());\newline
@@ -3791,7 +3912,7 @@ In the case of floating-point arrays their machine-specific bit representations
 
 See also: \hyperref[cppfunc.bitwise.and]{bitwise\_and}, \hyperref[cppfunc.bitwise.not]{bitwise\_not}, \hyperref[cppfunc.bitwise.xor]{bitwise\_xor}
 
-\subsection{cv::bitwise\_not}\label{cppfunc.bitwise.not}
+\cvfunc{bitwise\_not}\label{cppfunc.bitwise.not}
 Inverts every bit of array
 
 \cvdefCpp{void bitwise\_not(const Mat\& src, Mat\& dst);\newline
@@ -3812,7 +3933,7 @@ In the case of floating-point source array its machine-specific bit representati
 See also: \hyperref[cppfunc.bitwise.and]{bitwise\_and}, \hyperref[cppfunc.bitwise.or]{bitwise\_or}, \hyperref[cppfunc.bitwise.xor]{bitwise\_xor}
 
 
-\subsection{cv::bitwise\_or}\label{cppfunc.bitwise.or}
+\cvfunc{bitwise\_or}\label{cppfunc.bitwise.or}
 Calculates per-element bit-wise disjunction of two arrays and an array and a scalar.
 
 \cvdefCpp{void bitwise\_or(const Mat\& src1, const Mat\& src2,\par Mat\& dst, const Mat\& mask=Mat());\newline
@@ -3841,7 +3962,7 @@ In the case of floating-point arrays their machine-specific bit representations
 
 See also: \hyperref[cppfunc.bitwise.and]{bitwise\_and}, \hyperref[cppfunc.bitwise.not]{bitwise\_not}, \hyperref[cppfunc.bitwise.or]{bitwise\_or}
 
-\subsection{cv::bitwise\_xor}\label{cppfunc.bitwise.xor}
+\cvfunc{bitwise\_xor}\label{cppfunc.bitwise.xor}
 Calculates per-element bit-wise "exclusive or" operation on two arrays and an array and a scalar.
 
 \cvdefCpp{void bitwise\_xor(const Mat\& src1, const Mat\& src2,\par Mat\& dst, const Mat\& mask=Mat());\newline
@@ -4057,7 +4178,7 @@ Counts non-zero array elements.
 \cvdefCpp{int countNonZero( const Mat\& mtx );\newline
 int countNonZero( const MatND\& mtx );}
 \begin{description}
-\cvarg{mtx}Single-channel array
+\cvarg{mtx}{Single-channel array}
 \end{description}
 
 The function \texttt{cvCountNonZero} returns the number of non-zero elements in mtx:
@@ -4071,7 +4192,7 @@ Computes cube root of the argument
 
 \cvdefCpp{float cubeRoot(float val);}
 \begin{description}
-\cvarg{val}The function argument
+\cvarg{val}{The function argument}
 \end{description}
 
 The function \texttt{cubeRoot} computes $\sqrt[3]{\texttt{val}}$.
@@ -4130,7 +4251,7 @@ Performs a forward or inverse discrete cosine transform of 1D or 2D array
 \begin{description}
 \cvarg{src}{The source floating-point array}
 \cvarg{dst}{The destination array; will have the same size and same type as \texttt{src}}
-\cvarg{flags}\cvarg{flags}{Transformation flags, a combination of the following values
+\cvarg{flags}{Transformation flags, a combination of the following values
 \begin{description}
 \cvarg{DCT\_INVERSE}{do an inverse 1D or 2D transform instead of the default forward transform.}
 \cvarg{DCT\_ROWS}{do a forward or inverse transform of every individual row of the input matrix. This flag allows user to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself), to do 3D and higher-dimensional transforms and so forth.}
@@ -5103,7 +5224,7 @@ in the case of sparse matrices, only the non-zero values are analyzed and transf
 See also: \cvCppCross{norm}, \cvCppCross{Mat::convertScale}, \cvCppCross{MatND::convertScale}, \cvCppCross{SparseMat::convertScale}
 
 
-\cvCppFunc{PCA}
+\cvclass{PCA}
 Class for Principal Component Analysis
 
 \begin{lstlisting}
@@ -5111,22 +5232,22 @@ class PCA
 {
 public:
     // default constructor
-    PCA();newline
+    PCA();
     // computes PCA for a set of vectors stored as data rows or columns.
-    PCA(const Mat& data, const Mat& mean, int flags, int maxComponents=0);newline
+    PCA(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
     // computes PCA for a set of vectors stored as data rows or columns
-    PCA& operator()(const Mat& data, const Mat& mean, int flags, int maxComponents=0);newline
+    PCA& operator()(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
     // projects vector into the principal components space
-    Mat project(const Mat& vec) const;newline
-    void project(const Mat& vec, Mat& result) const;newline
+    Mat project(const Mat& vec) const;
+    void project(const Mat& vec, Mat& result) const;
     // reconstructs the vector from its PC projection
-    Mat backProject(const Mat& vec) const;newline
-    void backProject(const Mat& vec, Mat& result) const;newline
+    Mat backProject(const Mat& vec) const;
+    void backProject(const Mat& vec, Mat& result) const;
 
     // eigenvectors of the PC space, stored as the matrix rows
-    Mat eigenvectors;newline
+    Mat eigenvectors;
     // the corresponding eigenvalues; not used for PCA compression/decompression
-    Mat eigenvalues;newline
+    Mat eigenvalues;
     // mean vector, subtracted from the projected vector
     // or added to the reconstructed vector
     Mat mean;
@@ -5174,6 +5295,75 @@ PCA compressPCA(const Mat& pcaset, int maxComponents,
 
 See also: \cvCppCross{calcCovarMatrix}, \cvCppCross{mulTransposed}, \cvCppCross{SVD}, \cvCppCross{dft}, \cvCppCross{dct}
 
+\cvCppFunc{PCA::PCA}
+PCA constructors
+
+\cvdefCpp{
+PCA::PCA();\newline
+PCA::PCA(const Mat\& data, const Mat\& mean, int flags, int maxComponents=0);
+}
+\begin{description}
+\cvarg{data}{the input samples, stored as the matrix rows or as the matrix columns}
+\cvarg{mean}{the optional mean value. If the matrix is empty (\texttt{Mat()}), the mean is computed from the data.}
+\cvarg{flags}{operation flags. Currently the parameter is only used to specify the data layout.}
+\begin{description}
+    \cvarg{CV\_PCA\_DATA\_AS\_ROWS}{Indicates that the input samples are stored as matrix rows.}
+    \cvarg{CV\_PCA\_DATA\_AS\_COLS}{Indicates that the input samples are stored as matrix columns.}
+\end{description}
+\cvarg{maxComponents}{The maximum number of components that PCA should retain. By default, all the components are retained.}
+\end{description}
+
+The default constructor initializes empty PCA structure. The second constructor initializes the structure and calls \cvCppCross{PCA::operator ()}.
+
+\cvCppFunc{PCA::operator ()}
+Performs Principal Component Analysis of the supplied dataset. 
+
+\cvdefCpp{
+PCA\& PCA::operator()(const Mat\& data, const Mat\& mean, int flags, int maxComponents=0);
+}
+\begin{description}
+\cvarg{data}{the input samples, stored as the matrix rows or as the matrix columns}
+\cvarg{mean}{the optional mean value. If the matrix is empty (\texttt{Mat()}), the mean is computed from the data.}
+\cvarg{flags}{operation flags. Currently the parameter is only used to specify the data layout.}
+\begin{description}
+    \cvarg{CV\_PCA\_DATA\_AS\_ROWS}{Indicates that the input samples are stored as matrix rows.}
+    \cvarg{CV\_PCA\_DATA\_AS\_COLS}{Indicates that the input samples are stored as matrix columns.}
+\end{description}
+\cvarg{maxComponents}{The maximum number of components that PCA should retain. By default, all the components are retained.}
+\end{description}
+
+The operator performs PCA of the supplied dataset. It is safe to reuse the same PCA structure for multiple dataset. That is, if the  structure has been previously used with another dataset, the existing internal data is reclaimed and the new \texttt{eigenvalues}, \texttt{eigenvectors} and \texttt{mean} are allocated and computed.
+
+The computed eigenvalues are sorted from the largest to the smallest and the corresponding eigenvectors are stored as \texttt{PCA::eigenvectors} rows. 
+
+\cvCppFunc{PCA::project}
+Project vector(s) to the principal component subspace
+
+\cvdefCpp{
+Mat PCA::project(const Mat\& vec) const;\newline
+void PCA::project(const Mat\& vec, Mat\& result) const;
+}
+\begin{description}
+\cvarg{vec}{the input vector(s). They have to have the same dimensionality and the same layout as the input data used at PCA phase. That is, if \texttt{CV\_PCA\_DATA\_AS\_ROWS} had been specified, then \texttt{vec.cols==data.cols} (that's vectors' dimensionality) and \texttt{vec.rows} is the number of vectors to project; and similarly for the \texttt{CV\_PCA\_DATA\_AS\_COLS} case.}
+\cvarg{result}{the output vectors. Let's now consider \texttt{CV\_PCA\_DATA\_AS\_COLS} case. In this case the output matrix will have as many columns as the number of input vectors, i.e. \texttt{result.cols==vec.cols} and the number of rows will match the number of principal components (e.g. \texttt{maxComponents} parameter passed to the constructor).}
+\end{description}
+
+The methods project one or more vectors to the principal component subspace, where each vector projection is represented by coefficients in the principal component basis. The first form of the method returns the matrix that the second form writes to the result. So the first form can be used as a part of expression, while the second form can be more efficient in a processing loop. 
+
+\cvCppFunc{PCA::backProject}
+Reconstruct vectors from their PC projections.
+
+\cvdefCpp{
+Mat PCA::backProject(const Mat\& vec) const;\newline
+void PCA::backProject(const Mat\& vec, Mat\& result) const;
+}
+\begin{description}
+\cvarg{vec}{Coordinates of the vectors in the principal component subspace. The layout and size are the same as of \texttt{PCA::project} output vectors.}
+\cvarg{result}{The reconstructed vectors. The layout and size are the same as of \texttt{PCA::project} input vectors.}
+\end{description}
+
+The methods are inverse operations to \cvCppCross{PCA::project}. They take PC coordinates of projected vectors and reconstruct the original vectors. Of course, unless all the principal components have been retained, the reconstructed vectors will be different from the originals, but typically the difference will be small is if the number of components is large enough (but still much smaller than the original vector dimensionality) - that's why PCA is used after all. 
+
 \cvCppFunc{perspectiveTransform}
 Performs perspective matrix transformation of vectors.
 
@@ -5281,6 +5471,174 @@ For some values of \texttt{p}, such as integer values, 0.5, and -0.5, specialize
 
 See also: \cvCppCross{sqrt}, \cvCppCross{exp}, \cvCppCross{log}, \cvCppCross{cartToPolar}, \cvCppCross{polarToCart}
 
+
+\subsection{RNG}\label{RNG}
+
+Random number generator class.
+
+\begin{lstlisting}
+class CV_EXPORTS RNG
+{
+public:
+    enum { A=4164903690U, UNIFORM=0, NORMAL=1 };
+
+    // constructors
+    RNG();
+    RNG(uint64 state);
+    
+    // returns 32-bit unsigned random number
+    unsigned next();
+
+    // return random numbers of the specified type
+    operator uchar();
+    operator schar();
+    operator ushort();
+    operator short();
+    operator unsigned();
+       // returns a random integer sampled uniformly from [0, N).
+       unsigned operator()(unsigned N);
+       unsigned operator()();
+    operator int();
+    operator float();
+    operator double();
+    // returns a random number sampled uniformly from [a, b) range
+    int uniform(int a, int b);
+    float uniform(float a, float b);
+    double uniform(double a, double b);
+    
+    // returns Gaussian random number with zero mean.
+       double gaussian(double sigma);
+    
+    // fills array with random numbers sampled from the specified distribution
+    void fill( Mat& mat, int distType, const Scalar& a, const Scalar& b );
+    void fill( MatND& mat, int distType, const Scalar& a, const Scalar& b );
+
+    // internal state of the RNG (could change in the future)
+    uint64 state;
+};
+\end{lstlisting}
+
+The class \texttt{RNG} implements random number generator. It encapsulates the RNG state (currently, a 64-bit integer) and  has methods to return scalar random values and to fill arrays with random values. Currently it supports uniform and Gaussian (normal) distributions. The generator uses Multiply-With-Carry algorithm, introduced by G. Marsaglia (\url{http://en.wikipedia.org/wiki/Multiply-with-carry}). Gaussian-distribution random numbers are generated using Ziggurat algorithm (\url{http://en.wikipedia.org/wiki/Ziggurat_algorithm}), introduced by G. Marsaglia and W. W. Tsang. 
+
+\cvCppFunc{RNG::RNG}
+RNG constructors
+
+\cvdefCpp{
+RNG::RNG();\newline
+RNG::RNG(uint64 state);
+}
+\begin{description}
+\cvarg{state}{the 64-bit value used to initialize the RNG}
+\end{description}
+
+These are the RNG constructors. The first form sets the state to some pre-defined value, equal to \texttt{2**32-1} in the current implementation. The second form sets the state to the specified value. If the user passed \texttt{state=0}, the constructor uses the above default value instead, to avoid the singular random number sequence, consisting of all zeros.
+
+\cvCppFunc{RNG::next}
+Returns the next random number
+
+\cvdefCpp{
+unsigned RNG::next();
+}
+
+The method updates the state using MWC algorithm and returns the next 32-bit random number.
+
+
+\cvCppFunc{RNG::operator T}
+Returns the next random number of the specified type
+
+\cvdefCpp{
+RNG::operator uchar();
+RNG::operator schar();
+RNG::operator ushort();
+RNG::operator short();
+RNG::operator unsigned();
+RNG::operator int();
+RNG::operator float();
+RNG::operator double();
+}
+
+Each of the methods updates the state using MWC algorithm and returns the next random number of the specified type. In the case of integer types the returned number is from the whole available value range for the specified type. In the case of floating-point types the returned value is from \texttt{[0,1)} range.
+
+\cvCppFunc{RNG::operator ()}
+Returns the next random number
+
+\cvdefCpp{
+unsigned RNG::operator ()();\newline
+unsigned RNG::operator ()(unsigned N);
+}
+\begin{description}
+\cvarg{N}{The upper non-inclusive boundary of the returned random number}
+\end{description}
+
+The methods transforms the state using MWC algorithm and returns the next random number. The first form is equivalent to \cvCppCross{RNG::next}, the second form returns the random number modulo \texttt{N}, i.e. the result will be in the range \texttt{[0, N)}.
+
+\cvCppFunc{RNG::uniform}
+Returns the next random number sampled from the uniform distribution
+
+\cvdefCpp{
+int RNG::uniform(int a, int b);\newline
+float RNG::uniform(float a, float b);\newline
+double RNG::uniform(double a, double b);
+}
+\begin{description}
+\cvarg{a}{The lower inclusive boundary of the returned random numbers}
+\cvarg{b}{The upper non-inclusive boundary of the returned random numbers}
+\end{description}
+
+The methods transforms the state using MWC algorithm and returns the next uniformly-distributed random number of the specified type, deduced from the input parameter type, from the range \texttt{[a, b)}. There is one nuance, illustrated by the following sample:
+
+\begin{lstlisting}
+cv::RNG rng;
+
+// will always produce 0
+double a = rng.uniform(0, 1);
+
+// will produce double from [0, 1)
+double a1 = rng.uniform((double)0, (double)1);
+
+// will produce float from [0, 1)
+double b = rng.uniform(0.f, 1.f);
+
+// will produce double from [0, 1)
+double c = rng.uniform(0., 1.);
+
+// will likely cause compiler error because of ambiguity:
+//  RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)?
+double d = rng.uniform(0, 0.999999);
+\end{lstlisting}
+
+That is, the compiler does not take into account type of the variable that you assign the result of \texttt{RNG::uniform} to, the only thing that matters to it is the type of \texttt{a} and \texttt{b} parameters. So if you want a floating-point random number, but the range boundaries are integer numbers, either put dots in the end, if they are constants, or use explicit type cast operators, as in \texttt{a1} initialization above.
+
+
+\cvCppFunc{RNG::gaussian}
+Returns the next random number sampled from the Gaussian distribution
+
+\cvdefCpp{
+double RNG::gaussian(double sigma);
+}
+\begin{description}
+\cvarg{sigma}{The standard deviation of the distribution}
+\end{description}
+
+The methods transforms the state using MWC algorithm and returns the next random number from the Gaussian distribution \texttt{N(0,sigma)}. That is, the mean value of the returned random numbers will be zero and the standard deviation will be the specified \texttt{sigma}.
+
+
+\cvCppFunc{RNG::fill}
+Fill arrays with random numbers 
+
+\cvdefCpp{
+void RNG::fill( Mat\& mat, int distType, const Scalar\& a, const Scalar\& b );\newline
+void RNG::fill( MatND\& mat, int distType, const Scalar\& a, const Scalar\& b );
+}
+\begin{description}
+\cvarg{mat}{2D or N-dimensional matrix. Currently matrices with more than 4 channels are not supported by the methods. Use \cvCppCross{reshape} as a possible workaround.}
+\cvarg{distType}{The distribution type, \texttt{RNG::UNIFORM} or \texttt{RNG::NORMAL}}
+\cvarg{a}{The first distribution parameter. In the case of uniform distribution this is inclusive lower boundary. In the case of normal distribution this is mean value.}
+\cvarg{b}{The second distribution parameter. In the case of uniform distribution this is non-inclusive upper boundary. In the case of normal distribution this is standard deviation.}
+\end{description}
+
+Each of the methods fills the matrix with the random values from the specified distribution. As the new numbers are generated, the RNG state is updated accordingly. In the case of multiple-channel images every channel is filled independently, i.e. RNG can not generate samples from multi-dimensional Gaussian distribution with non-diagonal covariation matrix directly. To do that, first, generate matrix from the distribution $N(0, I_n)$, i.e. Gaussian distribution with zero mean and identity covariation matrix, and then transform it using \cvCppCross{transform} and the specific covariation matrix.  
+
 \cvCppFunc{randu}
 Generates a single uniformly-distributed random number or array of random numbers
 
@@ -5371,9 +5729,9 @@ The second variant of the function is more convenient to use with \cross{Matrix
 See also: \cvCppCross{reduce}, \cross{Matrix Expressions}
 
 \ifplastex
-\subsection{saturate\_cast}\label{cppfunc.saturatecast}
+\cvfunc{saturate\_cast}\label{cppfunc.saturatecast}
 \else
-\subsection{cv::saturate\_cast}\label{cppfunc.saturatecast}
+\subsection{saturate\_cast}\label{cppfunc.saturatecast}
 \fi
 Template function for accurate conversion from one primitive type to another
 
@@ -5653,28 +6011,28 @@ dst -= src2; // equivalent to subtract(dst, src2, dst);
 See also: \cvCppCross{add}, \cvCppCross{addWeighted}, \cvCppCross{scaleAdd}, \cvCppCross{convertScale},
 \cross{Matrix Expressions}, \hyperref[cppfunc.saturatecast]{saturate\_cast}.
 
-\cvCppFunc{SVD}
+\cvclass{SVD}
 Class for computing Singular Value Decomposition
 
 \begin{lstlisting}
 class SVD
 {
 public:
-    enum { MODIFY_A=1, NO_UV=2, FULL_UV=4 };newline
+    enum { MODIFY_A=1, NO_UV=2, FULL_UV=4 };
     // default empty constructor
-    SVD();newline
-    // decomposes m into u, w and vt: m = u*w*vt;newline
+    SVD();
+    // decomposes A into u, w and vt: A = u*w*vt;
     // u and vt are orthogonal, w is diagonal
-    SVD( const Mat& m, int flags=0 );newline
-    // decomposes m into u, w and vt.
-    SVD& operator ()( const Mat& m, int flags=0 );newline
+    SVD( const Mat& A, int flags=0 );
+    // decomposes A into u, w and vt.
+    SVD& operator ()( const Mat& A, int flags=0 );
 
-    // finds such vector x, norm(x)=1, so that m*x = 0,
-    // where m is singular matrix
-    static void solveZ( const Mat& m, Mat& dst );newline
+    // finds such vector x, norm(x)=1, so that A*x = 0,
+    // where A is singular matrix
+    static void solveZ( const Mat& A, Mat& x );
     // does back-subsitution:
-    // dst = vt.t()*inv(w)*u.t()*rhs ~ inv(m)*rhs
-    void backSubst( const Mat& rhs, Mat& dst ) const;newline
+    // x = vt.t()*inv(w)*u.t()*rhs ~ inv(A)*rhs
+    void backSubst( const Mat& rhs, Mat& x ) const;
 
     Mat u, w, vt;
 };
@@ -5685,6 +6043,80 @@ For a bit faster operation you can pass \texttt{flags=SVD::MODIFY\_A|...} to mod
 
 See also: \cvCppCross{invert}, \cvCppCross{solve}, \cvCppCross{eigen}, \cvCppCross{determinant}
 
+\cvCppFunc{SVD::SVD}
+SVD constructors
+
+\cvdefCpp{
+SVD::SVD();\newline
+SVD::SVD( const Mat\& A, int flags=0 );
+}
+\begin{description}
+\cvarg{A}{The decomposed matrix}
+\cvarg{flags}{Operation flags}
+\begin{description}
+    \cvarg{SVD::MODIFY\_A}{The algorithm can modify the decomposed matrix. It can save some space and speed-up processing a bit}
+    \cvarg{SVD::NO\_UV}{Only singular values are needed. The algorithm will not compute \texttt{U} and \texttt{V} matrices}
+    \cvarg{SVD::FULL\_UV}{When the matrix is not square, by default the algorithm produces \texttt{U} and \texttt{V} matrices of sufficiently large size for the further \texttt{A} reconstruction. If, however, \texttt{FULL\_UV} flag is specified, \texttt{U} and \texttt{V} will be full-size square orthogonal matrices.}
+\end{description}
+\end{description}
+
+The first constructor initializes empty \texttt{SVD} structure. The second constructor initializes empty \texttt{SVD} structure and then calls \cvCppCross{SVD::operator ()}.
+
+
+\cvCppFunc{SVD::operator ()}
+Performs SVD of a matrix
+
+\cvdefCpp{
+SVD\& SVD::operator ()( const Mat\& A, int flags=0 );
+}
+\begin{description}
+\cvarg{A}{The decomposed matrix}
+\cvarg{flags}{Operation flags}
+\begin{description}
+    \cvarg{SVD::MODIFY\_A}{The algorithm can modify the decomposed matrix. It can save some space and speed-up processing a bit}
+    \cvarg{SVD::NO\_UV}{Only singular values are needed. The algorithm will not compute \texttt{U} and \texttt{V} matrices}
+    \cvarg{SVD::FULL\_UV}{When the matrix is not square, by default the algorithm produces \texttt{U} and \texttt{V} matrices of sufficiently large size for the further \texttt{A} reconstruction. If, however, \texttt{FULL\_UV} flag is specified, \texttt{U} and \texttt{V} will be full-size square orthogonal matrices.}
+\end{description}
+\end{description}
+
+The operator performs singular value decomposition of the supplied matrix. The \texttt{U}, transposed \texttt{V} and the diagonal of \texttt{W} are stored in the structure. The same \texttt{SVD} structure can be reused many times with different matrices. Each time, if needed, the previous \texttt{u}, \texttt{vt} and \texttt{w} are reclaimed and the new matrices are created, which is all handled by \cvCppCross{Mat::create}.
+
+\cvCppFunc{SVD::solveZ}
+Solves under-determined singular linear system
+
+\cvdefCpp{
+static void SVD::solveZ( const Mat\& A, Mat\& x );
+}
+\begin{description}
+\cvarg{A}{The left-hand-side matrix.}
+\cvarg{x}{The found solution}
+\end{description}
+
+The method finds unit-length solution \textbf{x} of the under-determined system $A x = 0$. Theory says that such system has infinite number of solutions, so the algorithm finds the unit-length solution as the right singular vector corresponding to the smallest singular value (which should be 0). In practice, because of round errors and limited floating-point accuracy, the input matrix can appear to be close-to-singular rather than just singular. So, strictly speaking, the algorithm solves the following problem:
+
+\[
+x^* = \arg \min_{x: \|x\|=1} \|A \cdot x \|
+\]
+
+\cvCppFunc{SVD::backSubst}
+Performs singular value back substitution
+
+\cvdefCpp{
+void SVD::backSubst( const Mat\& rhs, Mat\& x ) const;
+}
+\begin{description}
+\cvarg{rhs}{The right-hand side of a linear system $\texttt{A} \texttt{x} = \texttt{rhs}$ being solved, where \texttt{A} is the matrix passed to \cvCppCross{SVD::SVD} or \cvCppCross{SVD::operator ()}}
+\cvarg{x}{The found solution of the system}
+\end{description}
+
+The method computes back substitution for the specified right-hand side:
+
+\[
+\texttt{x} = \texttt{vt}^T \cdot diag(\texttt{w})^{-1} \cdot \texttt{u}^T \cdot \texttt{rhs} \sim \texttt{A}^{-1} \cdot \texttt{rhs}
+\]
+
+Using this technique you can either get a very accurate solution of convenient linear system, or the best (in the least-squares terms) pseudo-solution of an overdetermined linear system. Note that explicit SVD with the further back substitution only makes sense if you need to solve many linear systems with the same left-hand side (e.g. \texttt{A}). If all you need is to solve a single system (possibly with multiple \texttt{rhs} immediately available), simply call \cvCppCross{solve} add pass \texttt{cv::DECOMP\_SVD} there - it will do absolutely the same thing. 
+
 \cvCppFunc{sum}
 Calculates sum of array elements