title: How can I draw a circle on an image in MATLAB?
body: <p>I have an image in MATLAB:</p>
  
  <pre><code>im = rgb2gray(imread('some_image.jpg');
  % normalize the image to be between 0 and 1
  im = im/max(max(im));
  </code></pre>
  
  <p>And I've done some processing that resulted in a number of points that I want to highlight:</p>
  
  <pre><code>points = some_processing(im);
  </code></pre>
  
  <p>Where <code>points</code> is a matrix the same size as <code>im</code> with ones in the interesting points.</p>
  
  <p>Now I want to draw a circle on the image in all the places where <code>points</code> is 1.</p>
  
  <p>Is there any function in MATLAB that does this? The best I can come up with is:</p>
  
  <pre><code>[x_p, y_p] = find (points);
  
  [x, y] = meshgrid(1:size(im,1), 1:size(im,2))
  r = 5;
  
  circles = zeros(size(im));
  
  for k = 1:length(x_p)
      circles = circles + (floor((x - x_p(k)).^2 + (y - y_p(k)).^2) == r);
  end
  
  % normalize circles
  circles = circles/max(max(circles));
  
  output = im + circles;
  
  imshow(output)
  </code></pre>
  
  <p>This seems more than somewhat inelegant. Is there a way to draw circles similar to the <code>line</code> function?</p>