- Community Home
- :
- Discussion Forums
- :
- Most Active Hardware Boards
- :
- Machine Vision
- :
- Re: Find whether a point is inside or outside a ROI or Region

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

09-29-2005 05:35 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hi all,

I need to find whether a point is lies inside an ROI. Is there any direct or indirect VI doing this? My ROI is huge list of points (Say a polygon ROI with more than 10,000 points on the contour).

We can use the Ray tracing algorithm, shooting a line and find howmany times it hits the contour. But the number of points is huge, so it may be time consuming. I also have a list of points to be found whether it is inside or not. So if any of you know some simple algorithm or VI please let me know.

Thanks,

senthil kumar m

09-29-2005 10:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

A simple way of doing this is to create a mask using the ROItoMask VI and then plug the point you want to check into GetPixelValue to see whether it is lit up or not.

Ken Pietrzak

Dragonfly Computing

09-29-2005 10:44 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Give that a try and see if the performance is adequate for your needs.

Kevin C.

National Instruments

NI Vision

09-29-2005 11:26 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hi Ken & Kevin,

I appreciate your suggestions. Yes, thats the simplest way to do. I will do that.

One problem could be my image size is very big - say 8000 * 23000 resolution. So it might putup lot of memory issues. Anyway thanks for the soution dudes. If you have anything more please let me know.

My image has irregular shapes, its not always complex. It has intersecting of shapes like two circles merged.

Thanks,

senthil kumar m

10-24-2005 02:13 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hai Logic,

Try these steps:

Instead of getting the extracting the entire ROI,

Find out the ROI points which are nearer to your point. Points which say are less than some 100 pixel or the first 20 nearest points just by mathematical calculation. Now construct the ROI with these points(of course a maximum of one side would be left out). Extract this portion alone and see whether the point lies in it. Just check if this works.

Thanks,

Vasanth.

Ya Ya

01-17-2007 12:44 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

01-18-2007 06:32 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hello 4342,

If you are looking to do this processing in LabVIEW, it appears this forum should answer your question. If you have a different issue, please repost with a more detailed description.

However, if you are inquiring as to how to do this processing in MATLAB, I would suggest posting on a MathWorks forum.

Regards,

Jasper S

01-22-2007 10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Randall Pursley

04-29-2007 04:00 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

To determine if a point is within a curve, the easiest way is to calculate its winding number. This involves a lot of calculations using complex numbers, but it can be reduced to the following steps:

Store the contour points in an array, and store a duplicate of the first point as the last point.

Subtract the point A from each point in your contour to get vectors.

Use Atan2(y,x) to determine the angle for each vector in the contour.

Use Unwrap Phase to eliminate jumps in the angle.

Compare the first angle to the last angle in the contour. If they are equal, the point is outside the curve. If they differ by a multiple of 2 Pi, the point is inside the curve.

If the point is on the curve, the angle may or may not jump at the end. To identify a point that is on the curve, search the list of unwrapped angles for a difference of exactly Pi (or -Pi). If this exists, the point is on the curve.

The algorithm will not work if point A is equal to a point on the contour, so it would probably be a good idea to search to make sure none of the contour points are equal to the point A, also.

I attached an example that demonstrates this concept.

Bruce

Bruce Ammons

Ammons Engineering

Ammons Engineering

Highlighted
##
##### Re: Find whether a point is inside or outside a ROI or Region

Options
As my contribution to this 5-old thread, since I didn't find any better solution than doing it myself, a VI which tests if a point is inside any of the [multiple] ROIs of an image. Implementation is for type 2 (rectangle), 4 (ellipse), 5 (closed polygon) and 6 (closed freehand). For types 2,5,6, the technique of the preceding post is used. Further types (rotated rectangle, annulus) could be done but it would be tedious. Provided for LV10.

04-01-2012 02:04 PM - edited 04-01-2012 02:05 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator