pow
import { pow } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Raises every array element to a power.
The function cv::pow raises every element of the input array to power :
\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}
So, for a non-integer power exponent, the absolute values of input array elements are used. However, it is possible to get true values for negative values using some extra operations. In the example below, computing the 5th root of array src shows:
Mat mask = src < 0;
pow(src, 1./5, dst);
subtract(Scalar::all(0), dst, dst, mask);
For some values of power, such as integer values, 0.5 and -0.5, specialized faster algorithms are used.
Special values (NaN, Inf) are not handled.
See: sqrt, exp, log, cartToPolar, polarToCart
pow(src: Mat, power: number, dst: Mat): void;srcinput array.
powerexponent of power.
dstOutput destination, filled by the native operation. output array of the same size and type as src.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.