Filter löschen
Filter löschen

Putting two circles on the same image

1 Ansicht (letzte 30 Tage)
Mert Aygün
Mert Aygün am 20 Mai 2018
Kommentiert: Ameer Hamza am 20 Mai 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.
function [outimg, outimg1] = CircleIm(radius)
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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 20 Mai 2018
Bearbeitet: Ameer Hamza am 20 Mai 2018
Try the following
function [outimg] = CircleIm(radius)
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 Kommentare
Mert Aygün
Mert Aygün am 20 Mai 2018
Thank you!
Ameer Hamza
Ameer Hamza am 20 Mai 2018
You are welcome.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by