Creating a star shape using the imshow() function.
이전 댓글 표시
The shape should look like a star
⭐⭐
and should use MATLAB and the imshow() function.
답변 (2개)
Image Analyst
2016년 12월 10일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
stepSize = 360 / 5;
angles1 = 0 : stepSize : 360;
angles2 = stepSize/2 : stepSize : 360 + stepSize/2;
r1 = 150;
r2 = 300;
x1 = r1 * cosd(angles1);
y1 = r1 * sind(angles1);
x2 = r2 * cosd(angles2);
y2 = r2 * sind(angles2);
subplot(2,2,1);
plot(x1, y1, 'LineWidth', 2);
hold on;
plot(x2, y2, 'LineWidth', 2);
grid on;
x3 = reshape([x1;x2], 1, []);
y3 = reshape([y1;y2], 1, []);
% Shift center to 500, 500
x3 = x3 + 500;
y3 = y3 + 500;
subplot(2,2,2);
plot(x3, y3, 'LineWidth', 2);
% Make 900x900 image from the coordinates.
subplot(2,2,3);
maskImage = poly2mask(x3, y3, 900, 900);
imshow(maskImage);
axis on;

댓글 수: 2
ammar khider
2016년 12월 11일
Image Analyst
2016년 12월 11일
Then you do not have the Image Processing Toolbox. Use the ver command to check. You'll have to use some other way to turn the vertices into an image, which you need to do because it says you must use imshow().
Image Analyst
2016년 12월 11일
0 개 추천
Fancier demo attached.

카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!