title: How to perform faster updation of data in my image using matlab?
body: <p>I'm coding an algorithm for lane detection,</p>
  
  <p>This is the skeleton code I've used,</p>
  
  <pre><code>while ~isDone(video)
     currentFrame = getFrame(video);
     .
     . % Do segmentation and lane detection
     .
     figure(1),imshow(currentFrame),hold on
     figure(1),plot( theLinesThatWereDetected );
     pause(.0001); % without pause the plot command wouldn't work like a streamer.
  end
  </code></pre>
  
  <p>This is a video <a href="https://www.youtube.com/watch?v=K881hFCyiQ8" rel="nofollow">https://www.youtube.com/watch?v=K881hFCyiQ8</a> of the simulation, 
  Problem : The output video gets slower and slower after displaying each frame, but as soon as I close the figure window it automatically restarts(as the code's running) and it gets faster(check video). Why is this happening, is there some memory build up that is happening to slow down the plotting? What can I do to fast things up other than manually closing figure window?</p>
  
  <p>I know there is a video.ShapeInserter object available which is faster than the plotting method I've used . The reason I didn't use it is because the changing the thickness of lines in thee video.ShapeInserter object came only in the 2014 release and I'm using 2013 version. I wanted very distinct thick lines for my lane detection.</p>
  
  <p>Kindly give me suggestions.</p>
  
  <p><strong>Edit:</strong> This is the video after applying the edits suggested by Shai. <a href="https://www.youtube.com/watch?v=LJ_may0hkaE&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=LJ_may0hkaE&amp;feature=youtu.be</a></p>