Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract a Circular ROI

Any update?

0 Kudos
Message 21 of 23
(1,366 Views)

@muks can you show me your code for this? tnx

0 Kudos
Message 22 of 23
(1,188 Views)

The original question was about circular ROIs. While there are "annulus to ROI" and "ROI to annulus" functions, there are no direct conversion functions for ROI type 4 (circle/ellipse), so you need to roll up your sleeves a bit to work with elliptical ROIs.

 

While "ellipse to ROI" and "ROI to ellipse" functions aren't available, you can always generate circle and ellipse ROIs from the bounding box dimensions. You simply need to create an ROI specification based on the bounding box.

 

The ROI cluster is composed of 2 elements: the Global Rectangle array, and the Contours cluster.

 

For the Global Rectangle array, you will simply build an array composed of the left, top, right, bottom locations that define the bounding box for the ellipse.

 

For the Contours cluster, set Contour Type = 0, ROI Type = 4, and for the Points array, just use the same left, top, right, bottom values you used for the Global Rectangle.

 

As an example, suppose you wanted to define a circular ROI enclosed in the rectangle specified by the point pairs (100,100), (100, 200), (200, 100), (200, 200). Your "left" value is 100, your "top" value is 100, your "right' value is 200, and your "bottom" value is 200.

 

So, your ROI cluster would look like this:

Global Rectangle: 100, 100, 200, 200

Contours Cluster:

   Contour Type = 0

   ROI Type = 4

   Points: 100, 100, 200, 200

 

The attached .png shows how this looks in a LabVIEW context. Use this ROI definition with any VI that can accept an ROI input. 

 

Referring back to the original posting, the original question was about generating a circular ROI based on a point that defined the center of the circle. If you know the center point coordinates and the radius length (in pixels), it is quite easy to build a circular ROI around a given center point. (In the example above, the center point is (150, 150) and radius is 50. The Global Rectangle values can easily be calculated by adding and subtracting the radius value to/from center point coordinates.)   

 

While this doesn't directly answer the question, it may be easier to use the Type 4 "ellipse" ROI than the Type 7 "annulus" ROI, particularly if you need to construct, translate, or scale a circular region programmatically.   

 

-- Dave Ritter,
MoviMED/MoviTHERM

          

0 Kudos
Message 23 of 23
(469 Views)