Statistical Functions
sum
Input array (1 to 4 channels)
Sum of all array elements for each channel
mean
Input array (1 to 4 channels)
Optional operation mask (8-bit single channel)
Mean value for each channel
meanStdDev
Input array (1 to 4 channels)
Output parameter: calculated mean value
Output parameter: calculated standard deviation
Optional operation mask
minMaxLoc
Input single-channel array
Pointer to returned minimum value (can be NULL)
Pointer to returned maximum value (can be NULL)
Pointer to returned minimum location (can be NULL)
Pointer to returned maximum location (can be NULL)
Optional mask to select a sub-array
norm
First input array
Second input array (for difference norms)
Type of norm: NORM_INF, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2
Optional operation mask
Calculated norm value
NORM_INF: max(|x_i|)NORM_L1: Σ|x_i|NORM_L2: √(Σx_i²)NORM_L2SQR: Σx_i²
normalize
Input array
Output array (same size as src)
Norm value to normalize to or lower range boundary in range normalization
Upper range boundary in range normalization (not used for norm normalization)
Normalization type: NORM_INF, NORM_L1, NORM_L2, or NORM_MINMAX
Optional depth of output array
Optional operation mask
countNonZero
Single-channel array
Number of non-zero elements
hasNonZero
True if at least one non-zero element exists
findNonZero
Single-channel array (8-bit or floating-point)
Output array of Point locations (N×1 or 1×N)
Reduction Operations
reduce
Input array
Output vector
Dimension to reduce: 0 (reduce to single row), 1 (reduce to single column)
Reduction operation: REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN, REDUCE_SUM2
Optional depth of output array
REDUCE_SUM: Sum of all rows/columnsREDUCE_AVG: Mean of all rows/columnsREDUCE_MAX: Maximum of all rows/columnsREDUCE_MIN: Minimum of all rows/columnsREDUCE_SUM2: Sum of squared values
reduceArgMin
Input array
Output array of indices
Dimension to reduce along
Whether to return last index in case of multiple minimum values
reduceArgMax
Sorting
sort
Input single-channel array
Output array (same size and type as src)
Operation flags: SORT_EVERY_ROW, SORT_EVERY_COLUMN, SORT_ASCENDING, SORT_DESCENDING
sortIdx
Output integer array of sorted indices
Linear Algebra
determinant
Input matrix (must be square)
Determinant value
trace
Input matrix
Trace of the matrix
invert
Input floating-point matrix
Output matrix of the same size and type as src
Inversion method: DECOMP_LU, DECOMP_SVD, DECOMP_CHOLESKY
Reciprocal condition number (for SVD) or 0 if singular
DECOMP_LU: LU decomposition (fastest for well-conditioned matrices)DECOMP_SVD: Singular value decomposition (works for singular matrices)DECOMP_CHOLESKY: Cholesky decomposition (for symmetric positive-definite matrices)
solve
Coefficient matrix (A in Ax=b)
Right-hand side matrix (b in Ax=b)
Output solution (x in Ax=b)
Solution method: DECOMP_LU, DECOMP_SVD, DECOMP_CHOLESKY, DECOMP_QR, DECOMP_NORMAL
True if solution exists
eigen
Input symmetric square matrix
Output vector of eigenvalues (in descending order)
Output matrix of eigenvectors (one per row)
True if successful
This function is optimized for symmetric matrices. For general matrices, use eigenNonSymmetric().
calcCovarMatrix
Input samples (each row or column is a sample)
Output covariance matrix
Input or output mean vector
Operation flags: COVAR_SCRAMBLED, COVAR_NORMAL, COVAR_USE_AVG, COVAR_SCALE, COVAR_ROWS, COVAR_COLS
Type of output matrices (CV_32F or CV_64F)
Timing and Profiling
getTickCount
Current tick count
getTickFrequency
Tick frequency in Hz
TickMeter
System Information
getNumberOfCPUs
setNumThreads
Number of threads. Use 0 or negative values to reset to default
getNumThreads
getBuildInformation
getVersionString
getCPUFeaturesLine
- No marker: baseline features
*: features enabled in dispatcher?: features enabled but not available in hardware
Utility Functions
setUseOptimized
True to enable optimizations, false to disable
useOptimized
checkRange
Input array
If true, doesn’t throw exceptions on invalid values
Optional output parameter for position of first invalid value
Minimum valid value (inclusive)
Maximum valid value (inclusive)
True if all elements are within range and not NaN/Inf
patchNaNs
Input/output floating-point array
Value to replace NaNs with
LUT
Input array (8-bit elements)
Look-up table (256 elements)
Output array (same size as src)
convertScaleAbs
Input array
Output array (CV_8U type)
Scale factor
Delta added to scaled values
PSNR
First input array
Second input array (same size and type as src1)
Maximum pixel value (255.0 for 8-bit images)
PSNR value in decibels (dB)
Higher PSNR values indicate better quality. Typical values range from 20 to 50 dB, with 30-50 dB being good quality.
