Effacer les filtres
Effacer les filtres

Putting two circles on the same image

1 vue (au cours des 30 derniers jours)
Mert Aygün
Mert Aygün le 20 Mai 2018
Commenté : Ameer Hamza le 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

Réponse acceptée

Ameer Hamza
Ameer Hamza le 20 Mai 2018
Modifié(e) : Ameer Hamza le 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 commentaires
Mert Aygün
Mert Aygün le 20 Mai 2018
Thank you!
Ameer Hamza
Ameer Hamza le 20 Mai 2018
You are welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by