이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to produce equally distant samples in Matlab?
조회 수: 10 (최근 30일)
이전 댓글 표시
I am interested to produce equally distant samples inside a closed n-dim space whereas each generated point has the same distance to its neighboring points. Is there any matlab function or method to do this?
Let's say we have a vector in 2D system with known coordination for the tip and tail of that vector. How to find equally distant samples over this vector? Let's assume we have a regular triangle shape and the coordination of the edges in the 3-dim Cartesian system is known. How to find equally distant samples in this shape? Last, what if the shape is not regular and has curvature arms (curves connecting the edges). Assume there are some known points (coordination) on the arms. How to find equally distant samples in this shape. For first figure:
p1=[1,3];
p2=[5,4];
for triangle shape:
p1=[1,3,0];
p2=[5,4,1];
p3=[-1,2,4];
for the last shape, there are just some known points on the arms (red curves).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167010/image.png)
댓글 수: 25
John D'Errico
2017년 9월 2일
편집: John D'Errico
2017년 9월 2일
Jamais said:
"I want the equally distant points to be generated IN the shape and also on it's boundary.
For the first two figures, they lie on a plane, but for the 3rd one, it doesn't lie on a plane."
Johns response: For the non-convex, non-planar general case, Have fun. It is not gonna happen without a hell of a lot of work at defining EXACTLY what it means to be "inside" that region. (Why I deleted my answer.) Don't expect to be successful at the task.
Jamais avenir
2017년 9월 2일
편집: Jamais avenir
2017년 9월 2일
Equally distant points Inside the region means a set of points that lie inside the shape and meanwhile they are equally distant. For the first two figures, I've already solved it. But for the last one, I have no clue.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186797/image.png)
Walter Roberson
2017년 9월 2일
What are they equally distant from ?
Your description so far implies that you should be creating a single arc of a circle relative to something, since a circle is the set of points that are equally distant from some origin (at least if you are working in Euclidean space.)
Jamais avenir
2017년 9월 2일
편집: Walter Roberson
2017년 9월 2일
@Walter , I mean the generated points should be equally distant from each others.
Walter Roberson
2017년 9월 2일
In N dimensions, at most (N+1) points can be equally distant from each other, vertices of a hyper-pyramid.
Jamais avenir
2017년 9월 3일
편집: Jamais avenir
2017년 9월 3일
@Walter, From "equally distant points", I mean the generated points should have an equal distant to their neighboring points as shown in the figure.
John D'Errico
2017년 9월 3일
Let me explain. You want code to generate what is essentially optimal circle or sphere packing, inside and on the boundary of a completely general non-convex object, defined only by a set of arbitrary points along a simple curved path in 2 or 3 dimensions.
Of course, since you have not yet decided how to define what are the boundaries of that complicated curved object, the task you ask to solve will be rather difficult, the subject of a doctoral thesis even if someone were able to show you how to do it.
Even if you were willing to accept a maximal circle/sphere packing inside (and on the surface of) the convex hull of your object, that alone is a quite difficult problem, and it surely would not be acceptable, since those curved lines will not lie inside the convex hull.
It is easy to say, I want to do this (...) on a computer. Before you find a computational algorithm to solve a problem, you need to decide what is the problem. You have not even done that yet. What is the object described by that rather complex 3-d region defined by that curved path in your third picture? Start there.
Jamais avenir
2017년 9월 3일
편집: Jamais avenir
2017년 9월 3일
Thanks for your time @John. I cannot simplify it too much. The last shape is in fact a dried leaf. So it may not even lie in a plane. However with more simplification, it lies on a plane too, but still with curvature boundaries. This shape may illustrate this matter better.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186804/image.jpeg)
Image Analyst
2017년 9월 3일
If it's not lying in a plane, then it's not a photo. What generated this 3-D image? A profilometer? Computer graphics? If it's computer graphics (a simulation) then you know the boundaries and so you'll know all locations along the edge of the leaf. If it's from a profilometer or some kind of 3-D white light scanning system, then why don't you just find all the edges? Why do you want/need only some of them?
Jamais avenir
2017년 9월 3일
@Image Analyst thanks for your time.
We can have all the (enough) edges on the boundary. The question is, how to generate evenly distributed samples (points) inside this 3D shape (right) and also in the other 2D image shape (left).
Image Analyst
2017년 9월 3일
Why don't you have them already? You should have a voxel at every point already. Why do you have them only at certain widely-spaced locations?
Walter Roberson
2017년 9월 3일
You want a triangular mapping along the surface of an arbitrary 3D curve. It is not possible to do that without distortion.
See in particular http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/foldout.html, but add the additional restriction that you permit the vertices to be only where the equivalent of "land" is.
Your situation is even more complicated than a regular surface such as a sphere. Those pages discussion projection techniques and what they preserve or not (and why so), which might allow you to choose a trade-off that is acceptable to you.
Jamais avenir
2017년 9월 3일
@ Image Analyst , We have the coordination of many points on the boundary! Now how to generate evenly distributed samples inside these shapes (left & right)? P.S. I cannot generate other points on the boundary, they belong to a rare leaf in museum and I can only have access to some data from it. Now I am trying to develop a method and in the first step I need to know the coordination of evenly spaced sample points inside it.
Image Analyst
2017년 9월 3일
Instead of coordination, I think/hope you mean coordinates. Otherwise I have no idea what you have. Assuming you have only a few points along a boundary, you can't "fill in" other points unless you make some assumptions. For example let's say you have a salad bowl and only the coordinates of 12 points along the upper rim. There is no way to get the points on the surface of the bowl below the rim (i.e. "interior" to the rim points) unless you make some assumptions that the shape will be a concave bowl shape. Otherwise you'd simply get a flat disk, not dipping into the bowl. Does that make sense?
Jamais avenir
2017년 9월 3일
@Image Analyst , Yes I mean coordinates, thanks for the point. I got what you mean clearly now. Then I need to ask them for more information.
However, I m still interested to generate evenly spaced samples inside the other simplified leaf which lies on a plane (But How should I generate them?). As shown in the figure the coordinates of (edges and) some points over the boundary are know. so we can interpolate that bit if it's needed.
Image Analyst
2017년 9월 3일
Why not use John D'Errico's polyfitn? You can fit a plane between the points so now you have a z value for every (x,y) location. If you want just some of them, rather than each and every pixel, you can either subsample the whole plane or use randi() to randomly pick locations.
Jamais avenir
2017년 9월 3일
편집: Jamais avenir
2017년 9월 3일
Isn't that for interpolation of points? And the result would be several points ON the boundary?!
But I want to generate samples inside the shape, not on it's boundary. Anyhow I have no clue to generate the samples inside the shape using that tool.
Image Analyst
2017년 9월 3일
No, it takes points anywhere in space and builds a model. Then you can use that model to get estimated values at any other locations that you want. I attach a background correction demo where I used it.
Jamais avenir
2017년 9월 3일
Thanks. But, it's utterly complicated for my matlab knowledge. Is it possible to use my coordinates and produce some evenly spaced samples in it?!
you can assume some points between my coordinates are given so as to interpolate the boundary if needed.
Jamais avenir
2017년 9월 4일
편집: Jamais avenir
2017년 9월 4일
@Image Analyst, here is the set of coordinates. All points lie on a plane. Thanks.
Walter Roberson
2017년 9월 4일
You cannot get a spatially-curved 3D figure from those points.
In your post https://www.mathworks.com/matlabcentral/answers/354968-how-to-produce-equally-distant-samples-in-matlab#comment_481591 you showed a diagram with a leaf, and that leaf appears to have a shadow. Are leaf and shadow images available? If so then it might be possible to deduce some 3D information (not easily though.)
Jamais avenir
2017년 9월 4일
편집: Jamais avenir
2017년 9월 4일
@Walter, Now I am thinking on the simplified model where the leaf lies on a plane. As an example I've generated some points which indicate the boundary of a namely leaf-shape and they stay on a plane. I am curious to see how one can generate evenly spaced samples inside this boundary perhaps with your polyfitn. For the realistic model, I will ask for more information about coordinates of some points around the boundary and inside the leaf in order to simulate and visualize it on a computer first. Additionally, that was an example, we don't have the shadow.
답변 (1개)
Image Analyst
2017년 9월 2일
I don't see how having curved "arms" makes any difference if you're just interested in finding the point in the middle between three specified points.
Anyway, you can write those points to an image and use bwdist() to compute the Euclidean Distance Transform. You may need to use poly2mask() if you have a solid shape with "arms".
Attach input data and desired result if you want more help.
댓글 수: 3
Image Analyst
2017년 9월 3일
In your diagram, a point at the center of the hexagon is equidistant from only 6 other points and has different distances to all the other points.
Assuming that's what you want, you can generate such a hexagonal grid by simply making two simple rectangular grids and combining them, with one offset from the other by half a box.
Jamais avenir
2017년 9월 3일
@Image Analyst, Yes that's what I want. Would you give me some hint on how to do this on matlab please!
Generate such a hexagonal grid by simply making two simple rectangular grids and combining them, with one offset from the other by half a box.
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning for Image Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)