How can I generate data points form arbitrary shape in 2D in MATLAB ?
이전 댓글 표시
Dear All, I would like to ask: How can I generate data points form arbitrary shape in 2D in MATLAB ?
답변 (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
Ammar
2016년 12월 1일
Image Analyst
2016년 12월 1일
rand() will give you arbitrary/random locations for a shape. Since it's arbitrary, there's no guarantee that it will look like anything in particular like a star or letter B.
If you have a specific shape in mind, then it's no longer arbitrary, is it? Like I said in my other answer, if you have a specific shape, then you can get the perimeter points using bwboundary().
If this doesn't answer your question, then see this link because I have no other guesses as to what you want.
Ammar
2016년 12월 1일
Image Analyst
2016년 12월 1일
How are you going to get those? I don't have the coordinates for a letter B. Do you? And I don't know of any analytical mathematical formula to give them. If you have an image of a B then I can get them, but if that's the case, you already have the B and there's nothing else for you to do.
Ammar
2016년 12월 1일
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.
Ammar
2016년 12월 2일
Image Analyst
2016년 12월 1일
0 개 추천
Do you want the boundary points of a binary image shape? If so, use bwboundaries().
댓글 수: 2
Ammar
2016년 12월 1일
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일
0 개 추천
Daya tables for one of the famous vector fonts is given at http://paulbourke.net/dataformats/hershey/
카테고리
도움말 센터 및 File Exchange에서 Valentines Day에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!