title: Remove noise from a binary image
body: <p>I want to get an image only with the grapes and the three circles (red, green, blue).
  [I need to remove all the smears].
  how can I improve my code for that?</p>
  
  <p>this is my code:</p>
  
  <pre><code>RGB = imread('img_3235.jpg');
  GRAY = rgb2gray(RGB);
  
  threshold = graythresh(GRAY);
  originalImage = im2bw(GRAY, threshold);
  
  originalImage = bwareaopen(originalImage,250);
  
  imshow(originalImage);
  
  CC = bwconncomp(originalImage); %Ibw is my binary image
  stats = regionprops(CC,'pixellist');
  </code></pre>
  
  <p>this is my image (img_3235.jpg).
  <img src="https://i.stack.imgur.com/XUsl0.jpg" alt="enter image description here"></p>
  
  <p>and this is the result of my code:
  <img src="https://i.stack.imgur.com/08YRZ.png" alt="enter image description here"></p>