title: Using OpenCV Mat images with Intel IPP?
body: <p>I've recently started using <a href="http://software.intel.com/en-us/intel-ipp" rel="noreferrer">Intel Performance Primitives (IPP)</a> for image processing. For those who haven't heard of IPP, think of IPP as the analogue of <a href="http://software.intel.com/en-us/intel-mkl" rel="noreferrer">MKL</a> for image processing instead of linear algebra.</p>
  
  <p>I've already implemented a somewhat complicated vision system in OpenCV, and I'd like to swap out some of the OpenCV routines (e.g. convolution and FFT) for faster IPP routines. My OpenCV code always uses the <code>cv::Mat</code> image data structure. However, based on the IPP code samples, it seems that IPP prefers the <a href="http://www.codeforge.com/read/116995/ippiImage.h__html" rel="noreferrer"><code>CIppiImage</code></a> data structure. </p>
  
  <p>My system does several image transformations in OpenCV, then I want to do a couple of things in IPP, then do more work in OpenCV. Here's a naive way to make OpenCV and IPP play nicely together:</p>
  
  <pre><code> cv::Mat = load original image
   use OpenCV to do some work on cv::Mat
   write cv::Mat to file
  
   CIppiImage = read cv::Mat from file //for IPP
   use IPP to do some work on CIppiImage
   write CIppiImage to file
  
   cv::Mat = read CIppiImage from file
   use OpenCV to do more work on cv::Mat
   write final image to file
  </code></pre>
  
  <p>However, this is kind of tedious, and reading/writing files probably adds to the overall execution time.</p>
  
  <hr>
  
  <p>I'm trying to make it more seamless to alternate between OpenCV and IPP in an image processing program. Here are a couple of things that could solve the problem:</p>
  
  <ol>
  <li>Is there a one-liner that would convert a <code>cv::Mat</code> to <code>CIppiImage</code> and vice versa?</li>
  <li>I am pretty familiar with the <code>cv::Mat</code> implementation details, but I don't know much about <code>CIppiImage</code>. Do <code>cv::Mat</code> and <code>CIppiImage</code> have the same data layout? If so, could I do something similar to the following cast? <code>CIppiImage cimg = (CIppiImage)(&amp;myMat.data[0])</code>?</li>
  </ol>