OpenCV Matrix (Array) operation (i) __OPENCV

Source: Internet
Author: User
Tags abs scalar

OpenCV Learning:

In OpenCV, the API Matrix (array) works:

1. Calculate the absolute value of all elements in the array;

Scalar cv::cuda::abssum (Inputarray src,
Inputarray mask = Noarray ()
)

Returns the sum of absolute values for matrix elements

Parameters
SRC Source image of any depth except for cv_64f.
Mask optional Operation mask; It must have the same size as SRC1 and CV_8UC1 type.

2. The absolute value of the difference of two arrays;

void Cv::absdiff (INPUTARRAYSRC1,
Inputarray Src2,
Outputarray DST
)

Between an array and a scalar.

Calculates the per-element absolute difference between two arrays or Parameters
Src1 a scalar.
SRC2 second input array or a scalar.
DST output array that has the same size and type as input array

Click to open the link

3. Element-level addition of two arrays;

void Cv::add (INPUTARRAYSRC1,
Inputarray Src2,
Outputarray DST,
Inputarray mask = Noarray (),
int dtype =-1

)

Two arrays or an array and a scalar.

Calculates the per-element sum of Parameters:
Src1 a scalar.
SRC2 second input array or a scalar.
DST output array that has the same size and number of channels as the input array (s); The depth is defined by Dtype or SRC1/SRC2.
Mask optional Operation Mask-8-bit Single channel array, this specifies elements of the output array to is changed
Dtype optional depth of the output array (the discussion below).

Click to open the link

4. The weighted addition operation of two array elements;

void Cv::addweighted (INPUTARRAYSRC1,
Double Alpha,
Inputarray Src2,
Double Beta,
Double Gamma,
Outputarray DST,
int dtype =-1
)

Calculates the weighted sum of two array.

DST = Src1*alpha + Src2*beta + gamma;

Parameters
SRC1-the-i-input array.
Alpha weight of the ' the ' the ' the ' the ' the '.
SRC2 second input array of the same size and channel number as SRC1.
Beta weight of the second array elements.
Gamma scalar added to each sum.
DST output array that has the same size and number of channels as the input arrays.
Dtype optional depth of the output array; When both input arrays have the same depth, Dtype can is set to-1, which'll is equivalent to SRC1.D Epth ().

Detailed introduction links are as follows:

Click to open the link

5. Calculates the average of all elements in an array;

No API found, but I can provide a way to use the API, which is to sum the API by dividing the length of the array

6. Calculate the absolute value and standard deviation of all elements in an array

There is no API that can be invoked directly in opencv3.0, and the decomposed code can be found on the Internet.

7. Calculates the covariance of a set of n-dimensional space vectors;

void Cv::calccovarmatrix (Inputarray samples,
Outputarray Covar,
Inputoutputarray mean,
int flags,
int ctype = cv_64f

)


This is a overloaded member function with provided for convenience. It differs from the above function is in what argument (s) it accepts

Parameters
Samples samples stored as rows/columns of a single matrix.
Covar output covariance matrix of the type CType and square size.
Mean input or output (depending on the flags) array as the average value of the input vectors.
Flags operation flags as a combination of cv::covarflags
CType type of the MATRIXL; It equals ' cv_64f ' by default.

Click to open the link

8. Use the set comparison operation for all elements in the two array;

void Cv::compare (Inputarray src1,
Inputarray Src2,
Outputarray DST,
int Cmpop
)

Performs the per-element comparison of two arrays or an array and scalar value.

Parameters
Src1 a scalar; When it's an array, it must have a single channel.
SRC2 second input array or a scalar; When it's an array, it must have a single channel.
DST output array of type ref cv_8u that has the same size and the same number of channels as the input arrays.
Cmpop a flag, that specifies correspondence between the arrays (Cv::cmptypes)

Click to open the link

9. Converts the type of the array element after calculating the absolute value of the optional scaling value;

void Cv::convertscaleabs (Inputarray src,
Outputarray DST,
Double alpha = 1,
Double beta = 0
)

Scales, calculates absolute values, and converts the result to 8-bit.

Parameters

Src Input array.
Dst Output array.
Alpha Optional scale factor.
Beta Optional Delta added to the scaled values.

Mat_<float> A (30,30); Randu (A,scalar ( -100), Scalar (100)); Mat_<float> B = a*5 + 3; b = ABS (b); mat_<float> B = ABS (A*5+3) 'll also do the job,//But it'll allocate A temporary matrix click Open link

10. Calculation of 0 numbers in the array;

int Cv::countnonzero (Inputarray src)

11. Compute the vector product of two three-dimensional vectors;

No API found on the web write DST = src1 * SRC2 to meet the rules of matrix multiplication;

12. Transfer the array channel from one primary color space to another;

void Cv::cvtcolor (Inputarray src,
Outputarray DST,
int code,
int DSTCN = 0
)

Converts an image from one color spaces to another.

Parameters
src input image:8-bit unsigned, 16-bit unsigned (Cv_16uc ...), or single-precision floating-point.
DST output image of the same size and depth as SRC.
Code color Space Conversion Code (CV::COLORCONVERSIONCODES).
DSTCN number of channels in the destination image; If the parameter is 0, the number of the channels are derived automatically from SRC and code.

13. Calculate the determinant of the square;

Double Cvdet (const CVARR * mat)

14. An element-level division operation of an array using another array;

void Cvdiv (const Cvarr * SRC1,
Const CVARR * SRC2,
Cvarr * DST,
Double scale = 1
)

DST (IDX) = SRC1 (IDX) * SCALE/SRC2 (IDX) or DST (idx) = SCALE/SRC2 (idx) If Src1 = 0

15. Compute the dot product of two vectors;

Double cvdotproduct (const Cvarr * SRC1,
Const CVARR * SRC2
)

Parameters
Src1 the ' the ' ' the ' the ' source array
Src2 the second source array

16. Compute the eigenvalues and eigenvectors of the matrices;

void Cveigenvv (Cvarr * mat,
Cvarr * Evects,
Cvarr * Evals,
Double EPS = 0,
int lowindex =-1,
int highindex =-1
)

17. Flip around the selected axis;

void Cvflip (const CVARR * src,
Cvarr * DST = NULL,
int Flip_mode = 0
)

18. Matrix multiplication;

void Cvgemm (const Cvarr * SRC1,
Const CVARR * SRC2,
Double Alpha,
Const CVARR * SRC3,
Double Beta,
Cvarr * DST,
int TABC = 0
)

19. Copy elements from a column in an array;

cvmat* Cvgetcol (const Cvarr * arr,
Cvmat * Submat,
int col
)

Parameters
Arr Input Array
Submat pointer to the resulting SUB-ARRAY header
Col zero-based index of the selected column

20. Copy element values from multiple columns adjacent to the data;

cvmat* cvgetcols (const Cvarr * arr,
                      &NB Sp                 Cvmat *    submat,
     ,                                   int   &NBSP ;         start_col,
                    &NBSP ;                   int             end_col& nbsp
                                   )

Parameters
Arr Input Array
Submat pointer to the resulting SUB-ARRAY header
Start_col zero-based index of the starting column (inclusive) of the span
End_col zero-based index of the ending column (exclusive) of the span

21. Copy all the elements on the diagonal of the array;

cvmat* Cvgetdiag ( Const CVARR * Arr


Cvmat * Submat,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.