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!