Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure area of contour

Hello. 
I need to measure the area of an irregular shaped object. Ideally I would create a binay image, but I fear it is not possible for my solution, since the background and conditions in general varies. 
So I wonder if there is a way to detect the shape (I know it's possible, I already did it) and then somehow measure on this shape? 
Either by measuring the number of pixels contained in this shape, or somehow convert only the shape to binary? I.E. the shape is 1, the rest of the image is 0. 

Any thoughts would be much appreciated. 

0 Kudos
Message 1 of 4
(4,931 Views)

Hello,

 

if the background varies, did you try the adaptive thresholding methods?

 

If you can extract the contour of the object you could construct a custom (polygon) ROI and convert it to mask using the IMAQ ROI to Mask.

 

How do you detect the shape of your object?

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 4
(4,929 Views)

Well, the question was actually also about detecting a shape. 
I played around with the contour analysis tool. With this I was able to detect the desired contour. I actually only need to be able to measure how many pixels are contained within this contour. 

0 Kudos
Message 3 of 4
(4,922 Views)

Hello,

 

if you extracted the contour points, you could construct a ROI and convert it to mask, followed by the particle analysis:

 

PointsToMask_FP.png

PointsToMask_BD.png

 

One thing that is strange though, in the example above, the rectangle/mask of the particle analysis shows +1 pixel in both directions. I am not sure what is the reason for this.

 

Regarding the detection - it's impossible to say, since you did not provide any examples.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 4 of 4
(4,901 Views)