title: Releasing Mat images with openCV(.release() and =Mat() doesn't work)
body: <p>I have tried to release a Mat image from my program, however, no matter how I tried it, the same image (result) still appear when I click on the "process button" to process another image (from loading or snapping an image). The old results will always be displayed. </p>
  
  <p>I have to close the whole program, open the next image I want to process and click the "process button" to get the actual result. However, this is not ideal, as I want my program to immediately process the image I load or snap and not having to close the whole program(or rather stop run and click run again)</p>
  
  <p>Most of the results I searched from google suggested these methods:</p>
  
  <pre><code>imagep.release(); //where imagep is the image after going through processing
  imagep=Mat();
  </code></pre>
  
  <p>UPDATE:
  My code is goes something along this line. In my program.h file, the image and image p and declared like this:</p>
  
  <pre><code>class program : public QMainWindow
  {
      Q_OBJECT
  
  public:
      program(QWidget *parent = 0);
      ~program();
      cv::Mat image, imagep; //original image and image processed
  </code></pre>
  
  <p>The coding for the button in the .cpp file goes something like this:</p>
  
  <pre><code>imagep = image.clone();      //also tried: imagep=image, and imagep=image+0 already.
  .
  .
  .
  processing/segmenting steps
  .
  .
  cv::imshow("new image", imagep);
  cvWaitKey(10);
  imagep=Mat();     //also tried cvDestroyWindow("new image"), //imagep.release(); 
  </code></pre>
  
  <p>The setting of the picture of imagep(where I changed the values of the pixels based on results from the image processing. ) is created via: </p>
  
  <pre><code>for (int i=0; i&lt; imagep.rows; ++i)
      {
          for (int j=0; j&lt;imagep.cols; ++j)
      {
          //imagep.at&lt;cv::Vec3b&gt;(i,j)= v_char[i]; Note that this is commented. This method doesn't work, hence the below method. But it doesn't work too.
              Vec3b temp=v_char[i];
          imagep.at&lt;cv::Vec3b&gt;(i,j)[0]=temp[0];
          imagep.at&lt;cv::Vec3b&gt;(i,j)[1]=temp[1];
          imagep.at&lt;cv::Vec3b&gt;(i,j)[2]=temp[2];
  
  
  
      }
  }   
  </code></pre>
  
  <p>However, these methods doesn't work. Any suggestions of how I can release the Mat image?</p>