turn on suggestions

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

Showing results for

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

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

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

09-29-2005 05:35 AM

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

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

09-29-2005 10:42 AM

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

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

09-29-2005 10:44 AM

If you could characterize your ROI a bit more (is it convex, does it
contain holes, is it non self intersecting, does it roughly fit some
geometric shape, etc.) I may be able to come up with something more
clever. As it stands, the simplist thing to do would probably be to
call IMAQ ROIToMask, and then check if the point in the resulting mask
image is 0 or not using IMAQ GetPixelValue.

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

Kevin C.

National Instruments

NI Vision

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

Kevin C.

National Instruments

NI Vision

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

09-29-2005 11:26 PM

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

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

10-24-2005 02:13 AM

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

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

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

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

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

01-22-2007 10:40 AM

You can always first compare your point to the global rectangle of the ROI to eliminate the need to process every point extensively.

Randall Pursley

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

04-29-2007 04:00 PM

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

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

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

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.

Message 10 of 10
(1,134 Views)