Creating a star shape using the imshow() function.
Mostrar comentarios más antiguos
The shape should look like a star
⭐⭐
and should use MATLAB and the imshow() function.
Respuestas (2)
Image Analyst
el 10 de Dic. de 2016
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 comentarios
ammar khider
el 11 de Dic. de 2016
Image Analyst
el 11 de Dic. de 2016
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
el 11 de Dic. de 2016
0 votos
Fancier demo attached.

Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!