title: vtk memory management when importing data
body: <p>I am using <code>vtkImageImport</code> to convert from an opencv matrix to <code>vtkImageData</code>.</p>
  
  <pre><code>vtkImageData* convertImage(const cv::Mat&amp; image)
  {
    int width = image.cols;
    int height = image.rows;
    vtkSmartPointer&lt;vtkImageImport&gt; importer = vtkSmartPointer&lt;vtkImageImport&gt;::New();
    importer-&gt;SetDataScalarTypeToUnsignedChar();
    importer-&gt;SetImportVoidPointer(image.data);
    importer-&gt;SetWholeExtent(0,width-1,0, height-1, 0, 0);
    importer-&gt;SetDataExtentToWholeExtent();
    importer-&gt;Update();
    return importer-&gt;GetOutput();
  }
  </code></pre>
  
  <p>I have 2 questions on how pointers and memory are managed when doing this kind of import.</p>
  
  <ol>
  <li>Does the importer create and allocate a new data pointer for the vtkImageData created, so that the vtk image is not affected when the opencv matrix is destroyed.</li>
  <li>Will the returned vtkImageData* still be valid once the importer is destroyed, or should I return a smart pointer to keep the reference counting > 0? My reasoning is that if the importer uses smart pointers for the vtkImageData internally, then the image will be destroyed as the importer is destroyed. VTK examples always use the importer in the same scope as where the data is then used.</li>
  </ol>
  
  <p>Thank you</p>