Function pow

Source
pub fn pow(
    src: &impl ToInputArray,
    power: f64,
    dst: &mut impl ToOutputArray,
) -> Result<()>
Expand description

Raises every array element to a power.

The function cv::pow raises every element of the input array to power : block formula

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.

§Parameters

  • src: input array.
  • power: exponent of power.
  • dst: output array of the same size and type as src.

§See also

sqrt, exp, log, cartToPolar, polarToCart