title: Element-wise power using OpenCV
body: <p>I am currently reading <a href="https://books.google.de/books?id=LPm3DQAAQBAJ&amp;pg=PA82&amp;lpg=PA82&amp;dq=iterator%20plane%20opencv&amp;source=bl&amp;ots=2vHrXddfz9&amp;sig=DW0xnwrOJZTz4oi-8WzF487j8qA&amp;hl=de&amp;sa=X&amp;ved=0ahUKEwj85burj6PXAhUQJlAKHUp0B1YQ6AEINzAC#v=onepage&amp;q=iterator%20plane%20opencv&amp;f=false" rel="nofollow noreferrer">this book</a>. The author wrote a code snippet on page 83 in order to (if i understand it correctly) calculate the element-wise power of two matrices. But i think the code doesn't fulfill its purpose because the matrix <code>dst</code> does not contain the element-wise power after the execution. </p>
  
  <p>Here is the original code:</p>
  
  <pre><code>const Mat* arrays[] = { src1, src2, dst, 0 };
  float* ptrs[3];
  
  NAryMatIterator it(arrays, (uchar**)ptrs);
  for( size_t i = 0; i &lt; it.nplanes; i++, ++it )
  {
      for( size_t j = 0; j &lt; it.size; j++ )
      {
          ptrs[2][j] = std::pow(ptrs[0][j], ptrs[1][j]);
      }
  }
  </code></pre>
  
  <p>Since the parameter of the constructor or <code>cv::NAryMatIterator</code> is <code>const cv::Mat **</code>, i think change of values in the matrix <code>dst</code> is not allowed. </p>
  
  <p>I tried to assign <code>ptrs[2][j]</code> back in <code>dst</code> but failed to get the correct indices of <code>dst</code>. My questions are as follows:</p>
  
  <ol>
  <li>Is there a convenient method for the matrix element-wise power, like <code>A .^ B</code> in Matlab?</li>
  <li>Is there a way to use <code>cv::NAryMatIterator</code> to achieve this goal? If no, then what is the most efficient way to implement it?</li>
  </ol>