public class Core
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Core.MinMaxLocResult |
| Modifier and Type | Field and Description |
|---|---|
static int |
CMP_EQ |
static int |
CMP_GE |
static int |
CMP_GT |
static int |
CMP_LE |
static int |
CMP_LT |
static int |
CMP_NE |
static int |
COVAR_COLS |
static int |
COVAR_NORMAL |
static int |
COVAR_ROWS |
static int |
COVAR_SCALE |
static int |
COVAR_SCRAMBLED |
static int |
COVAR_USE_AVG |
static int |
DCT_INVERSE |
static int |
DCT_ROWS |
static int |
DECOMP_CHOLESKY |
static int |
DECOMP_EIG |
static int |
DECOMP_LU |
static int |
DECOMP_NORMAL |
static int |
DECOMP_QR |
static int |
DECOMP_SVD |
static int |
DEPTH_MASK |
static int |
DEPTH_MASK_16S |
static int |
DEPTH_MASK_16U |
static int |
DEPTH_MASK_32F |
static int |
DEPTH_MASK_32S |
static int |
DEPTH_MASK_64F |
static int |
DEPTH_MASK_8S |
static int |
DEPTH_MASK_8U |
static int |
DEPTH_MASK_ALL |
static int |
DEPTH_MASK_ALL_BUT_8S |
static int |
DEPTH_MASK_FLT |
static int |
DFT_COMPLEX_OUTPUT |
static int |
DFT_INVERSE |
static int |
DFT_REAL_OUTPUT |
static int |
DFT_ROWS |
static int |
DFT_SCALE |
static int |
FILLED |
static int |
FONT_HERSHEY_COMPLEX |
static int |
FONT_HERSHEY_COMPLEX_SMALL |
static int |
FONT_HERSHEY_DUPLEX |
static int |
FONT_HERSHEY_PLAIN |
static int |
FONT_HERSHEY_SCRIPT_COMPLEX |
static int |
FONT_HERSHEY_SCRIPT_SIMPLEX |
static int |
FONT_HERSHEY_SIMPLEX |
static int |
FONT_HERSHEY_TRIPLEX |
static int |
FONT_ITALIC |
static int |
GEMM_1_T |
static int |
GEMM_2_T |
static int |
GEMM_3_T |
static int |
KMEANS_PP_CENTERS |
static int |
KMEANS_RANDOM_CENTERS |
static int |
KMEANS_USE_INITIAL_LABELS |
static int |
LINE_4 |
static int |
LINE_8 |
static int |
LINE_AA |
static int |
MAGIC_MASK |
static int |
MARKER_CROSS |
static int |
MARKER_DIAMOND |
static int |
MARKER_SQUARE |
static int |
MARKER_STAR |
static int |
MARKER_TILTED_CROSS |
static int |
MARKER_TRIANGLE_DOWN |
static int |
MARKER_TRIANGLE_UP |
static java.lang.String |
NATIVE_LIBRARY_NAME |
static int |
NORM_HAMMING |
static int |
NORM_HAMMING2 |
static int |
NORM_INF |
static int |
NORM_L1 |
static int |
NORM_L2 |
static int |
NORM_L2SQR |
static int |
NORM_MINMAX |
static int |
NORM_RELATIVE |
static int |
NORM_TYPE_MASK |
static int |
REDUCE_AVG |
static int |
REDUCE_MAX |
static int |
REDUCE_MIN |
static int |
REDUCE_SUM |
static int |
SORT_ASCENDING |
static int |
SORT_DESCENDING |
static int |
SORT_EVERY_COLUMN |
static int |
SORT_EVERY_ROW |
static int |
SVD_FULL_UV |
static int |
SVD_MODIFY_A |
static int |
SVD_NO_UV |
static int |
TYPE_MASK |
static java.lang.String |
VERSION |
static int |
VERSION_EPOCH |
static int |
VERSION_MAJOR |
static int |
VERSION_MINOR |
static int |
VERSION_REVISION |
| Constructor and Description |
|---|
Core() |
| Modifier and Type | Method and Description |
|---|---|
static void |
absdiff(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element absolute difference between two arrays or between
an array and a scalar.
|
static void |
absdiff(Mat src1,
Scalar src2,
Mat dst)
Calculates the per-element absolute difference between two arrays or between
an array and a scalar.
|
static void |
add(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
add(Mat src1,
Mat src2,
Mat dst,
Mat mask)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
add(Mat src1,
Mat src2,
Mat dst,
Mat mask,
int dtype)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
add(Mat src1,
Scalar src2,
Mat dst)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
add(Mat src1,
Scalar src2,
Mat dst,
Mat mask)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
add(Mat src1,
Scalar src2,
Mat dst,
Mat mask,
int dtype)
Calculates the per-element sum of two arrays or an array and a scalar.
|
static void |
addWeighted(Mat src1,
double alpha,
Mat src2,
double beta,
double gamma,
Mat dst)
Calculates the weighted sum of two arrays.
|
static void |
addWeighted(Mat src1,
double alpha,
Mat src2,
double beta,
double gamma,
Mat dst,
int dtype)
Calculates the weighted sum of two arrays.
|
static void |
arrowedLine(Mat img,
Point pt1,
Point pt2,
Scalar color)
Draws a arrow segment pointing from the first point to the second one.
|
static void |
arrowedLine(Mat img,
Point pt1,
Point pt2,
Scalar color,
int thickness,
int line_type,
int shift,
double tipLength)
Draws a arrow segment pointing from the first point to the second one.
|
static void |
batchDistance(Mat src1,
Mat src2,
Mat dist,
int dtype,
Mat nidx) |
static void |
batchDistance(Mat src1,
Mat src2,
Mat dist,
int dtype,
Mat nidx,
int normType,
int K) |
static void |
batchDistance(Mat src1,
Mat src2,
Mat dist,
int dtype,
Mat nidx,
int normType,
int K,
Mat mask,
int update,
boolean crosscheck) |
static void |
bitwise_and(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element bit-wise conjunction of two arrays or an array and
a scalar.
|
static void |
bitwise_and(Mat src1,
Mat src2,
Mat dst,
Mat mask)
Calculates the per-element bit-wise conjunction of two arrays or an array and
a scalar.
|
static void |
bitwise_not(Mat src,
Mat dst)
Inverts every bit of an array.
|
static void |
bitwise_not(Mat src,
Mat dst,
Mat mask)
Inverts every bit of an array.
|
static void |
bitwise_or(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element bit-wise disjunction of two arrays or an array and
a scalar.
|
static void |
bitwise_or(Mat src1,
Mat src2,
Mat dst,
Mat mask)
Calculates the per-element bit-wise disjunction of two arrays or an array and
a scalar.
|
static void |
bitwise_xor(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element bit-wise "exclusive or" operation on two arrays or
an array and a scalar.
|
static void |
bitwise_xor(Mat src1,
Mat src2,
Mat dst,
Mat mask)
Calculates the per-element bit-wise "exclusive or" operation on two arrays or
an array and a scalar.
|
static void |
calcCovarMatrix(Mat samples,
Mat covar,
Mat mean,
int flags)
Calculates the covariance matrix of a set of vectors.
|
static void |
calcCovarMatrix(Mat samples,
Mat covar,
Mat mean,
int flags,
int ctype)
Calculates the covariance matrix of a set of vectors.
|
static void |
cartToPolar(Mat x,
Mat y,
Mat magnitude,
Mat angle)
Calculates the magnitude and angle of 2D vectors.
|
static void |
cartToPolar(Mat x,
Mat y,
Mat magnitude,
Mat angle,
boolean angleInDegrees)
Calculates the magnitude and angle of 2D vectors.
|
static boolean |
checkRange(Mat a)
Checks every element of an input array for invalid values.
|
static boolean |
checkRange(Mat a,
boolean quiet,
double minVal,
double maxVal)
Checks every element of an input array for invalid values.
|
static void |
circle(Mat img,
Point center,
int radius,
Scalar color)
Draws a circle.
|
static void |
circle(Mat img,
Point center,
int radius,
Scalar color,
int thickness)
Draws a circle.
|
static void |
circle(Mat img,
Point center,
int radius,
Scalar color,
int thickness,
int lineType,
int shift)
Draws a circle.
|
static boolean |
clipLine(Rect imgRect,
Point pt1,
Point pt2)
Clips the line against the image rectangle.
|
static void |
compare(Mat src1,
Mat src2,
Mat dst,
int cmpop)
Performs the per-element comparison of two arrays or an array and scalar
value.
|
static void |
compare(Mat src1,
Scalar src2,
Mat dst,
int cmpop)
Performs the per-element comparison of two arrays or an array and scalar
value.
|
static void |
completeSymm(Mat mtx)
Copies the lower or the upper half of a square matrix to another half.
|
static void |
completeSymm(Mat mtx,
boolean lowerToUpper)
Copies the lower or the upper half of a square matrix to another half.
|
static void |
convertScaleAbs(Mat src,
Mat dst)
Scales, calculates absolute values, and converts the result to 8-bit.
|
static void |
convertScaleAbs(Mat src,
Mat dst,
double alpha,
double beta)
Scales, calculates absolute values, and converts the result to 8-bit.
|
static int |
countNonZero(Mat src)
Counts non-zero array elements.
|
static float |
cubeRoot(float val)
Computes the cube root of an argument.
|
static void |
dct(Mat src,
Mat dst)
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
|
static void |
dct(Mat src,
Mat dst,
int flags)
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
|
static double |
determinant(Mat mtx)
Returns the determinant of a square floating-point matrix.
|
static void |
dft(Mat src,
Mat dst)
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D
floating-point array.
|
static void |
dft(Mat src,
Mat dst,
int flags,
int nonzeroRows)
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D
floating-point array.
|
static void |
divide(double scale,
Mat src2,
Mat dst)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(double scale,
Mat src2,
Mat dst,
int dtype)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Mat src2,
Mat dst)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Mat src2,
Mat dst,
double scale)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Mat src2,
Mat dst,
double scale,
int dtype)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Scalar src2,
Mat dst)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Scalar src2,
Mat dst,
double scale)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
divide(Mat src1,
Scalar src2,
Mat dst,
double scale,
int dtype)
Performs per-element division of two arrays or a scalar by an array.
|
static void |
drawMarker(Mat img,
Point position,
Scalar color) |
static void |
drawMarker(Mat img,
Point position,
Scalar color,
int markerType,
int markerSize,
int thickness,
int line_type) |
static boolean |
eigen(Mat src,
boolean computeEigenvectors,
Mat eigenvalues,
Mat eigenvectors)
Calculates eigenvalues and eigenvectors of a symmetric matrix.
|
static void |
ellipse(Mat img,
Point center,
Size axes,
double angle,
double startAngle,
double endAngle,
Scalar color)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse(Mat img,
Point center,
Size axes,
double angle,
double startAngle,
double endAngle,
Scalar color,
int thickness)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse(Mat img,
Point center,
Size axes,
double angle,
double startAngle,
double endAngle,
Scalar color,
int thickness,
int lineType,
int shift)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse(Mat img,
RotatedRect box,
Scalar color)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse(Mat img,
RotatedRect box,
Scalar color,
int thickness)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse(Mat img,
RotatedRect box,
Scalar color,
int thickness,
int lineType)
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
static void |
ellipse2Poly(Point center,
Size axes,
int angle,
int arcStart,
int arcEnd,
int delta,
MatOfPoint pts)
Approximates an elliptic arc with a polyline.
|
static void |
exp(Mat src,
Mat dst)
Calculates the exponent of every array element.
|
static void |
extractChannel(Mat src,
Mat dst,
int coi) |
static float |
fastAtan2(float y,
float x)
Calculates the angle of a 2D vector in degrees.
|
static void |
fillConvexPoly(Mat img,
MatOfPoint points,
Scalar color)
Fills a convex polygon.
|
static void |
fillConvexPoly(Mat img,
MatOfPoint points,
Scalar color,
int lineType,
int shift)
Fills a convex polygon.
|
static void |
fillPoly(Mat img,
java.util.List<MatOfPoint> pts,
Scalar color)
Fills the area bounded by one or more polygons.
|
static void |
fillPoly(Mat img,
java.util.List<MatOfPoint> pts,
Scalar color,
int lineType,
int shift,
Point offset)
Fills the area bounded by one or more polygons.
|
static void |
findNonZero(Mat src,
Mat idx) |
static void |
flip(Mat src,
Mat dst,
int flipCode)
Flips a 2D array around vertical, horizontal, or both axes.
|
static void |
gemm(Mat src1,
Mat src2,
double alpha,
Mat src3,
double beta,
Mat dst)
Performs generalized matrix multiplication.
|
static void |
gemm(Mat src1,
Mat src2,
double alpha,
Mat src3,
double beta,
Mat dst,
int flags)
Performs generalized matrix multiplication.
|
static java.lang.String |
getBuildInformation()
Returns full configuration time cmake output.
|
static long |
getCPUTickCount()
Returns the number of CPU ticks.
|
static int |
getNumberOfCPUs()
Returns the number of logical CPUs available for the process.
|
static int |
getNumThreads()
Returns the number of threads used by OpenCV for parallel regions.
|
static int |
getOptimalDFTSize(int vecsize)
Returns the optimal DFT size for a given vector size.
|
static Size |
getTextSize(java.lang.String text,
int fontFace,
double fontScale,
int thickness,
int[] baseLine)
Calculates the width and height of a text string.
|
static int |
getThreadNum()
Returns the index of the currently executed thread within the current
parallel region.
|
static long |
getTickCount()
Returns the number of ticks.
|
static double |
getTickFrequency()
Returns the number of ticks per second.
|
static void |
hconcat(java.util.List<Mat> src,
Mat dst) |
static void |
idct(Mat src,
Mat dst)
Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
|
static void |
idct(Mat src,
Mat dst,
int flags)
Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
|
static void |
idft(Mat src,
Mat dst)
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
|
static void |
idft(Mat src,
Mat dst,
int flags,
int nonzeroRows)
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
|
static void |
inRange(Mat src,
Scalar lowerb,
Scalar upperb,
Mat dst)
Checks if array elements lie between the elements of two other arrays.
|
static void |
insertChannel(Mat src,
Mat dst,
int coi) |
static double |
invert(Mat src,
Mat dst)
Finds the inverse or pseudo-inverse of a matrix.
|
static double |
invert(Mat src,
Mat dst,
int flags)
Finds the inverse or pseudo-inverse of a matrix.
|
static double |
kmeans(Mat data,
int K,
Mat bestLabels,
TermCriteria criteria,
int attempts,
int flags)
Finds centers of clusters and groups input samples around the clusters.
|
static double |
kmeans(Mat data,
int K,
Mat bestLabels,
TermCriteria criteria,
int attempts,
int flags,
Mat centers)
Finds centers of clusters and groups input samples around the clusters.
|
static void |
line(Mat img,
Point pt1,
Point pt2,
Scalar color)
Draws a line segment connecting two points.
|
static void |
line(Mat img,
Point pt1,
Point pt2,
Scalar color,
int thickness)
Draws a line segment connecting two points.
|
static void |
line(Mat img,
Point pt1,
Point pt2,
Scalar color,
int thickness,
int lineType,
int shift)
Draws a line segment connecting two points.
|
static void |
log(Mat src,
Mat dst)
Calculates the natural logarithm of every array element.
|
static void |
LUT(Mat src,
Mat lut,
Mat dst)
Performs a look-up table transform of an array.
|
static void |
LUT(Mat src,
Mat lut,
Mat dst,
int interpolation)
Performs a look-up table transform of an array.
|
static void |
magnitude(Mat x,
Mat y,
Mat magnitude)
Calculates the magnitude of 2D vectors.
|
static double |
Mahalanobis(Mat v1,
Mat v2,
Mat icovar)
Calculates the Mahalanobis distance between two vectors.
|
static void |
max(Mat src1,
Mat src2,
Mat dst)
Calculates per-element maximum of two arrays or an array and a scalar.
|
static void |
max(Mat src1,
Scalar src2,
Mat dst)
Calculates per-element maximum of two arrays or an array and a scalar.
|
static Scalar |
mean(Mat src)
Calculates an average (mean) of array elements.
|
static Scalar |
mean(Mat src,
Mat mask)
Calculates an average (mean) of array elements.
|
static void |
meanStdDev(Mat src,
MatOfDouble mean,
MatOfDouble stddev)
Calculates a mean and standard deviation of array elements.
|
static void |
meanStdDev(Mat src,
MatOfDouble mean,
MatOfDouble stddev,
Mat mask)
Calculates a mean and standard deviation of array elements.
|
static void |
merge(java.util.List<Mat> mv,
Mat dst)
Creates one multichannel array out of several single-channel ones.
|
static void |
min(Mat src1,
Mat src2,
Mat dst)
Calculates per-element minimum of two arrays or an array and a scalar.
|
static void |
min(Mat src1,
Scalar src2,
Mat dst)
Calculates per-element minimum of two arrays or an array and a scalar.
|
static Core.MinMaxLocResult |
minMaxLoc(Mat src)
Finds the global minimum and maximum in an array.
|
static Core.MinMaxLocResult |
minMaxLoc(Mat src,
Mat mask)
Finds the global minimum and maximum in an array.
|
static void |
mixChannels(java.util.List<Mat> src,
java.util.List<Mat> dst,
MatOfInt fromTo)
Copies specified channels from input arrays to the specified channels of
output arrays.
|
static void |
mulSpectrums(Mat a,
Mat b,
Mat c,
int flags)
Performs the per-element multiplication of two Fourier spectrums.
|
static void |
mulSpectrums(Mat a,
Mat b,
Mat c,
int flags,
boolean conjB)
Performs the per-element multiplication of two Fourier spectrums.
|
static void |
multiply(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element scaled product of two arrays.
|
static void |
multiply(Mat src1,
Mat src2,
Mat dst,
double scale)
Calculates the per-element scaled product of two arrays.
|
static void |
multiply(Mat src1,
Mat src2,
Mat dst,
double scale,
int dtype)
Calculates the per-element scaled product of two arrays.
|
static void |
multiply(Mat src1,
Scalar src2,
Mat dst)
Calculates the per-element scaled product of two arrays.
|
static void |
multiply(Mat src1,
Scalar src2,
Mat dst,
double scale)
Calculates the per-element scaled product of two arrays.
|
static void |
multiply(Mat src1,
Scalar src2,
Mat dst,
double scale,
int dtype)
Calculates the per-element scaled product of two arrays.
|
static void |
mulTransposed(Mat src,
Mat dst,
boolean aTa)
Calculates the product of a matrix and its transposition.
|
static void |
mulTransposed(Mat src,
Mat dst,
boolean aTa,
Mat delta,
double scale)
Calculates the product of a matrix and its transposition.
|
static void |
mulTransposed(Mat src,
Mat dst,
boolean aTa,
Mat delta,
double scale,
int dtype)
Calculates the product of a matrix and its transposition.
|
static double |
norm(Mat src1)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static double |
norm(Mat src1,
int normType)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static double |
norm(Mat src1,
int normType,
Mat mask)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static double |
norm(Mat src1,
Mat src2)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static double |
norm(Mat src1,
Mat src2,
int normType)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static double |
norm(Mat src1,
Mat src2,
int normType,
Mat mask)
Calculates an absolute array norm, an absolute difference norm, or a relative
difference norm.
|
static void |
normalize(Mat src,
Mat dst)
Normalizes the norm or value range of an array.
|
static void |
normalize(Mat src,
Mat dst,
double alpha,
double beta,
int norm_type)
Normalizes the norm or value range of an array.
|
static void |
normalize(Mat src,
Mat dst,
double alpha,
double beta,
int norm_type,
int dtype)
Normalizes the norm or value range of an array.
|
static void |
normalize(Mat src,
Mat dst,
double alpha,
double beta,
int norm_type,
int dtype,
Mat mask)
Normalizes the norm or value range of an array.
|
static void |
patchNaNs(Mat a) |
static void |
patchNaNs(Mat a,
double val) |
static void |
PCABackProject(Mat data,
Mat mean,
Mat eigenvectors,
Mat result) |
static void |
PCACompute(Mat data,
Mat mean,
Mat eigenvectors) |
static void |
PCACompute(Mat data,
Mat mean,
Mat eigenvectors,
int maxComponents) |
static void |
PCAComputeVar(Mat data,
Mat mean,
Mat eigenvectors,
double retainedVariance) |
static void |
PCAProject(Mat data,
Mat mean,
Mat eigenvectors,
Mat result) |
static void |
perspectiveTransform(Mat src,
Mat dst,
Mat m)
Performs the perspective matrix transformation of vectors.
|
static void |
phase(Mat x,
Mat y,
Mat angle)
Calculates the rotation angle of 2D vectors.
|
static void |
phase(Mat x,
Mat y,
Mat angle,
boolean angleInDegrees)
Calculates the rotation angle of 2D vectors.
|
static void |
polarToCart(Mat magnitude,
Mat angle,
Mat x,
Mat y)
Calculates x and y coordinates of 2D vectors from their magnitude and angle.
|
static void |
polarToCart(Mat magnitude,
Mat angle,
Mat x,
Mat y,
boolean angleInDegrees)
Calculates x and y coordinates of 2D vectors from their magnitude and angle.
|
static void |
polylines(Mat img,
java.util.List<MatOfPoint> pts,
boolean isClosed,
Scalar color)
Draws several polygonal curves.
|
static void |
polylines(Mat img,
java.util.List<MatOfPoint> pts,
boolean isClosed,
Scalar color,
int thickness)
Draws several polygonal curves.
|
static void |
polylines(Mat img,
java.util.List<MatOfPoint> pts,
boolean isClosed,
Scalar color,
int thickness,
int lineType,
int shift)
Draws several polygonal curves.
|
static void |
pow(Mat src,
double power,
Mat dst)
Raises every array element to a power.
|
static void |
putText(Mat img,
java.lang.String text,
Point org,
int fontFace,
double fontScale,
Scalar color)
Draws a text string.
|
static void |
putText(Mat img,
java.lang.String text,
Point org,
int fontFace,
double fontScale,
Scalar color,
int thickness)
Draws a text string.
|
static void |
putText(Mat img,
java.lang.String text,
Point org,
int fontFace,
double fontScale,
Scalar color,
int thickness,
int lineType,
boolean bottomLeftOrigin)
Draws a text string.
|
static void |
randn(Mat dst,
double mean,
double stddev)
Fills the array with normally distributed random numbers.
|
static void |
randShuffle(Mat dst) |
static void |
randShuffle(Mat dst,
double iterFactor) |
static void |
randu(Mat dst,
double low,
double high)
Generates a single uniformly-distributed random number or an array of random
numbers.
|
static void |
rectangle(Mat img,
Point pt1,
Point pt2,
Scalar color)
Draws a simple, thick, or filled up-right rectangle.
|
static void |
rectangle(Mat img,
Point pt1,
Point pt2,
Scalar color,
int thickness)
Draws a simple, thick, or filled up-right rectangle.
|
static void |
rectangle(Mat img,
Point pt1,
Point pt2,
Scalar color,
int thickness,
int lineType,
int shift)
Draws a simple, thick, or filled up-right rectangle.
|
static void |
reduce(Mat src,
Mat dst,
int dim,
int rtype)
Reduces a matrix to a vector.
|
static void |
reduce(Mat src,
Mat dst,
int dim,
int rtype,
int dtype)
Reduces a matrix to a vector.
|
static void |
repeat(Mat src,
int ny,
int nx,
Mat dst)
Fills the output array with repeated copies of the input array.
|
static void |
scaleAdd(Mat src1,
double alpha,
Mat src2,
Mat dst)
Calculates the sum of a scaled array and another array.
|
static void |
setErrorVerbosity(boolean verbose) |
static void |
setIdentity(Mat mtx)
Initializes a scaled identity matrix.
|
static void |
setIdentity(Mat mtx,
Scalar s)
Initializes a scaled identity matrix.
|
static void |
setNumThreads(int nthreads)
OpenCV will try to set the number of threads for the next parallel region.
|
static void |
setRNGSeed(int seed) |
static boolean |
solve(Mat src1,
Mat src2,
Mat dst)
Solves one or more linear systems or least-squares problems.
|
static boolean |
solve(Mat src1,
Mat src2,
Mat dst,
int flags)
Solves one or more linear systems or least-squares problems.
|
static int |
solveCubic(Mat coeffs,
Mat roots)
Finds the real roots of a cubic equation.
|
static double |
solvePoly(Mat coeffs,
Mat roots)
Finds the real or complex roots of a polynomial equation.
|
static double |
solvePoly(Mat coeffs,
Mat roots,
int maxIters)
Finds the real or complex roots of a polynomial equation.
|
static void |
sort(Mat src,
Mat dst,
int flags)
Sorts each row or each column of a matrix.
|
static void |
sortIdx(Mat src,
Mat dst,
int flags)
Sorts each row or each column of a matrix.
|
static void |
split(Mat m,
java.util.List<Mat> mv)
Divides a multi-channel array into several single-channel arrays.
|
static void |
sqrt(Mat src,
Mat dst)
Calculates a square root of array elements.
|
static void |
subtract(Mat src1,
Mat src2,
Mat dst)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static void |
subtract(Mat src1,
Mat src2,
Mat dst,
Mat mask)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static void |
subtract(Mat src1,
Mat src2,
Mat dst,
Mat mask,
int dtype)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static void |
subtract(Mat src1,
Scalar src2,
Mat dst)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static void |
subtract(Mat src1,
Scalar src2,
Mat dst,
Mat mask)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static void |
subtract(Mat src1,
Scalar src2,
Mat dst,
Mat mask,
int dtype)
Calculates the per-element difference between two arrays or array and a
scalar.
|
static Scalar |
sumElems(Mat src)
Calculates the sum of array elements.
|
static void |
SVBackSubst(Mat w,
Mat u,
Mat vt,
Mat rhs,
Mat dst) |
static void |
SVDecomp(Mat src,
Mat w,
Mat u,
Mat vt) |
static void |
SVDecomp(Mat src,
Mat w,
Mat u,
Mat vt,
int flags) |
static Scalar |
trace(Mat mtx)
Returns the trace of a matrix.
|
static void |
transform(Mat src,
Mat dst,
Mat m)
Performs the matrix transformation of every array element.
|
static void |
transpose(Mat src,
Mat dst)
Transposes a matrix.
|
static void |
vconcat(java.util.List<Mat> src,
Mat dst) |
public static final int CMP_EQ
public static final int CMP_GE
public static final int CMP_GT
public static final int CMP_LE
public static final int CMP_LT
public static final int CMP_NE
public static final int COVAR_COLS
public static final int COVAR_NORMAL
public static final int COVAR_ROWS
public static final int COVAR_SCALE
public static final int COVAR_SCRAMBLED
public static final int COVAR_USE_AVG
public static final int DCT_INVERSE
public static final int DCT_ROWS
public static final int DECOMP_CHOLESKY
public static final int DECOMP_EIG
public static final int DECOMP_LU
public static final int DECOMP_NORMAL
public static final int DECOMP_QR
public static final int DECOMP_SVD
public static final int DEPTH_MASK
public static final int DEPTH_MASK_16S
public static final int DEPTH_MASK_16U
public static final int DEPTH_MASK_32F
public static final int DEPTH_MASK_32S
public static final int DEPTH_MASK_64F
public static final int DEPTH_MASK_8S
public static final int DEPTH_MASK_8U
public static final int DEPTH_MASK_ALL
public static final int DEPTH_MASK_ALL_BUT_8S
public static final int DEPTH_MASK_FLT
public static final int DFT_COMPLEX_OUTPUT
public static final int DFT_INVERSE
public static final int DFT_REAL_OUTPUT
public static final int DFT_ROWS
public static final int DFT_SCALE
public static final int FILLED
public static final int FONT_HERSHEY_COMPLEX
public static final int FONT_HERSHEY_COMPLEX_SMALL
public static final int FONT_HERSHEY_DUPLEX
public static final int FONT_HERSHEY_PLAIN
public static final int FONT_HERSHEY_SCRIPT_COMPLEX
public static final int FONT_HERSHEY_SCRIPT_SIMPLEX
public static final int FONT_HERSHEY_SIMPLEX
public static final int FONT_HERSHEY_TRIPLEX
public static final int FONT_ITALIC
public static final int GEMM_1_T
public static final int GEMM_2_T
public static final int GEMM_3_T
public static final int KMEANS_PP_CENTERS
public static final int KMEANS_RANDOM_CENTERS
public static final int KMEANS_USE_INITIAL_LABELS
public static final int LINE_4
public static final int LINE_8
public static final int LINE_AA
public static final int MAGIC_MASK
public static final int MARKER_CROSS
public static final int MARKER_DIAMOND
public static final int MARKER_SQUARE
public static final int MARKER_STAR
public static final int MARKER_TILTED_CROSS
public static final int MARKER_TRIANGLE_DOWN
public static final int MARKER_TRIANGLE_UP
public static final java.lang.String NATIVE_LIBRARY_NAME
public static final int NORM_HAMMING
public static final int NORM_HAMMING2
public static final int NORM_INF
public static final int NORM_L1
public static final int NORM_L2
public static final int NORM_L2SQR
public static final int NORM_MINMAX
public static final int NORM_RELATIVE
public static final int NORM_TYPE_MASK
public static final int REDUCE_AVG
public static final int REDUCE_MAX
public static final int REDUCE_MIN
public static final int REDUCE_SUM
public static final int SORT_ASCENDING
public static final int SORT_DESCENDING
public static final int SORT_EVERY_COLUMN
public static final int SORT_EVERY_ROW
public static final int SVD_FULL_UV
public static final int SVD_MODIFY_A
public static final int SVD_NO_UV
public static final int TYPE_MASK
public static final java.lang.String VERSION
public static final int VERSION_EPOCH
public static final int VERSION_MAJOR
public static final int VERSION_MINOR
public static final int VERSION_REVISION
public static void absdiff(Mat src1, Mat src2, Mat dst)
Calculates the per-element absolute difference between two arrays or between an array and a scalar.
The function absdiff
calculates:
dst(I) = saturate(| src1(I) - src2(I)|)
Scalar
or has as many elements as the
number of channels in src1
:
dst(I) = saturate(| src1(I) - src2|)
Scalar
or has as many elements as the number
of channels in src2
:
dst(I) = saturate(| src1 - src2(I)|)
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
Note: Saturation is not applied when the arrays have the depth
CV_32S
. You may even get a negative value in the case of
overflow.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as input arrays.public static void absdiff(Mat src1, Scalar src2, Mat dst)
Calculates the per-element absolute difference between two arrays or between an array and a scalar.
The function absdiff
calculates:
dst(I) = saturate(| src1(I) - src2(I)|)
Scalar
or has as many elements as the
number of channels in src1
:
dst(I) = saturate(| src1(I) - src2|)
Scalar
or has as many elements as the number
of channels in src2
:
dst(I) = saturate(| src1 - src2(I)|)
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
Note: Saturation is not applied when the arrays have the depth
CV_32S
. You may even get a negative value in the case of
overflow.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as input arrays.public static void add(Mat src1, Mat src2, Mat dst)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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
.addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void add(Mat src1, Mat src2, Mat dst, Mat mask)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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, that
specifies elements of the output array to be changed.addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void add(Mat src1, Mat src2, Mat dst, Mat mask, int dtype)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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, that
specifies elements of the output array to be changed.dtype
- optional depth of the output array (see the discussion below).addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void add(Mat src1, Scalar src2, Mat dst)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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
.addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void add(Mat src1, Scalar src2, Mat dst, Mat mask)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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, that
specifies elements of the output array to be changed.addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void add(Mat src1, Scalar src2, Mat dst, Mat mask, int dtype)
Calculates the per-element sum of two arrays or an array and a scalar.
The function add
calculates:
dst(I) = saturate(src1(I) + src2(I)) if mask(I) != 0
src2
is constructed
from Scalar
or has the same number of elements as
src1.channels()
:
dst(I) = saturate(src1(I) + src2) if mask(I) != 0
src1
is constructed
from Scalar
or has the same number of elements as
src2.channels()
:
dst(I) = saturate(src1 + src2(I)) if mask(I) != 0
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions:
// C++ code:
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
The input arrays and the output array can all have the same or different
depths. For example, you can add a 16-bit unsigned array to a 8-bit signed
array and store the sum as a 32-bit floating-point array. Depth of the output
array is determined by the dtype
parameter. In the second and
third cases above, as well as in the first case, when src1.depth() ==
src2.depth()
, dtype
can be set to the default
-1
. In this case, the output array will have the same depth as
the input array, be it src1
, src2
or both.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array or 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, that
specifies elements of the output array to be changed.dtype
- optional depth of the output array (see the discussion below).addWeighted(org.opencv.core.Mat, double, org.opencv.core.Mat, double, double, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst)
Calculates the weighted sum of two arrays.
The function addWeighted
calculates the weighted sum of two
arrays as follows:
dst(I)= saturate(src1(I)* alpha + src2(I)* beta + gamma)
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The function can be replaced with a matrix expression:
// C++ code:
dst = src1*alpha + src2*beta + gamma;
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.alpha
- weight of the first array elements.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.add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst, int dtype)
Calculates the weighted sum of two arrays.
The function addWeighted
calculates the weighted sum of two
arrays as follows:
dst(I)= saturate(src1(I)* alpha + src2(I)* beta + gamma)
where I
is a multi-dimensional index of array elements. In case
of multi-channel arrays, each channel is processed independently.
The function can be replaced with a matrix expression:
// C++ code:
dst = src1*alpha + src2*beta + gamma;
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.alpha
- weight of the first array elements.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 be set to -1
, which will
be equivalent to src1.depth()
.add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
scaleAdd(org.opencv.core.Mat, double, org.opencv.core.Mat, org.opencv.core.Mat)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
Mat.convertTo(org.opencv.core.Mat, int, double, double)
public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color)
Draws a arrow segment pointing from the first point to the second one.
The function arrowedLine
draws an arrow between pt1
and pt2
points in the image. See also "line".
img
- Image.pt1
- The point the arrow starts from.pt2
- The point the arrow points to.color
- Line color.public static void arrowedLine(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int line_type, int shift, double tipLength)
Draws a arrow segment pointing from the first point to the second one.
The function arrowedLine
draws an arrow between pt1
and pt2
points in the image. See also "line".
img
- Image.pt1
- The point the arrow starts from.pt2
- The point the arrow points to.color
- Line color.thickness
- Line thickness.line_type
- Type of the line:
shift
- Number of fractional bits in the point coordinates.tipLength
- The length of the arrow tip in relation to the arrow lengthpublic static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K)
public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update, boolean crosscheck)
public static void bitwise_and(Mat src1, Mat src2, Mat dst)
Calculates the per-element bit-wise conjunction of two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical conjunction for:
src1
and src2
have the same
size:
dst(I) = src1(I) / src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I) / src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1 / src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the second and third cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.public static void bitwise_and(Mat src1, Mat src2, Mat dst, Mat mask)
Calculates the per-element bit-wise conjunction of two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical conjunction for:
src1
and src2
have the same
size:
dst(I) = src1(I) / src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I) / src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1 / src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the second and third cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.mask
- optional operation mask, 8-bit single channel array, that
specifies elements of the output array to be changed.public static void bitwise_not(Mat src, Mat dst)
Inverts every bit of an array.
The function calculates per-element bit-wise inversion of the input array:
dst(I) = !src(I)
In case of a floating-point input array, its machine-specific bit representation (usually IEEE754-compliant) is used for the operation. In case of multi-channel arrays, each channel is processed independently.
src
- input array.dst
- output array that has the same size and type as the input array.public static void bitwise_not(Mat src, Mat dst, Mat mask)
Inverts every bit of an array.
The function calculates per-element bit-wise inversion of the input array:
dst(I) = !src(I)
In case of a floating-point input array, its machine-specific bit representation (usually IEEE754-compliant) is used for the operation. In case of multi-channel arrays, each channel is processed independently.
src
- input array.dst
- output array that has the same size and type as the input array.mask
- optional operation mask, 8-bit single channel array, that
specifies elements of the output array to be changed.public static void bitwise_or(Mat src1, Mat src2, Mat dst)
Calculates the per-element bit-wise disjunction of two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical disjunction for:
src1
and src2
have the same
size:
dst(I) = src1(I) V src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I) V src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1 V src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the second and third cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.public static void bitwise_or(Mat src1, Mat src2, Mat dst, Mat mask)
Calculates the per-element bit-wise disjunction of two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical disjunction for:
src1
and src2
have the same
size:
dst(I) = src1(I) V src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I) V src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1 V src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the second and third cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.mask
- optional operation mask, 8-bit single channel array, that
specifies elements of the output array to be changed.public static void bitwise_xor(Mat src1, Mat src2, Mat dst)
Calculates the per-element bit-wise "exclusive or" operation on two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical "exclusive-or" operation for:
src1
and src2
have the same
size:
dst(I) = src1(I)(+) src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I)(+) src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1(+) src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the 2nd and 3rd cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.public static void bitwise_xor(Mat src1, Mat src2, Mat dst, Mat mask)
Calculates the per-element bit-wise "exclusive or" operation on two arrays or an array and a scalar.
The function calculates the per-element bit-wise logical "exclusive-or" operation for:
src1
and src2
have the same
size:
dst(I) = src1(I)(+) src2(I) if mask(I) != 0
src2
is constructed from
Scalar
or has the same number of elements as src1.channels()
:
dst(I) = src1(I)(+) src2 if mask(I) != 0
src1
is constructed from
Scalar
or has the same number of elements as src2.channels()
:
dst(I) = src1(+) src2(I) if mask(I) != 0
In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the 2nd and 3rd cases above, the scalar is first converted to the array type.
src1
- first input array or a scalar.src2
- second input array or a scalar.dst
- output array that has the same size and type as the input arrays.mask
- optional operation mask, 8-bit single channel array, that
specifies elements of the output array to be changed.public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags)
Calculates the covariance matrix of a set of vectors.
The functions calcCovarMatrix
calculate the covariance matrix
and, optionally, the mean vector of the set of input vectors.
samples
- samples stored either as separate matrices or 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 the following values:
scale * [ vects [0]- mean, vects [1]- mean,...]^T * [ vects [0]- mean, vects [1]- mean,...],
The covariance matrix will be nsamples x nsamples
. Such an
unusual covariance matrix is used for fast PCA of a set of very large vectors
(see, for example, the EigenFaces technique for face recognition).
Eigenvalues of this "scrambled" matrix match the eigenvalues of the true
covariance matrix. The "true" eigenvectors can be easily calculated from the
eigenvectors of the "scrambled" covariance matrix.
scale * [ vects [0]- mean, vects [1]- mean,...] * [ vects [0]- mean, vects [1]- mean,...]^T,
covar
will be a square matrix of the same size as the total
number of elements in each input vector. One and only one of
CV_COVAR_SCRAMBLED
and CV_COVAR_NORMAL
must be
specified.
mean
from the input vectors but, instead, uses the
passed mean
vector. This is useful if mean
has been
pre-calculated or known in advance, or if the covariance matrix is calculated
by parts. In this case, mean
is not a mean vector of the input
sub-set of vectors but rather the mean vector of the whole set.
scale
is 1./nsamples
.
In the "scrambled" mode, scale
is the reciprocal of the total
number of elements in each input vector. By default (if the flag is not
specified), the covariance matrix is not scaled (scale=1
).
samples
matrix. mean
should be a single-row vector
in this case.
samples
matrix. mean
should be a single-column
vector in this case.
Mahalanobis(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
mulTransposed(org.opencv.core.Mat, org.opencv.core.Mat, boolean, org.opencv.core.Mat, double, int)
public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags, int ctype)
Calculates the covariance matrix of a set of vectors.
The functions calcCovarMatrix
calculate the covariance matrix
and, optionally, the mean vector of the set of input vectors.
samples
- samples stored either as separate matrices or 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 the following values:
scale * [ vects [0]- mean, vects [1]- mean,...]^T * [ vects [0]- mean, vects [1]- mean,...],
The covariance matrix will be nsamples x nsamples
. Such an
unusual covariance matrix is used for fast PCA of a set of very large vectors
(see, for example, the EigenFaces technique for face recognition).
Eigenvalues of this "scrambled" matrix match the eigenvalues of the true
covariance matrix. The "true" eigenvectors can be easily calculated from the
eigenvectors of the "scrambled" covariance matrix.
scale * [ vects [0]- mean, vects [1]- mean,...] * [ vects [0]- mean, vects [1]- mean,...]^T,
covar
will be a square matrix of the same size as the total
number of elements in each input vector. One and only one of
CV_COVAR_SCRAMBLED
and CV_COVAR_NORMAL
must be
specified.
mean
from the input vectors but, instead, uses the
passed mean
vector. This is useful if mean
has been
pre-calculated or known in advance, or if the covariance matrix is calculated
by parts. In this case, mean
is not a mean vector of the input
sub-set of vectors but rather the mean vector of the whole set.
scale
is 1./nsamples
.
In the "scrambled" mode, scale
is the reciprocal of the total
number of elements in each input vector. By default (if the flag is not
specified), the covariance matrix is not scaled (scale=1
).
samples
matrix. mean
should be a single-row vector
in this case.
samples
matrix. mean
should be a single-column
vector in this case.
ctype
- type of the matrixl; it equals 'CV_64F' by default.Mahalanobis(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
mulTransposed(org.opencv.core.Mat, org.opencv.core.Mat, boolean, org.opencv.core.Mat, double, int)
public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle)
Calculates the magnitude and angle of 2D vectors.
The function cartToPolar
calculates either the magnitude, angle,
or both for every 2D vector (x(I),y(I)):
magnitude(I)= sqrt(x(I)^2+y(I)^2), angle(I)= atan2(y(I), x(I))[ *180 / pi ]
The angles are calculated with accuracy about 0.3 degrees. For the point (0,0), the angle is set to 0.
x
- array of x-coordinates; this must be a single-precision or
double-precision floating-point array.y
- array of y-coordinates, that must have the same size and same type
as x
.magnitude
- output array of magnitudes of the same size and type as
x
.angle
- output array of angles that has the same size and type as
x
; the angles are measured in radians (from 0 to 2*Pi) or in
degrees (0 to 360 degrees).Imgproc.Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int)
,
Imgproc.Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int)
public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle, boolean angleInDegrees)
Calculates the magnitude and angle of 2D vectors.
The function cartToPolar
calculates either the magnitude, angle,
or both for every 2D vector (x(I),y(I)):
magnitude(I)= sqrt(x(I)^2+y(I)^2), angle(I)= atan2(y(I), x(I))[ *180 / pi ]
The angles are calculated with accuracy about 0.3 degrees. For the point (0,0), the angle is set to 0.
x
- array of x-coordinates; this must be a single-precision or
double-precision floating-point array.y
- array of y-coordinates, that must have the same size and same type
as x
.magnitude
- output array of magnitudes of the same size and type as
x
.angle
- output array of angles that has the same size and type as
x
; the angles are measured in radians (from 0 to 2*Pi) or in
degrees (0 to 360 degrees).angleInDegrees
- a flag, indicating whether the angles are measured in
radians (which is by default), or in degrees.Imgproc.Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int)
,
Imgproc.Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int)
public static boolean checkRange(Mat a)
Checks every element of an input array for invalid values.
The functions checkRange
check that every array element is
neither NaN nor infinite. When minVal < -DBL_MAX
and
maxVal < DBL_MAX
, the functions also check that each value is
between minVal
and maxVal
. In case of multi-channel
arrays, each channel is processed independently.
If some values are out of range, position of the first outlier is stored in
pos
(when pos != NULL
). Then, the functions either
return false (when quiet=true
) or throw an exception.
a
- input array.public static boolean checkRange(Mat a, boolean quiet, double minVal, double maxVal)
Checks every element of an input array for invalid values.
The functions checkRange
check that every array element is
neither NaN nor infinite. When minVal < -DBL_MAX
and
maxVal < DBL_MAX
, the functions also check that each value is
between minVal
and maxVal
. In case of multi-channel
arrays, each channel is processed independently.
If some values are out of range, position of the first outlier is stored in
pos
(when pos != NULL
). Then, the functions either
return false (when quiet=true
) or throw an exception.
a
- input array.quiet
- a flag, indicating whether the functions quietly return false
when the array elements are out of range or they throw an exception.minVal
- inclusive lower boundary of valid values range.maxVal
- exclusive upper boundary of valid values range.public static void circle(Mat img, Point center, int radius, Scalar color)
Draws a circle.
The function circle
draws a simple or filled circle with a given
center and radius.
img
- Image where the circle is drawn.center
- Center of the circle.radius
- Radius of the circle.color
- Circle color.public static void circle(Mat img, Point center, int radius, Scalar color, int thickness)
Draws a circle.
The function circle
draws a simple or filled circle with a given
center and radius.
img
- Image where the circle is drawn.center
- Center of the circle.radius
- Radius of the circle.color
- Circle color.thickness
- Thickness of the circle outline, if positive. Negative
thickness means that a filled circle is to be drawn.public static void circle(Mat img, Point center, int radius, Scalar color, int thickness, int lineType, int shift)
Draws a circle.
The function circle
draws a simple or filled circle with a given
center and radius.
img
- Image where the circle is drawn.center
- Center of the circle.radius
- Radius of the circle.color
- Circle color.thickness
- Thickness of the circle outline, if positive. Negative
thickness means that a filled circle is to be drawn.lineType
- Type of the circle boundary. See the "line" description.shift
- Number of fractional bits in the coordinates of the center and
in the radius value.public static boolean clipLine(Rect imgRect, Point pt1, Point pt2)
Clips the line against the image rectangle.
The functions clipLine
calculate a part of the line segment that
is entirely within the specified rectangle.
They return false
if the line segment is completely outside the
rectangle. Otherwise, they return true
.
imgRect
- Image rectangle.pt1
- First line point.pt2
- Second line point.public static void compare(Mat src1, Mat src2, Mat dst, int cmpop)
Performs the per-element comparison of two arrays or an array and scalar value.
The function compares:
src1
and src2
have the same size:
dst(I) = src1(I) cmpop src2(I)
src1
with a scalar src2
when
src2
is constructed from Scalar
or has a single
element:
dst(I) = src1(I) cmpop src2
src1
with elements of src2
when
src1
is constructed from Scalar
or has a single
element:
dst(I) = src1 cmpop src2(I)
When the comparison result is true, the corresponding element of output array
is set to 255.The comparison operations can be replaced with the equivalent
matrix expressions:
// C++ code:
Mat dst1 = src1 >= src2;
Mat dst2 = src1 < 8;...
src1
- first input array or a scalar (in the case of cvCmp
,
cv.Cmp
, cvCmpS
, cv.CmpS
it is always
an array); when it is an array, it must have a single channel.src2
- second input array or a scalar (in the case of cvCmp
and cv.Cmp
it is always an array; in the case of
cvCmpS
, cv.CmpS
it is always a scalar); when it is
an array, it must have a single channel.dst
- output array that has the same size and type as the input arrays.cmpop
- a flag, that specifies correspondence between the arrays:
src1
is equal to src2
.
src1
is greater than src2
.
src1
is greater than or equal to src2
.
src1
is less than src2
.
src1
is less than or equal to src2
.
src1
is unequal to src2
.
Imgproc.threshold(org.opencv.core.Mat, org.opencv.core.Mat, double, double, int)
,
max(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
checkRange(org.opencv.core.Mat, boolean, double, double)
,
min(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static void compare(Mat src1, Scalar src2, Mat dst, int cmpop)
Performs the per-element comparison of two arrays or an array and scalar value.
The function compares:
src1
and src2
have the same size:
dst(I) = src1(I) cmpop src2(I)
src1
with a scalar src2
when
src2
is constructed from Scalar
or has a single
element:
dst(I) = src1(I) cmpop src2
src1
with elements of src2
when
src1
is constructed from Scalar
or has a single
element:
dst(I) = src1 cmpop src2(I)
When the comparison result is true, the corresponding element of output array
is set to 255.The comparison operations can be replaced with the equivalent
matrix expressions:
// C++ code:
Mat dst1 = src1 >= src2;
Mat dst2 = src1 < 8;...
src1
- first input array or a scalar (in the case of cvCmp
,
cv.Cmp
, cvCmpS
, cv.CmpS
it is always
an array); when it is an array, it must have a single channel.src2
- second input array or a scalar (in the case of cvCmp
and cv.Cmp
it is always an array; in the case of
cvCmpS
, cv.CmpS
it is always a scalar); when it is
an array, it must have a single channel.dst
- output array that has the same size and type as the input arrays.cmpop
- a flag, that specifies correspondence between the arrays:
src1
is equal to src2
.
src1
is greater than src2
.
src1
is greater than or equal to src2
.
src1
is less than src2
.
src1
is less than or equal to src2
.
src1
is unequal to src2
.
Imgproc.threshold(org.opencv.core.Mat, org.opencv.core.Mat, double, double, int)
,
max(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
checkRange(org.opencv.core.Mat, boolean, double, double)
,
min(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static void completeSymm(Mat mtx)
Copies the lower or the upper half of a square matrix to another half.
The function completeSymm
copies the lower half of a square
matrix to its another half. The matrix diagonal remains unchanged:
lowerToUpper=false
lowerToUpper=true
mtx
- input-output floating-point square matrix.transpose(org.opencv.core.Mat, org.opencv.core.Mat)
,
flip(org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void completeSymm(Mat mtx, boolean lowerToUpper)
Copies the lower or the upper half of a square matrix to another half.
The function completeSymm
copies the lower half of a square
matrix to its another half. The matrix diagonal remains unchanged:
lowerToUpper=false
lowerToUpper=true
mtx
- input-output floating-point square matrix.lowerToUpper
- operation flag; if true, the lower half is copied to the
upper half. Otherwise, the upper half is copied to the lower half.transpose(org.opencv.core.Mat, org.opencv.core.Mat)
,
flip(org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void convertScaleAbs(Mat src, Mat dst)
Scales, calculates absolute values, and converts the result to 8-bit.
On each element of the input array, the function convertScaleAbs
performs three operations sequentially: scaling, taking an absolute value,
conversion to an unsigned 8-bit type:
dst(I)= saturate_cast<uchar>(| src(I)* alpha + beta|)<BR>In case
of multi-channel arrays, the function processes each channel independently.
When the output is not 8-bit, the operation can be emulated by calling the
Mat.convertTo
method(or by using matrix expressions) and then
by calculating an absolute value of the result. For example:
<BR><code>
// C++ code:
Mat_
randu(A, Scalar(-100), Scalar(100));
Mat_
B = abs(B);
// Mat_
// but it will allocate a temporary matrix
src
- input array.dst
- output array.Mat.convertTo(org.opencv.core.Mat, int, double, double)
public static void convertScaleAbs(Mat src, Mat dst, double alpha, double beta)
Scales, calculates absolute values, and converts the result to 8-bit.
On each element of the input array, the function convertScaleAbs
performs three operations sequentially: scaling, taking an absolute value,
conversion to an unsigned 8-bit type:
dst(I)= saturate_cast<uchar>(| src(I)* alpha + beta|)<BR>In case
of multi-channel arrays, the function processes each channel independently.
When the output is not 8-bit, the operation can be emulated by calling the
Mat.convertTo
method(or by using matrix expressions) and then
by calculating an absolute value of the result. For example:
<BR><code>
// C++ code:
Mat_
randu(A, Scalar(-100), Scalar(100));
Mat_
B = abs(B);
// Mat_
// but it will allocate a temporary matrix
src
- input array.dst
- output array.alpha
- optional scale factor.beta
- optional delta added to the scaled values.Mat.convertTo(org.opencv.core.Mat, int, double, double)
public static int countNonZero(Mat src)
Counts non-zero array elements.
The function returns the number of non-zero elements in src
:
sum(by: I: src(I) != 0) 1
src
- single-channel array.minMaxLoc(org.opencv.core.Mat, org.opencv.core.Mat)
,
calcCovarMatrix(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
meanStdDev(org.opencv.core.Mat, org.opencv.core.MatOfDouble, org.opencv.core.MatOfDouble, org.opencv.core.Mat)
,
norm(org.opencv.core.Mat, int, org.opencv.core.Mat)
,
mean(org.opencv.core.Mat, org.opencv.core.Mat)
public static float cubeRoot(float val)
Computes the cube root of an argument.
The function cubeRoot
computes sqrt3(val). Negative
arguments are handled correctly. NaN and Inf are not handled. The accuracy
approaches the maximum possible accuracy for single-precision data.
val
- A function argument.public static void dct(Mat src, Mat dst)
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
The function dct
performs a forward or inverse discrete Cosine
transform (DCT) of a 1D or 2D floating-point array:
N
elements:
Y = C^N * X
where
C^N_(jk)= sqrt(alpha_j/N) cos((pi(2k+1)j)/(2N))
and
alpha_0=1, alpha_j=2 for *j > 0*.
N
elements:
X = (C^N)^(-1) * Y = (C^N)^T * Y
(since C^N is an orthogonal matrix, C^N * (C^N)^T = I)
M x N
matrix:
Y = C^N * X * (C^N)^T
M x N
matrix:
X = (C^N)^T * X * C^N
The function chooses the mode of operation by looking at the flags and size of the input array:
(flags & DCT_INVERSE) == 0
, the function does a
forward 1D or 2D transform. Otherwise, it is an inverse 1D or 2D transform.
(flags & DCT_ROWS) != 0
, the function performs a 1D
transform of each row.
Note:
Currently dct
supports even-size arrays (2, 4, 6...). For data
analysis and approximation, you can pad the array when necessary.
Also, the function performance depends very much, and not monotonically, on
the array size (see"getOptimalDFTSize"). In the current implementation DCT of
a vector of size N
is calculated via DFT of a vector of size
N/2
. Thus, the optimal DCT size N1 >= N
can be
calculated as:
// C++ code:
size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
N1 = getOptimalDCTSize(N);
src
- input floating-point array.dst
- output array of the same size and type as src
.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
idct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
public static void dct(Mat src, Mat dst, int flags)
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
The function dct
performs a forward or inverse discrete Cosine
transform (DCT) of a 1D or 2D floating-point array:
N
elements:
Y = C^N * X
where
C^N_(jk)= sqrt(alpha_j/N) cos((pi(2k+1)j)/(2N))
and
alpha_0=1, alpha_j=2 for *j > 0*.
N
elements:
X = (C^N)^(-1) * Y = (C^N)^T * Y
(since C^N is an orthogonal matrix, C^N * (C^N)^T = I)
M x N
matrix:
Y = C^N * X * (C^N)^T
M x N
matrix:
X = (C^N)^T * X * C^N
The function chooses the mode of operation by looking at the flags and size of the input array:
(flags & DCT_INVERSE) == 0
, the function does a
forward 1D or 2D transform. Otherwise, it is an inverse 1D or 2D transform.
(flags & DCT_ROWS) != 0
, the function performs a 1D
transform of each row.
Note:
Currently dct
supports even-size arrays (2, 4, 6...). For data
analysis and approximation, you can pad the array when necessary.
Also, the function performance depends very much, and not monotonically, on
the array size (see"getOptimalDFTSize"). In the current implementation DCT of
a vector of size N
is calculated via DFT of a vector of size
N/2
. Thus, the optimal DCT size N1 >= N
can be
calculated as:
// C++ code:
size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
N1 = getOptimalDCTSize(N);
src
- input floating-point array.dst
- output array of the same size and type as src
.flags
- transformation flags as a combination of the following values:
dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
idct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
public static double determinant(Mat mtx)
Returns the determinant of a square floating-point matrix.
The function determinant
calculates and returns the determinant
of the specified matrix. For small matrices (mtx.cols=mtx.rows<=3
),
the direct method is used. For larger matrices, the function uses LU
factorization with partial pivoting.
For symmetric positively-determined matrices, it is also possible to use "eigen" decomposition to calculate the determinant.
mtx
- input matrix that must have CV_32FC1
or
CV_64FC1
type and square size.invert(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
solve(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
eigen(org.opencv.core.Mat, boolean, org.opencv.core.Mat, org.opencv.core.Mat)
,
trace(org.opencv.core.Mat)
public static void dft(Mat src, Mat dst)
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
The function performs one of the following:
N
elements:
Y = F^N * X,
where F^N_(jk)=exp(-2pi i j k/N) and i=sqrt(-1)
N
elements:
X'= (F^N)^(-1) * Y = (F^N)^* * y X = (1/N) * X,
where F^*=(Re(F^N)-Im(F^N))^T
M x N
matrix:
Y = F^M * X * F^N
M x N
matrix:
X'= (F^M)^* * Y * (F^N)^* X = 1/(M * N) * X'
In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input spectrum of the inverse Fourier transform can be represented in a packed format called *CCS* (complex-conjugate-symmetrical). It was borrowed from IPL (Intel* Image Processing Library). Here is how 2D *CCS* spectrum looks:
Re Y_(0,0) Re Y_(0,1) Im Y_(0,1) Re Y_(0,2) Im Y_(0,2) *s 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) *s 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) *s Re Y_(2,N/2-1) Im Y_(2,N/2-1) Im Y_(1,N/2)........................... Re Y_(M/2-1,0) Re Y_(M-3,1) Im Y_(M-3,1)......... 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)......... 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)......... Re Y_(M-1,N/2-1) Im Y_(M-1,N/2-1) Re Y_(M/2,N/2)
In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
So, the function chooses an operation mode depending on the flags and size of the input array:
DFT_ROWS
is set or the input array has a single row or
single column, the function performs a 1D forward or inverse transform of
each row of a matrix when DFT_ROWS
is set. Otherwise, it
performs a 2D transform.
DFT_INVERSE
is not set,
the function performs a forward 1D or 2D transform:
DFT_COMPLEX_OUTPUT
is set, the output is a complex
matrix of the same size as input.
DFT_COMPLEX_OUTPUT
is not set, the output is a real
matrix of the same size as input. In case of 2D transform, it uses the packed
format as shown above. In case of a single 1D transform, it looks like the
first row of the matrix above. In case of multiple 1D transforms (when using
the DFT_ROWS
flag), each row of the output matrix looks like the
first row of the matrix above.
DFT_INVERSE
or
DFT_REAL_OUTPUT
are not set, the output is a complex array of
the same size as input. The function performs a forward or inverse 1D or 2D
transform of the whole input array or each row of the input array
independently, depending on the flags DFT_INVERSE
and
DFT_ROWS
.
DFT_INVERSE
is set and the input array is real, or
it is complex but DFT_REAL_OUTPUT
is set, the output is a real
array of the same size as input. The function performs a 1D or 2D inverse
transformation of the whole input array or each individual row, depending on
the flags DFT_INVERSE
and DFT_ROWS
.
If DFT_SCALE
is set, the scaling is done after the
transformation.
Unlike "dct", the function supports arrays of arbitrary size. But only those
arrays are processed efficiently, whose sizes can be factorized in a product
of small prime numbers (2, 3, and 5 in the current implementation). Such an
efficient DFT size can be calculated using the "getOptimalDFTSize" method.
The sample below illustrates how to calculate a DFT-based convolution of two
2D real arrays:
// C++ code:
void convolveDFT(InputArray A, InputArray B, OutputArray C)
// reallocate the output array if needed
C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
Size dftSize;
// calculate the size of DFT transform
dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
// allocate temporary buffers and initialize them with 0's
Mat tempA(dftSize, A.type(), Scalar.all(0));
Mat tempB(dftSize, B.type(), Scalar.all(0));
// copy A and B to the top-left corners of tempA and tempB, respectively
Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
A.copyTo(roiA);
Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
B.copyTo(roiB);
// now transform the padded A & B in-place;
// use "nonzeroRows" hint for faster processing
dft(tempA, tempA, 0, A.rows);
dft(tempB, tempB, 0, B.rows);
// multiply the spectrums;
// the function handles packed spectrum representations well
mulSpectrums(tempA, tempB, tempA);
// transform the product back from the frequency domain.
// Even though all the result rows will be non-zero,
// you need only the first C.rows of them, and thus you
// pass nonzeroRows == C.rows
dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
// now copy the result back to C.
tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
// all the temporary buffers will be deallocated automatically
To optimize this sample, consider the following approaches:
nonzeroRows != 0
is passed to the forward transform
calls and since A
and B
are copied to the top-left
corners of tempA
and tempB
, respectively, it is not
necessary to clear the whole tempA
and tempB
. It is
only necessary to clear the tempA.cols - A.cols
(tempB.cols - B.cols
) rightmost columns of the matrices.
B
is significantly smaller than
A
or vice versa. Instead, you can calculate convolution by
parts. To do this, you need to split the output array C
into
multiple tiles. For each tile, estimate which parts of A
and
B
are required to calculate convolution in this tile. If the
tiles in C
are too small, the speed will decrease a lot because
of repeated work. In the ultimate case, when each tile in C
is a
single pixel, the algorithm becomes equivalent to the naive convolution
algorithm. If the tiles are too big, the temporary arrays tempA
and tempB
become too big and there is also a slowdown because of
bad cache locality. So, there is an optimal tile size somewhere in the
middle.
C
can be calculated in parallel
and, thus, the convolution is done by parts, the loop can be threaded.
All of the above improvements have been implemented in "matchTemplate" and
"filter2D". Therefore, by using them, you can get the performance even better
than with the above theoretically optimal implementation. Though, those two
functions actually calculate cross-correlation, not convolution, so you need
to "flip" the second convolution operand B
vertically and
horizontally using "flip".
Note:
src
- input array that could be real or complex.dst
- output array whose size and type depends on the flags
.Imgproc.matchTemplate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean)
,
cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
flip(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
magnitude(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
phase(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
Imgproc.filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)
,
getOptimalDFTSize(int)
public static void dft(Mat src, Mat dst, int flags, int nonzeroRows)
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
The function performs one of the following:
N
elements:
Y = F^N * X,
where F^N_(jk)=exp(-2pi i j k/N) and i=sqrt(-1)
N
elements:
X'= (F^N)^(-1) * Y = (F^N)^* * y X = (1/N) * X,
where F^*=(Re(F^N)-Im(F^N))^T
M x N
matrix:
Y = F^M * X * F^N
M x N
matrix:
X'= (F^M)^* * Y * (F^N)^* X = 1/(M * N) * X'
In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input spectrum of the inverse Fourier transform can be represented in a packed format called *CCS* (complex-conjugate-symmetrical). It was borrowed from IPL (Intel* Image Processing Library). Here is how 2D *CCS* spectrum looks:
Re Y_(0,0) Re Y_(0,1) Im Y_(0,1) Re Y_(0,2) Im Y_(0,2) *s 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) *s 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) *s Re Y_(2,N/2-1) Im Y_(2,N/2-1) Im Y_(1,N/2)........................... Re Y_(M/2-1,0) Re Y_(M-3,1) Im Y_(M-3,1)......... 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)......... 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)......... Re Y_(M-1,N/2-1) Im Y_(M-1,N/2-1) Re Y_(M/2,N/2)
In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
So, the function chooses an operation mode depending on the flags and size of the input array:
DFT_ROWS
is set or the input array has a single row or
single column, the function performs a 1D forward or inverse transform of
each row of a matrix when DFT_ROWS
is set. Otherwise, it
performs a 2D transform.
DFT_INVERSE
is not set,
the function performs a forward 1D or 2D transform:
DFT_COMPLEX_OUTPUT
is set, the output is a complex
matrix of the same size as input.
DFT_COMPLEX_OUTPUT
is not set, the output is a real
matrix of the same size as input. In case of 2D transform, it uses the packed
format as shown above. In case of a single 1D transform, it looks like the
first row of the matrix above. In case of multiple 1D transforms (when using
the DFT_ROWS
flag), each row of the output matrix looks like the
first row of the matrix above.
DFT_INVERSE
or
DFT_REAL_OUTPUT
are not set, the output is a complex array of
the same size as input. The function performs a forward or inverse 1D or 2D
transform of the whole input array or each row of the input array
independently, depending on the flags DFT_INVERSE
and
DFT_ROWS
.
DFT_INVERSE
is set and the input array is real, or
it is complex but DFT_REAL_OUTPUT
is set, the output is a real
array of the same size as input. The function performs a 1D or 2D inverse
transformation of the whole input array or each individual row, depending on
the flags DFT_INVERSE
and DFT_ROWS
.
If DFT_SCALE
is set, the scaling is done after the
transformation.
Unlike "dct", the function supports arrays of arbitrary size. But only those
arrays are processed efficiently, whose sizes can be factorized in a product
of small prime numbers (2, 3, and 5 in the current implementation). Such an
efficient DFT size can be calculated using the "getOptimalDFTSize" method.
The sample below illustrates how to calculate a DFT-based convolution of two
2D real arrays:
// C++ code:
void convolveDFT(InputArray A, InputArray B, OutputArray C)
// reallocate the output array if needed
C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
Size dftSize;
// calculate the size of DFT transform
dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
// allocate temporary buffers and initialize them with 0's
Mat tempA(dftSize, A.type(), Scalar.all(0));
Mat tempB(dftSize, B.type(), Scalar.all(0));
// copy A and B to the top-left corners of tempA and tempB, respectively
Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
A.copyTo(roiA);
Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
B.copyTo(roiB);
// now transform the padded A & B in-place;
// use "nonzeroRows" hint for faster processing
dft(tempA, tempA, 0, A.rows);
dft(tempB, tempB, 0, B.rows);
// multiply the spectrums;
// the function handles packed spectrum representations well
mulSpectrums(tempA, tempB, tempA);
// transform the product back from the frequency domain.
// Even though all the result rows will be non-zero,
// you need only the first C.rows of them, and thus you
// pass nonzeroRows == C.rows
dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
// now copy the result back to C.
tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
// all the temporary buffers will be deallocated automatically
To optimize this sample, consider the following approaches:
nonzeroRows != 0
is passed to the forward transform
calls and since A
and B
are copied to the top-left
corners of tempA
and tempB
, respectively, it is not
necessary to clear the whole tempA
and tempB
. It is
only necessary to clear the tempA.cols - A.cols
(tempB.cols - B.cols
) rightmost columns of the matrices.
B
is significantly smaller than
A
or vice versa. Instead, you can calculate convolution by
parts. To do this, you need to split the output array C
into
multiple tiles. For each tile, estimate which parts of A
and
B
are required to calculate convolution in this tile. If the
tiles in C
are too small, the speed will decrease a lot because
of repeated work. In the ultimate case, when each tile in C
is a
single pixel, the algorithm becomes equivalent to the naive convolution
algorithm. If the tiles are too big, the temporary arrays tempA
and tempB
become too big and there is also a slowdown because of
bad cache locality. So, there is an optimal tile size somewhere in the
middle.
C
can be calculated in parallel
and, thus, the convolution is done by parts, the loop can be threaded.
All of the above improvements have been implemented in "matchTemplate" and
"filter2D". Therefore, by using them, you can get the performance even better
than with the above theoretically optimal implementation. Though, those two
functions actually calculate cross-correlation, not convolution, so you need
to "flip" the second convolution operand B
vertically and
horizontally using "flip".
Note:
src
- input array that could be real or complex.dst
- output array whose size and type depends on the flags
.flags
- transformation flags, representing a combination of the
following values:
DFT_INVERSE
.
DFT_COMPLEX_OUTPUT
flag), the output is a real array; while the function itself does not check
whether the input is symmetrical or not, you can pass the flag and then the
function will assume the symmetry and produce the real output array (note
that when the input is packed into a real array and inverse transformation is
executed, the function treats the input as a packed complex-conjugate
symmetrical array, and the output will also be a real array).
nonzeroRows
- when the parameter is not zero, the function assumes that
only the first nonzeroRows
rows of the input array
(DFT_INVERSE
is not set) or only the first nonzeroRows
of the output array (DFT_INVERSE
is set) contain non-zeros,
thus, the function can handle the rest of the rows more efficiently and save
some time; this technique is very useful for calculating array
cross-correlation or convolution using DFT.Imgproc.matchTemplate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean)
,
cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
flip(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
magnitude(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
phase(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
Imgproc.filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)
,
getOptimalDFTSize(int)
public static void divide(double scale, Mat src2, Mat dst)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
scale
- scalar factor.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(double scale, Mat src2, Mat dst, int dtype)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
scale
- scalar factor.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.dtype
- optional depth of the output array; if -1
,
dst
will have depth src2.depth()
, but in case of an
array-by-array division, you can only pass -1
when
src1.depth()==src2.depth()
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Mat src2, Mat dst)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Mat src2, Mat dst, double scale)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.scale
- scalar factor.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Mat src2, Mat dst, double scale, int dtype)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.scale
- scalar factor.dtype
- optional depth of the output array; if -1
,
dst
will have depth src2.depth()
, but in case of an
array-by-array division, you can only pass -1
when
src1.depth()==src2.depth()
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Scalar src2, Mat dst)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Scalar src2, Mat dst, double scale)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.scale
- scalar factor.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void divide(Mat src1, Scalar src2, Mat dst, double scale, int dtype)
Performs per-element division of two arrays or a scalar by an array.
The functions divide
divide one array by another:
dst(I) = saturate(src1(I)*scale/src2(I))
or a scalar by an array when there is no src1
:
dst(I) = saturate(scale/src2(I))
When src2(I)
is zero, dst(I)
will also be zero.
Different channels of multi-channel arrays are processed independently.
Note: Saturation is not applied when the output array has the depth
CV_32S
. You may even get result of an incorrect sign in the case
of overflow.
src1
- first input array.src2
- second input array of the same size and type as src1
.dst
- output array of the same size and type as src2
.scale
- scalar factor.dtype
- optional depth of the output array; if -1
,
dst
will have depth src2.depth()
, but in case of an
array-by-array division, you can only pass -1
when
src1.depth()==src2.depth()
.multiply(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, double, int)
,
add(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
,
subtract(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static void drawMarker(Mat img, Point position, Scalar color, int markerType, int markerSize, int thickness, int line_type)
public static boolean eigen(Mat src, boolean computeEigenvectors, Mat eigenvalues, Mat eigenvectors)
Calculates eigenvalues and eigenvectors of a symmetric matrix.
The functions eigen
calculate just eigenvalues, or eigenvalues
and eigenvectors of the symmetric matrix src
:
// C++ code:
src*eigenvectors.row(i).t() = eigenvalues.at
Note: in the new and the old interfaces different ordering of eigenvalues and eigenvectors parameters is used.
src
- input matrix that must have CV_32FC1
or
CV_64FC1
type, square size and be symmetrical (src
^"T"
== src
).computeEigenvectors
- a computeEigenvectorseigenvalues
- output vector of eigenvalues of the same type as
src
; the eigenvalues are stored in the descending order.eigenvectors
- output matrix of eigenvectors; it has the same size and
type as src
; the eigenvectors are stored as subsequent matrix
rows, in the same order as the corresponding eigenvalues.completeSymm(org.opencv.core.Mat, boolean)
public static void ellipse(Mat img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.center
- Center of the ellipse.axes
- Half of the size of the ellipse main axes.angle
- Ellipse rotation angle in degrees.startAngle
- Starting angle of the elliptic arc in degrees.endAngle
- Ending angle of the elliptic arc in degrees.color
- Ellipse color.public static void ellipse(Mat img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color, int thickness)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.center
- Center of the ellipse.axes
- Half of the size of the ellipse main axes.angle
- Ellipse rotation angle in degrees.startAngle
- Starting angle of the elliptic arc in degrees.endAngle
- Ending angle of the elliptic arc in degrees.color
- Ellipse color.thickness
- Thickness of the ellipse arc outline, if positive.
Otherwise, this indicates that a filled ellipse sector is to be drawn.public static void ellipse(Mat img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color, int thickness, int lineType, int shift)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.center
- Center of the ellipse.axes
- Half of the size of the ellipse main axes.angle
- Ellipse rotation angle in degrees.startAngle
- Starting angle of the elliptic arc in degrees.endAngle
- Ending angle of the elliptic arc in degrees.color
- Ellipse color.thickness
- Thickness of the ellipse arc outline, if positive.
Otherwise, this indicates that a filled ellipse sector is to be drawn.lineType
- Type of the ellipse boundary. See the "line" description.shift
- Number of fractional bits in the coordinates of the center and
values of axes.public static void ellipse(Mat img, RotatedRect box, Scalar color)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.box
- Alternative ellipse representation via "RotatedRect" or
CvBox2D
. This means that the function draws an ellipse inscribed
in the rotated rectangle.color
- Ellipse color.public static void ellipse(Mat img, RotatedRect box, Scalar color, int thickness)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.box
- Alternative ellipse representation via "RotatedRect" or
CvBox2D
. This means that the function draws an ellipse inscribed
in the rotated rectangle.color
- Ellipse color.thickness
- Thickness of the ellipse arc outline, if positive.
Otherwise, this indicates that a filled ellipse sector is to be drawn.public static void ellipse(Mat img, RotatedRect box, Scalar color, int thickness, int lineType)
Draws a simple or thick elliptic arc or fills an ellipse sector.
The functions ellipse
with less parameters draw an ellipse
outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If
you need more control of the ellipse rendering, you can retrieve the curve
using "ellipse2Poly" and then render it with "polylines" or fill it with
"fillPoly". If you use the first variant of the function and want to draw the
whole ellipse, not an arc, pass startAngle=0
and
endAngle=360
. The figure below explains the meaning of the
parameters.
Figure 1. Parameters of Elliptic Arc
img
- Image.box
- Alternative ellipse representation via "RotatedRect" or
CvBox2D
. This means that the function draws an ellipse inscribed
in the rotated rectangle.color
- Ellipse color.thickness
- Thickness of the ellipse arc outline, if positive.
Otherwise, this indicates that a filled ellipse sector is to be drawn.lineType
- Type of the ellipse boundary. See the "line" description.public static void ellipse2Poly(Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, MatOfPoint pts)
Approximates an elliptic arc with a polyline.
The function ellipse2Poly
computes the vertices of a polyline
that approximates the specified elliptic arc. It is used by "ellipse".
center
- Center of the arc.axes
- Half of the size of the ellipse main axes. See the "ellipse" for
details.angle
- Rotation angle of the ellipse in degrees. See the "ellipse" for
details.arcStart
- Starting angle of the elliptic arc in degrees.arcEnd
- Ending angle of the elliptic arc in degrees.delta
- Angle between the subsequent polyline vertices. It defines the
approximation accuracy.pts
- Output vector of polyline vertices.public static void exp(Mat src, Mat dst)
Calculates the exponent of every array element.
The function exp
calculates the exponent of every element of the
input array:
dst [I] = e^(src(I))
The maximum relative error is about 7e-6
for single-precision
input and less than 1e-10
for double-precision input. Currently,
the function converts denormalized values to zeros on output. Special values
(NaN, Inf) are not handled.
src
- input array.dst
- output array of the same size and type as src
.log(org.opencv.core.Mat, org.opencv.core.Mat)
,
cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
pow(org.opencv.core.Mat, double, org.opencv.core.Mat)
,
sqrt(org.opencv.core.Mat, org.opencv.core.Mat)
,
magnitude(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
polarToCart(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
phase(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)
public static float fastAtan2(float y, float x)
Calculates the angle of a 2D vector in degrees.
The function fastAtan2
calculates the full-range angle of an
input 2D vector. The angle is measured in degrees and varies from 0 to 360
degrees. The accuracy is about 0.3 degrees.
y
- y-coordinate of the vector.x
- x-coordinate of the vector.public static void fillConvexPoly(Mat img, MatOfPoint points, Scalar color)
Fills a convex polygon.
The function fillConvexPoly
draws a filled convex polygon.
This function is much faster than the function fillPoly
. It can
fill not only convex polygons but any monotonic polygon without
self-intersections, that is, a polygon whose contour intersects every
horizontal line (scan line) twice at the most (though, its top-most and/or
the bottom edge could be horizontal).
img
- Image.points
- a pointscolor
- Polygon color.public static void fillConvexPoly(Mat img, MatOfPoint points, Scalar color, int lineType, int shift)
Fills a convex polygon.
The function fillConvexPoly
draws a filled convex polygon.
This function is much faster than the function fillPoly
. It can
fill not only convex polygons but any monotonic polygon without
self-intersections, that is, a polygon whose contour intersects every
horizontal line (scan line) twice at the most (though, its top-most and/or
the bottom edge could be horizontal).
img
- Image.points
- a pointscolor
- Polygon color.lineType
- Type of the polygon boundaries. See the "line" description.shift
- Number of fractional bits in the vertex coordinates.public static void fillPoly(Mat img, java.util.List<MatOfPoint> pts, Scalar color)
Fills the area bounded by one or more polygons.
The function fillPoly
fills an area bounded by several polygonal
contours. The function can fill complex areas, for example, areas with holes,
contours with self-intersections (some of their parts), and so forth.
img
- Image.pts
- Array of polygons where each polygon is represented as an array of
points.color
- Polygon color.public static void fillPoly(Mat img, java.util.List<MatOfPoint> pts, Scalar color, int lineType, int shift, Point offset)
Fills the area bounded by one or more polygons.
The function fillPoly
fills an area bounded by several polygonal
contours. The function can fill complex areas, for example, areas with holes,
contours with self-intersections (some of their parts), and so forth.
img
- Image.pts
- Array of polygons where each polygon is represented as an array of
points.color
- Polygon color.lineType
- Type of the polygon boundaries. See the "line" description.shift
- Number of fractional bits in the vertex coordinates.offset
- Optional offset of all points of the contours.public static void flip(Mat src, Mat dst, int flipCode)
Flips a 2D array around vertical, horizontal, or both axes.
The function flip
flips the array in one of three different ways
(row and column indices are 0-based):
dst _(ij) =<BR> <= ft(<BR> ltBR gtsrc _(src.rows-i-1,j) if flipCode = 0 ltBR gtsrc _(i, src.cols -j-1) if flipCode gt 0 ltBR gtsrc _(src.rows -i-1, src.cols -j-1) if flipCode lt 0 ltBR gt<BR>right.
The example scenarios of using the function are the following:
flipCode == 0
) to switch
between top-left and bottom-left image origin. This is a typical operation in
video processing on Microsoft Windows* OS.
flipCode > 0
).
flipCode < 0
).
flipCode > 0
or
flipCode == 0
).
src
- input array.dst
- output array of the same size and type as src
.flipCode
- a flag to specify how to flip the array; 0 means flipping
around the x-axis and positive value (for example, 1) means flipping around
y-axis. Negative value (for example, -1) means flipping around both axes (see
the discussion below for the formulas).repeat(org.opencv.core.Mat, int, int, org.opencv.core.Mat)
,
transpose(org.opencv.core.Mat, org.opencv.core.Mat)
,
completeSymm(org.opencv.core.Mat, boolean)
public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst)
Performs generalized matrix multiplication.
The function performs generalized matrix multiplication similar to the
gemm
functions in BLAS level 3. For example, gemm(src1,
src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)
corresponds to
dst = alpha * src1 ^T * src2 + beta * src3 ^T<BR>The function can be replaced with a matrix expression. For example, the above call can be replaced with: <BR><code>
// C++ code:
dst = alpha*src1.t()*src2 + beta*src3.t();
src1
- first multiplied input matrix that should have CV_32FC1
,
CV_64FC1
, CV_32FC2
, or CV_64FC2
type.src2
- second multiplied input matrix of the same type as
src1
.alpha
- weight of the matrix product.src3
- third optional delta matrix added to the matrix product; it
should have the same type as src1
and src2
.beta
- weight of src3
.dst
- output matrix; it has the proper size and the same type as input
matrices.mulTransposed(org.opencv.core.Mat, org.opencv.core.Mat, boolean, org.opencv.core.Mat, double, int)
,
transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst, int flags)
Performs generalized matrix multiplication.
The function performs generalized matrix multiplication similar to the
gemm
functions in BLAS level 3. For example, gemm(src1,
src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)
corresponds to
dst = alpha * src1 ^T * src2 + beta * src3 ^T<BR>The function can be replaced with a matrix expression. For example, the above call can be replaced with: <BR><code>
// C++ code:
dst = alpha*src1.t()*src2 + beta*src3.t();
src1
- first multiplied input matrix that should have CV_32FC1
,
CV_64FC1
, CV_32FC2
, or CV_64FC2
type.src2
- second multiplied input matrix of the same type as
src1
.alpha
- weight of the matrix product.src3
- third optional delta matrix added to the matrix product; it
should have the same type as src1
and src2
.beta
- weight of src3
.dst
- output matrix; it has the proper size and the same type as input
matrices.flags
- operation flags:
src1
.
src2
.
src3
.
mulTransposed(org.opencv.core.Mat, org.opencv.core.Mat, boolean, org.opencv.core.Mat, double, int)
,
transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static java.lang.String getBuildInformation()
Returns full configuration time cmake output.
Returned value is raw cmake output including version control system revision, compiler version, compiler flags, enabled modules and third party libraries, etc. Output format depends on target architecture.
public static long getCPUTickCount()
Returns the number of CPU ticks.
The function returns the current number of CPU ticks on some architectures
(such as x86, x64, PowerPC). On other platforms the function is equivalent to
getTickCount
. It can also be used for very accurate time
measurements, as well as for RNG initialization. Note that in case of
multi-CPU systems a thread, from which getCPUTickCount
is
called, can be suspended and resumed at another CPU with its own counter. So,
theoretically (and practically) the subsequent calls to the function do not
necessary return the monotonously increasing values. Also, since a modern CPU
varies the CPU frequency depending on the load, the number of CPU clocks
spent in some code cannot be directly converted to time units. Therefore,
getTickCount
is generally a preferable solution for measuring
execution time.
public static int getNumberOfCPUs()
Returns the number of logical CPUs available for the process.
public static int getNumThreads()
Returns the number of threads used by OpenCV for parallel regions. Always returns 1 if OpenCV is built without threading support.
The exact meaning of return value depends on the threading framework used by OpenCV library:
If there is any tbb.thread_scheduler_init
in user code
conflicting with OpenCV, then function returns default number of threads used
by TBB library.
setNumThreads
with threads >
0
, otherwise returns the number of logical CPUs, available for the
process.
public static int getOptimalDFTSize(int vecsize)
Returns the optimal DFT size for a given vector size.
DFT performance is not a monotonic function of a vector size. Therefore, when you calculate convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to pad the input data with zeros to get a bit larger array that can be transformed much faster than the original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32,...) are the fastest to process. Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5*5*3*2*2) are also processed quite efficiently.
The function getOptimalDFTSize
returns the minimum number
N
that is greater than or equal to vecsize
so that
the DFT of a vector of size N
can be processed efficiently. In
the current implementation N
= 2^"p" * 3^"q" * 5^"r" for some
integer p
, q
, r
.
The function returns a negative number if vecsize
is too large
(very close to INT_MAX
).
While the function cannot be used directly to estimate the optimal vector
size for DCT transform (since the current DCT implementation supports only
even-size vectors), it can be easily processed as getOptimalDFTSize((vecsize+1)/2)*2
.
vecsize
- vector size.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
idct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean)
,
idft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
public static Size getTextSize(java.lang.String text, int fontFace, double fontScale, int thickness, int[] baseLine)
Calculates the width and height of a text string.
The function getTextSize
calculates and returns the size of a
box that contains the specified text.That is, the following code renders some
text, the tight box surrounding it, and the baseline:
// C++ code:
string text = "Funny text inside the box";
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
double fontScale = 2;
int thickness = 3;
Mat img(600, 800, CV_8UC3, Scalar.all(0));
int baseline=0;
Size textSize = getTextSize(text, fontFace,
fontScale, thickness, &baseline);
baseline += thickness;
// center the text
Point textOrg((img.cols - textSize.width)/2,
(img.rows + textSize.height)/2);
// draw the box
rectangle(img, textOrg + Point(0, baseline),
textOrg + Point(textSize.width, -textSize.height),
Scalar(0,0,255));
//... and the baseline first
line(img, textOrg + Point(0, thickness),
textOrg + Point(textSize.width, thickness),
Scalar(0, 0, 255));
// then put the text itself
putText(img, text, textOrg, fontFace, fontScale,
Scalar.all(255), thickness, 8);
text
- Input text string.fontFace
- Font to use. See the "putText" for details.fontScale
- Font scale. See the "putText" for details.thickness
- Thickness of lines used to render the text. See "putText"
for details.baseLine
- Output parameter - y-coordinate of the baseline relative to
the bottom-most text point.public static int getThreadNum()
Returns the index of the currently executed thread within the current parallel region. Always returns 0 if called outside of parallel region.
The exact meaning of the return value depends on the threading framework used by OpenCV library:
public static long getTickCount()
Returns the number of ticks.
The function returns the number of ticks after the certain event (for example, when the machine was turned on). It can be used to initialize "RNG" or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
public static double getTickFrequency()
Returns the number of ticks per second.
The function returns the number of ticks per second.That is, the following
code computes the execution time in seconds:
// C++ code:
double t = (double)getTickCount();
// do something...
t = ((double)getTickCount() - t)/getTickFrequency();
public static void idct(Mat src, Mat dst)
Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
idct(src, dst, flags)
is equivalent to dct(src, dst, flags
| DCT_INVERSE)
.
src
- input floating-point single-channel array.dst
- output array of the same size and type as src
.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
,
idft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
public static void idct(Mat src, Mat dst, int flags)
Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
idct(src, dst, flags)
is equivalent to dct(src, dst, flags
| DCT_INVERSE)
.
src
- input floating-point single-channel array.dst
- output array of the same size and type as src
.flags
- operation flags.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
,
idft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
public static void idft(Mat src, Mat dst)
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
idft(src, dst, flags)
is equivalent to dft(src, dst, flags
| DFT_INVERSE)
.
See "dft" for details.
Note: None of dft
and idft
scales the result by
default. So, you should pass DFT_SCALE
to one of
dft
or idft
explicitly to make these transforms
mutually inverse.
src
- input floating-point real or complex array.dst
- output array whose size and type depend on the flags
.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
,
idct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean)
public static void idft(Mat src, Mat dst, int flags, int nonzeroRows)
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
idft(src, dst, flags)
is equivalent to dft(src, dst, flags
| DFT_INVERSE)
.
See "dft" for details.
Note: None of dft
and idft
scales the result by
default. So, you should pass DFT_SCALE
to one of
dft
or idft
explicitly to make these transforms
mutually inverse.
src
- input floating-point real or complex array.dst
- output array whose size and type depend on the flags
.flags
- operation flags (see "dft").nonzeroRows
- number of dst
rows to process; the rest of
the rows have undefined content (see the convolution sample in "dft"
description.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)
,
dct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
getOptimalDFTSize(int)
,
idct(org.opencv.core.Mat, org.opencv.core.Mat, int)
,
mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean)
public static void inRange(Mat src, Scalar lowerb, Scalar upperb, Mat dst)
Checks if array elements lie between the elements of two other arrays.
The function checks the range as follows:
dst(I)= lowerb(I)_0 <= src(I)_0 <= upperb(I)_0
dst(I)= lowerb(I)_0 <= src(I)_0 <= upperb(I)_0 land lowerb(I)_1 <= src(I)_1 <= upperb(I)_1
That is, dst
(I) is set to 255 (all 1
-bits) if
src
(I) is within the specified 1D, 2D, 3D,... box and 0
otherwise.
When the lower and/or upper boundary parameters are scalars, the indexes
(I)
at lowerb
and upperb
in the above
formulas should be omitted.
src
- first input array.lowerb
- inclusive lower boundary array or a scalar.upperb
- inclusive upper boundary array or a scalar.dst
- output array of the same size as src
and
CV_8U
type.public static double invert(Mat src, Mat dst)
Finds the inverse or pseudo-inverse of a matrix.
The function invert
inverts the matrix src
and
stores the result in dst
.
When the matrix src
is singular or non-square, the function
calculates the pseudo-inverse matrix (the dst
matrix) so that
norm(src*dst - I)
is minimal, where I is an identity matrix.
In case of the DECOMP_LU
method, the function returns non-zero
value if the inverse has been successfully calculated and 0 if
src
is singular.
In case of the DECOMP_SVD
method, the function returns the
inverse condition number of src
(the ratio of the smallest
singular value to the largest singular value) and 0 if src
is
singular. The SVD method calculates a pseudo-inverse matrix if
src
is singular.
Similarly to DECOMP_LU
, the method DECOMP_CHOLESKY
works only with non-singular square matrices that should also be symmetrical
and positively defined. In this case, the function stores the inverted matrix
in dst
and returns non-zero. Otherwise, it returns 0.
src
- input floating-point M x N
matrix.dst
- output matrix of N x M
size and the same type as
src
.solve(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static double invert(Mat src, Mat dst, int flags)
Finds the inverse or pseudo-inverse of a matrix.
The function invert
inverts the matrix src
and
stores the result in dst
.
When the matrix src
is singular or non-square, the function
calculates the pseudo-inverse matrix (the dst
matrix) so that
norm(src*dst - I)
is minimal, where I is an identity matrix.
In case of the DECOMP_LU
method, the function returns non-zero
value if the inverse has been successfully calculated and 0 if
src
is singular.
In case of the DECOMP_SVD
method, the function returns the
inverse condition number of src
(the ratio of the smallest
singular value to the largest singular value) and 0 if src
is
singular. The SVD method calculates a pseudo-inverse matrix if
src
is singular.
Similarly to DECOMP_LU
, the method DECOMP_CHOLESKY
works only with non-singular square matrices that should also be symmetrical
and positively defined. In this case, the function stores the inverted matrix
in dst
and returns non-zero. Otherwise, it returns 0.
src
- input floating-point M x N
matrix.dst
- output matrix of N x M
size and the same type as
src
.flags
- inversion method :
solve(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int)
public static double kmeans(Mat data, int K, Mat bestLabels, TermCriteria criteria, int attempts, int flags)
Finds centers of clusters and groups input samples around the clusters.
The function kmeans
implements a k-means algorithm that finds
the centers of cluster_count
clusters and groups the input
samples around the clusters. As an output, labels_i contains a
0-based cluster index for the sample stored in the i^(th) row of the
samples
matrix.
The function returns the compactness measure that is computed as
sum _i|samples _i - centers _(labels _i)| ^2
after every attempt. The best (minimum) value is chosen and the corresponding
labels and the compactness value are returned by the function.
Basically, you can use only the core of the function, set the number of