Transform boundary image to 2d plan coordinates
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, I need to transform some images (that represent different objects boundary line) to a curve on matlab. The images are like this

what I need to do is to "place" this curve and the area inside it in a 2d space in order to make an if cicle: if I am inside this area I have some requirements, if I am outside I have different requirements (an example would be a gps use: if I am inside an area defined by this curve and so inside some longitude and latitude limits I have three restaurants, if I am outside I have no restaurant). Can somebody help?
採用された回答
Image Analyst
2014 年 11 月 18 日
What is an "if cicle"? If you have the x,y coordinates of the boundary/perimeter/curve, then you can use inpolygon() to determine if a point is inside or not. I don't know what else to say since I don't know what it means "to place this curve and the area inside it in a 2D space" nor do I know what an "if cicle" is. Isn't the curve ALREADY in a 2D space? It's in a plane isn't it?
10 件のコメント
I think the example I wrote was good enough to explain. I have this image I posted but it's a png file. I have to upload this on matlab and define the blue curve in coordinates (like a matrix X,Y with all the blue pixels). Then I think I can use inpolygon()
If cicle means that I have to write a code like if my position (X,Y) is inside the area defined by the blue curve do something else do something else.
can this explanation work?
Image Analyst
2014 年 11 月 19 日
Well, cicle is not an English word, at least not where I'm from. Perhaps you mean "a while loop" or "a for loop". I don't know what you're starting with. Are you starting with a white image with a blue line on it, or are you starting with an array of (x,y) coordinates? What does "upload this on matlab" mean? Do you mean "read in the image"? If so, you can simply use imread(). Then you can find the blue coordinates and just scan the image from top to bottom and use inpolygon() to determine if each pixel is inside or not and take appropriate action based on the result. What would that action be? Do you just want to place N restaurants at random locations inside the blue curve? Please elaborate so I can help you.
Thank you so much. I know I've not explained my self very well (I'm not english) but you gave me the perfect advice (inpolygon). I'm working on my master thesis in space engineer and this I ask is just a small part of a bigger software very diffult to explain. What I've done is:
1)read the image I posted with imread
2)use points2contour to re-order image's points
3)use inpolygon to determine if one point is in or out the area defined by the curve on the image I posted .
The use of points2contour is needed because with a casual distribution there are errors in the inpolygon function
Image Analyst
2014 年 11 月 19 日
Do you just need a mask that's true inside the blue line and false (black) outside? If so, that's easy. Just take the red channel, threshold, and call imfill().
more or less this is just what I need to do thanks, but in my case inpolygon works better
Image Analyst
2014 年 11 月 20 日
But you have a problem in that your contour is not closed so inpolygon won't work. I know it's not closed because I did it my way and it didn't fill it. When I dilated the perimeter, then it closed it up. But then you might as well use imfill() in a single line of code then rather than a nested for loop calling inpolygon.

The m-file is attached below.
matteo
2014 年 11 月 20 日
Hi thanks for this, maybe I'll have some other question later (I keep working on my thesis so I can't know by now if it's going to work well for my study)
Hi, I've gone forward in my thesis:
I transformed that area in an area over a spherical surface (earth surface) now I have a point above this surface (some km above). I need to define the 3d cone that has for vertex the point and base the area. Then I have to define if some other points I'm going to enter in this model are inside or outside this "cone".
Image Analyst
2014 年 11 月 21 日
OK. Good luck. Thanks for Accepting the answer. I don't really know how to do your latest task but I think Roger Stafford probably does. I suggest you post it as a brand new question. And detail exactly what "define this 3d cone" means, mathematically.
matteo
2014 年 11 月 21 日
Thanks again for your help, you've really saved mylife so far.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Point Cloud Processing についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
