title: Returning cv:Mat pointer to main function
body: <p>I have written a function which belongs to class <code>panoramic_distance</code>. This function is returning array of <code>images/cv:Mat</code> to main function. But I am bit confused how to access the contents of array of images from main function because attached code is giving me segmentation fault when I call <code>cv::imshow</code>.</p>
  
  <pre><code>class panoramic_distance 
  {  
      cv::Mat* breakimageinstrips(cv::Mat image, bool vertical, int no_strips)
      {      
          cv:Mat split_image[6];
          int d_factor;
  
          d_factor=image.cols/3;
          split_image[0] = image(Rect(0,0,d_factor,image.rows));
          split_image[1] = image(Rect(d_factor,0,d_factor,image.rows));
          split_image[2] = image(Rect((2*d_factor),0,d_factor,image.rows));
          std::cout&lt;&lt;"\n Image slip in 3";
          std::cout&lt;&lt;" address = "&lt;&lt;split_image;
          split_images1=split_image;
          std::cout&lt;&lt;" addressss = "&lt;&lt;split_images1;
          return split_images1;
  
  
          return split_image;
      }     
  
  };
  
  int main( int argc, char** argv )
  {
      panoramic_distance p1;
      cv::Mat *images;
      images=p1.breakimageinstrips(t1,1,3);
      std::cout&lt;&lt;" \n"&lt;&lt;images&lt;&lt;std::endl;  
      cv::imshow("This image",*(image));
      return 0;
  }
  </code></pre>
  
  <p>if I commment <code>cv::imshow</code> then it doesnt give segmentation fault and have following output. This means the address of <code>cv:Mat</code> array is transferred to main but I dont know how to access the contents of array.There is nothing wrong with code but problem is how to access <code>cv:Mat</code> array contents in main function.</p>
  
  <p><strong>Output:</strong></p>
  
  <pre>0x47d6ecfa0
  
  Image slip in 3 address = 0x7ffe7d6ecbd0 addressss = 0x7ffe7d6ecbd0
  0x7ffe7d6ecbd0
  
  RUN FINISHED; exit value 0; real time: 10ms; user: 0ms; system: 0ms</pre>