# Putting two circles on the same image

11 views (last 30 days)
Mert Aygün on 20 May 2018
Commented: Ameer Hamza on 20 May 2018
I am trying to obtain a car figure with using two circles and one rectangle image. Firstly, I need to create the circles. How can I put two circles in the same image with the code below? Thanks in advance.
SizeX = 256;
SizeY = 256;
[C, R] = meshgrid(1:SizeX, 1:SizeY);
centerX = 64;
centerY = 64;
centerX1 = 192;
centerY1 = 192;
circle = (R - centerY).^2 + (C - centerX).^2 <= radius.^2;
circle1 = (R - centerY1).^2 + (C - centerX1).^2 <= radius.^2;
outimg=image(circle);
hold on;
outimg1=image(circle1);
colormap([0 0 0.4; 1 1 1]);
end

Ameer Hamza on 20 May 2018
Edited: Ameer Hamza on 20 May 2018
Try the following
SizeX = 256;
SizeY = 256;
[C, R] = meshgrid(1:SizeX, 1:SizeY);
centerX = 64;
centerY = 64;
centerX1 = 192;
centerY1 = 192;
circle = (R - centerY).^2 + (C - centerX).^2 <= radius.^2;
circle1 = (R - centerY1).^2 + (C - centerX1).^2 <= radius.^2;
circles = circle|circle1;
outimg=image(circle|circle1);
colormap([0 0 0.4; 1 1 1]);
end
your method of hold on will make draw the new image on top of the last image. You need to or both images together to retain both circles. The following are drawn with a radius of 20. %
##### 2 CommentsShow 1 older commentHide 1 older comment
Ameer Hamza on 20 May 2018
You are welcome.