# draw a white circle on an binary image?

17 views (last 30 days)
sara on 25 Sep 2014
Answered: Matthew Eicholtz on 29 Jan 2016
hi I want to draw a white cirle on an image ..my image is binary and I want to draw a withe circle on it : I have cordinate and radius of this: I use this code
if true
imshow(m);imellipse(gca,[168.673621460507 309.997019374069 50 50]);
end
and my result is like this:
how can I make a white circle before using it on this image and then use this circle on it??

Image Analyst on 25 Sep 2014
Try this:
% Demo to write an ellipse into the overlay of an image,
% and then to burn those overlays into the image.
%----- Initializing steps -----
% Clean up
clc;
clear all;
close all;
workspace; % Display the workspace panel.
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
% User said No, so exit.
return;
end
end
% Display images to prepare for the demo.
subplot(2, 2, 1);
imshow(monochromeImage);
title('Original Image');
subplot(2, 2, 2);
imshow(monochromeImage);
title('Original Image with ellipse in overlay');
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
set(gcf,'name','Image Analysis Demo','numbertitle','off')
%----- Burn ellipse into image -----
% Create elliptical mask, h, as an ROI object over the second image.
subplot(2, 2, 2);
hEllipse = imellipse(gca,[10 10 50 150]); % Second argument defines ellipse shape and position.
% Create a binary image ("mask") from the ROI object.
% It's solid now. If you want the perimeter, call bwperim
binaryImage = bwperim(binaryImage);
subplot(2, 2, 3);
imshow(binaryImage);
% Let's try to add some text. (Doesn't work)
% hText = text(50, 100, 'Line of Text');
% binaryImage = binaryImage & textMask;
% imshow(binaryImage);
% Burn ellipse into image by setting it to 255 wherever the mask is true.
monochromeImage(binaryImage) = 255;
% Display the image with the "burned in" ellipse.
subplot(2, 2, 4);
imshow(monochromeImage);
title('New image with ellipse burned into image');
See attached demo for one that also does a line.
sara on 25 Sep 2014
thanks

Matthew Eicholtz on 29 Jan 2016
You can also try using insertShape, which was introduced in R2014a.

### Categories

Find more on Computer Vision with Simulink in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!