Creating a star shape using the imshow() function.
Ältere Kommentare anzeigen
The shape should look like a star
⭐⭐
and should use MATLAB and the imshow() function.
Antworten (2)
Image Analyst
am 10 Dez. 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 Kommentare
ammar khider
am 11 Dez. 2016
Image Analyst
am 11 Dez. 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
am 11 Dez. 2016
0 Stimmen
Fancier demo attached.

Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!