title: How to subtract background from a video in Matlab
body: <p>I am trying to detect potatoes on roller belt. I have created mean background from empty belt images and want to subtract it from each frame of the video and play back but not sure how to achieve this.</p>
  <p>In other words, I would like to do something like this, but with each frame of the video:</p>
  <pre><code>&gt;&gt; Z = imread('mean.jpg');
  &gt;&gt; X = imread('beltpotatoes_1.jpg'); 
  &gt;&gt; C = Z - X;
  &gt;&gt; imshow(C);
  </code></pre>
  <p>My sample data:</p>
  <p>Mean background (mean.jpg): <a href="https://drive.google.com/file/d/0B_M7fjkKw1r3d0o3VHg1dXVFNmc/edit?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B_M7fjkKw1r3d0o3VHg1dXVFNmc/edit?usp=sharing</a></p>
  <p>avi file: <a href="https://drive.google.com/file/d/0B_M7fjkKw1r3a3lhdl91bGFLSjQ/edit?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B_M7fjkKw1r3a3lhdl91bGFLSjQ/edit?usp=sharing</a></p>
  <p>belt with potatoes image (beltpotatoes_1.jpg): <a href="https://drive.google.com/file/d/0B_M7fjkKw1r3SURDV19ud1VBQjQ/edit?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B_M7fjkKw1r3SURDV19ud1VBQjQ/edit?usp=sharing</a></p>