Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

using imaq count objects 2 for area calculation

Hi, I am scanning A4 size paper (at 300 dpi) having drawing of regular shapes such as square, triangle, right angle triangle of lenght and height of 30mm. I am using imaq count objects 2 for object recognition and the area, my question is : 1.)  Does the VI give the area in terms of number of pixels contained in the object? 2.) If I convert the area from pixel to sq mm I am getting 3-5% error is it advisable to convert the area in terms of pixel into sqmm directly on the basis of the DPI? 3.) Can you suggest other means of converting the area into metrics?

0 Kudos
Message 1 of 8
(5,316 Views)

Hello,

 

calibrate your system for perspective distortion based on knowing the distance between four points on your A4 paper (you can add your reference points to the four corners of the paper). Optionally correct for lens distortion if needed. Then use IMAQ Particle Analysis report to get real-world values based on your calibration (it will give the same output, i.e. area, object center, etc.). You can also use IMAQ Count Objects, but I think you will need to calculate the real-world values manually (which shouldn't be a problem).

 

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 8
(5,309 Views)

I did not follow why i need to know distance between the four coners of the paper, Are you saying that the scanner may introduce distortion? Also, I am guessing that there may be two errors introduced in the number obtained from the VI, first error is the number of pixels is not perfect for different shapes and second error is the conversion factor, but i am not sure if the accuracy of the calculation will be affected by 3-5%. If 

0 Kudos
Message 3 of 8
(5,307 Views)

Hello,

 

I apologize for reading your post too quickly and for misunderstanding you! My mistake Smiley Frustrated

You are using an image (flatbed) scanner... I thought you were using a camera (didn't see that you specified the dpi factor).

 

Regarding optical distortion - I don't know. You could do some tests though, but I don't know if the model fits rectilinear lense model... 

 

Did you try measuring distances only (not areas) and observing the error? For example, how much error do you get if you measure the lenght of the side of your square?

 

How do you convert the area in pix to mm^2? Are you using a scale factor based on measuring the pixels area of known real-world 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 4 of 8
(5,299 Views)

No IssuesSmiley Happy 1.) I didnot try to measure the lenght of the square 2.) my calculation is quite simple ( (area in pixel) / ( (dpi ^ 2) / (2.54 ^2) ) )*100

0 Kudos
Message 5 of 8
(5,296 Views)

I feel the scaling factor will not work for different shapes and especially for irregular shapes other than regular geometrical shapes, am i right?

0 Kudos
Message 6 of 8
(5,295 Views)

You need to calibrate your scanner.  It probably isn't scanning at exactly 300 dpi.  The easiest way would be to scan a piece of graph paper, or a paper with markings at known locations.  Measure the physical distance between the marks, and compare it to the number of pixels in your image.  You need to do this for both axis, because the scanner doesn't necessarily scan square pixels.

 

It can be a pretty small error in each axis to get 3%-5% error that you are talking about, so measure accurately.  If it is 294 dpi on both axis, that would give you 4% error in the area measurement.

 

Once you have your scaling factor correct, your conversion should work fine for any shape.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 8
(5,284 Views)

The use of scaling factor is not accurate for regular or irregular shapes because the resolution at which the flat bed scanner is used will introduce error when the angle of the edge changes and same for the curves, plus scaling factors for different resolutions is different, which is obvious. The percentage error can be reduced by increasing the DPI greater than 400 but still the error will have effects on the mathematical calculation because the pixel count itself will be wrong along the edges of the object depending on the shape of the edge. This will require more techniques to be implemented for reduction of error, which makes it more complicated......any suggestion on this?

0 Kudos
Message 8 of 8
(5,252 Views)