Draw a circle inside a black image
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to draw a circle in this 500x500 black matrix, but it deos not appear idk
here is the code
E = zeros(500,500);
E2 = insertShape(E, 'Circle',[250 250 100], ...
'Color','white', 'LineWidth',5);
figure(5),imshow(uint8(E2));
댓글 수: 0
채택된 답변
Voss
2022년 3월 6일
E = zeros(500,500);
E2 = insertShape(E, 'Circle',[250 250 100], ...
'Color','white', 'LineWidth',5);
figure(5);
% imshow(uint8(255*E2));
% or:
imshow(E2);
댓글 수: 4
Image Analyst
2022년 3월 6일
Do you need double? You just cast the whole thing to double at the end, so why didn't you like my solution where I just start out with the matrix being double right from the start, thus avoiding the need to cast it to double?
Or you can leave it as double - don't cast to uint8 - and it works fine:
E = zeros(500,500);
E2 = insertShape(E, 'Circle',[250 250 100], ...
'Color','white', 'LineWidth',5);
figure(5),imshow(E2);
추가 답변 (1개)
Image Analyst
2022년 3월 6일
Try this:
E = zeros(500,500, 'uint8'); % Make image as uint8 right from the beginning.
E2 = insertShape(E, 'Circle', [250 250 100], ...
'Color','white', 'LineWidth',5);
imshow(E2, []); % Display it with [] to expand the contrast.
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


