How can I generate data points form arbitrary shape in 2D in MATLAB ?
8 次查看(过去 30 天)
显示 更早的评论
Dear All, I would like to ask: How can I generate data points form arbitrary shape in 2D in MATLAB ?
0 个评论
回答(3 个)
Image Analyst
2016-12-1
How about rand()?
numberOfVertices = 15;
x = rand(1, numberOfVertices);
y = rand(1, numberOfVertices);
If you want an image, use
binaryImage = poly2mask(x, y, rows, columns);
7 个评论
Image Analyst
2016-12-1
Not that I know of. Perhaps if you were able to read a font file. In the meantime, here's some code that will create a heart shape:
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);
There is also code to create a Batman logo: http://www.mathworks.com/matlabcentral/answers/13131-batman-equation-in-matlab#answer_17935 But nothing for a letter B I'm afraid. Sorry.
Image Analyst
2016-12-1
Do you want the boundary points of a binary image shape? If so, use bwboundaries().
2 个评论
Image Analyst
2017-1-14
And where do you think those real data points will come from if you don't have them already? Apparently you didn't think they can come from images of shapes as I suggested. So exactly where are you going to get those boundary points?
Walter Roberson
2017-1-14
Daya tables for one of the famous vector fonts is given at http://paulbourke.net/dataformats/hershey/
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Valentines Day 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!