필터 지우기
필터 지우기

Putting two circles on the same image

조회 수: 1 (최근 30일)
Mert Aygün
Mert Aygün 2018년 5월 20일
댓글: Ameer Hamza 2018년 5월 20일
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

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 20일
편집: Ameer Hamza 2018년 5월 20일
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
Mert Aygün
Mert Aygün 2018년 5월 20일
Thank you!
Ameer Hamza
Ameer Hamza 2018년 5월 20일
You are welcome.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by