Example that analyses the colour content along an annular ROI in an image and identifies a feature along that curve.
Measuring gauges using the vision tool is usually very straight-forward. However, there are instances where the gauge measurement is complicated by the complexity of the background or, an absence of an easily identifiable needle centre.
Oil pressure gauges, fuel gauges etc all suffer from this.
What the example does is take a narrow annular region of interest and effectively unwrap it. For each line across the region, an average is then taken of the red green and blue components of the acquired image. If we have, say, a red needle, we will then find a peak in the red trace. On its own this isn't sufficient however. What about white areas - they will also appear as peaks in the red trace? This is true, but where the white is covered, the other colours will be reduced. So, we can subtract the blue value from the red and obtain a clean trace.
LabVIEW 2016
Vision development module
Load the example "Needle on meter.vi". It illustrates the process and also displays the resulting traces. In this case I'm just using images from a gauge indicator with a noisy background, but it works the same with a real video stream.
"Mean colour around annular ROI.vi" is the subVI you would use in your own analysis. It has one subVI "Mean colours.vi".
Once the peak index is located, it then needs scaling by the number of lines unwrapped from the ROI to give the measurement of a fraction of the scale.
Note that the measurement is taken clockwise around the annulus and so you may need to take 1-Measurement if your gauge is inverted.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hello Nick,
Your code looks very good. I am working on a similar project; I have captured video and I would like to get the average intensity of an annular region. I have limited experience with labview and I just got hold of an older version, labview 2010; so I tried to take a look at your code but I cannot because I get the message that the code if from a newer version.
Is it possible that you post your code for labview 2010.
Thanks in advance,
Rob
Hi Roberto83,
I wouldn't be able to test it properly even if I did convert it back to 2010, but what you are trying to achieve is very different in any case.
In this example, the inner pixels of the annulus are counted more than once. A line it taken radially from the outer edge of the defined annular ROI and is likely to overlap with its neighbours. In your case, you want to count the individual pixels within the region just the once.
I think you need to define the annular region and then turn it into a mask ("IMAQ ROIToMask 2.vi"). Use "IMAQ ImageToArray.vi" to obtain the 2D array of the mask values. Then use "IMAQ ColorImageToArray.vi" to extract the rectangular region of the ROI from your image (The rectangle is an element of the ROI cluster). Then you just need to find the mean of each colour component for all of array elements that are selected in the mask. Recombine the components to give you your mean colour.
Hope this helps.
Further to the mean colour question, here's a bit of code from a subVI I've created to process any ROI and extract the mean colour value. Incoming image is U32 RGB and the ROI is read from the display properties.