Transform boundary image to 2d plan coordinates
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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?
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
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
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".
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에서 Images에 대해 자세히 알아보기
참고 항목
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)
