I NEED TO MAKE A HEART in a CANVAS
53 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have a code in MATLAB,
i created a canvas with 3 pages 1000 rows and 1000 columns with a circle in the middle (the size doesnt matter) such:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
canvas = ones (1000,1000,3,'uint8'); canvas(:,:,1) = 255; canvas(:,:,2) = 0; canvas(:,:,3) = 0;
rad = 260; rows = 500; col = 500; for n = -rad:rad d = round(sqrt(rad^2 - n^2)); canvas (rows-d:rows+d,col+n,:) = 255; end
imshow (canvas)
%%%%%%%%%%%%%%%
I NEED to generate a HEART IN THE MIDDLE INSTEAD OF THE CIRCLE... can someone help me with that please ???
0 commentaires
Réponses (2)
Image Analyst
le 17 Oct 2018
Try this:
% Plots 2 heart-shaped curves.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
t = linspace(-pi,pi, 350);
X = t .* sin(pi * .872*sin(t)./t);
Y = -abs(t) .* cos(pi * sin(t)./t);
plot(X,Y);
fill(X, Y, 'r');
axis square;
set(gcf, 'Position', get(0,'Screensize'));
title('Happy Valentines Day', 'FontSize', 28);
% axis off; % Uncomment to turn off tick labels along the bottom and left axes and remove the box.
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
%------------------------------------------------------------------------------
% Another method.
% https://blogs.mathworks.com/cleve/2018/02/14/happy-valentines-day/
figure;
ezplot('(x^2+y^2-1)^3 = x^2*y^3', ...
[-1.5,1.5,-1.2,1.5])
colormap([.5 .2 .2])
2 commentaires
Image Analyst
le 17 Oct 2018
tzela's "Answer" moved here since it's a comment to me rather than an answer to the original question:
thanx, but i need a code that will implement it into CANVAS .... IN THE CENTER. thats where im having an issue
Image Analyst
le 17 Oct 2018
So use scale x and y to the desired size and then use poly2mask() to turn it into an image
scale = 100; % Whatever
canvass = poly2mask(scale*x, scale*y, rows, col);
adjust scale as needed.
Voir également
Catégories
En savoir plus sur Valentines Day dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!