Per-element Operations

gpu::add

C++: void gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::add(const GpuMat& src1, const Scalar& src2, GpuMat& dst)

Computes a matrix-matrix or matrix-scalar sum.

Parameters:
  • src1 – First source matrix. CV_8UC1, CV_8UC4, CV_32SC1, and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix or a scalar to be added to src1.
  • dst – Destination matrix with the same size and type as src1.

See also

add()

gpu::subtract

C++: void gpu::subtract(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::subtract(const GpuMat& src1, const Scalar& src2, GpuMat& dst)

Computes a matrix-matrix or matrix-scalar difference.

Parameters:
  • src1 – First source matrix. CV_8UC1, CV_8UC4, CV_32SC1, and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix or a scalar to be subtracted from src1.
  • dst – Destination matrix with the same size and type as src1.

See also

subtract()

gpu::multiply

C++: void gpu::multiply(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::multiply(const GpuMat& src1, const Scalar& src2, GpuMat& dst)

Computes a matrix-matrix or matrix-scalar per-element product.

Parameters:
  • src1 – First source matrix. CV_8UC1, CV_8UC4, CV_32SC1, and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix or a scalar to be multiplied by src1 elements.
  • dst – Destination matrix with the same size and type as src1.

See also

multiply()

gpu::divide

C++: void gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::divide(const GpuMat& src1, const Scalar& src2, GpuMat& dst)

Computes a matrix-matrix or matrix-scalar sum.

Parameters:
  • src1 – First source matrix. CV_8UC1, CV_8UC4, CV_32SC1, and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix or a scalar. The src1 elements are divided by it.
  • dst – Destination matrix with the same size and type as src1.

This function, in contrast to divide(), uses a round-down rounding mode.

See also

divide()

gpu::exp

C++: void gpu::exp(const GpuMat& src, GpuMat& dst)

Computes an exponent of each matrix element.

Parameters:
  • src – Source matrix. CV_32FC1 matrixes are supported for now.
  • dst – Destination matrix with the same size and type as src.

See also

exp()

gpu::log

C++: void gpu::log(const GpuMat& src, GpuMat& dst)

Computes a natural logarithm of absolute value of each matrix element.

Parameters:
  • src – Source matrix. CV_32FC1 matrixes are supported for now.
  • dst – Destination matrix with the same size and type as src.

See also

log()

gpu::absdiff

C++: void gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::absdiff(const GpuMat& src1, const Scalar& src2, GpuMat& dst)

Computes per-element absolute difference of two matrices (or of a matrix and scalar).

Parameters:
  • src1 – First source matrix. CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix or a scalar to be added to src1.
  • dst – Destination matrix with the same size and type as src1.

See also

absdiff()

gpu::compare

C++: void gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int cmpop)

Compares elements of two matrices.

Parameters:
  • src1 – First source matrix. CV_8UC4 and CV_32FC1 matrices are supported for now.
  • src2 – Second source matrix with the same size and type as a.
  • dst – Destination matrix with the same size as a and the CV_8UC1 type.
  • cmpop

    Flag specifying the relation between the elements to be checked:

    • CMP_EQ: src1(.) == src2(.)
    • CMP_GT: src1(.) < src2(.)
    • CMP_GE: src1(.) <= src2(.)
    • CMP_LT: src1(.) < src2(.)
    • CMP_LE: src1(.) <= src2(.)
    • CMP_NE: src1(.) != src2(.)

See also

compare()

gpu::bitwise_not

C++: void gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat())
C++: void gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream)

Performs a per-element bitwise inversion.

Parameters:
  • src – Source matrix.
  • dst – Destination matrix with the same size and type as src.
  • mask – Optional operation mask. 8-bit single channel image.
  • stream – Stream for the asynchronous version.

gpu::bitwise_or

C++: void gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat())
C++: void gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)

Performs a per-element bitwise disjunction of two matrices.

Parameters:
  • src1 – First source matrix.
  • src2 – Second source matrix with the same size and type as src1.
  • dst – Destination matrix with the same size and type as src1.
  • mask – Optional operation mask. 8-bit single channel image.
  • stream – Stream for the asynchronous version.

gpu::bitwise_and

C++: void gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat())
C++: void gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)

Performs a per-element bitwise conjunction of two matrices.

Parameters:
  • src1 – First source matrix.
  • src2 – Second source matrix with the same size and type as src1.
  • dst – Destination matrix with the same size and type as src1.
  • mask – Optional operation mask. 8-bit single channel image.
  • stream – Stream for the asynchronous version.

gpu::bitwise_xor

C++: void gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat())
C++: void gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)

Performs a per-element bitwise exclusive or operation of two matrices.

Parameters:
  • src1 – First source matrix.
  • src2 – Second source matrix with the same size and type as src1.
  • dst – Destination matrix with the same size and type as src1.
  • mask – Optional operation mask. 8-bit single channel image.
  • stream – Stream for the asynchronous version.

gpu::min

C++: void gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream)
C++: void gpu::min(const GpuMat& src1, double src2, GpuMat& dst)
C++: void gpu::min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream)

Computes the per-element minimum of two matrices (or a matrix and a scalar).

Parameters:
  • src1 – First source matrix.
  • src2 – Second source matrix or a scalar to compare src1 elements with.
  • dst – Destination matrix with the same size and type as src1.
  • stream – Stream for the asynchronous version.

See also

min()

gpu::max

C++: void gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
C++: void gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream)
C++: void gpu::max(const GpuMat& src1, double src2, GpuMat& dst)
C++: void gpu::max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream)

Computes the per-element maximum of two matrices (or a matrix and a scalar).

Parameters:
  • src1 – First source matrix.
  • src2 – Second source matrix or a scalar to compare src1 elements with.
  • dst – Destination matrix with the same size and type as src1.
  • stream – Stream for the asynchronous version.

See also

max()