LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW for simple image analysis

Solved!
Go to solution

Hi all, 

 

I'm using LabVIEW to control a piece of testing hardware that is designed to break test specimens. I am hoping to use a simple USB camera to verify if the specimen has broken, and stop the test. The image of the test specimen will go from bright (test specimen present) to dark (test specimen half-gone). My approach is to use average brightness values (one could do image correlation but it's simply not worth it for simple fail-detection).

I have attached a piece of .VI to grab the screen at a location (where the USB camera is running), as a hack to avoid needing to integrate a camera directly into LabVIEW (all .VI I have found show very complicated, camera model dependent solutions for direct integration). 

 

My questions are: 

-I'm struggling to understand the datatype handling: the image seems to be converted from array, to unsigned byte array, to png, to "image". Is there a suggested datatype to handle these operations? If I were writing this in python, I would perform all operations with the image as an array. 

-Does anyone have experience in either using the "image", or png, datatype to perform basic arithmetic (average brightness value)? I am having difficulty finding the operations which accept the proper datatypes, and then output the correct value. 

 

Thanks so much in advance!

H

0 Kudos
Message 1 of 8
(3,052 Views)

If you unbundle the image data, and choose the "image" element, that has all the values of the picture. I'm not sure what order they are in in terms of R, G, and B, but you can probably play around and figure that out. Then you need to find a formula for conversion from RBG to grayscale or brightness (some people like different ratios of the colors). Then add those up.

 

I've done something similar to this before, but it's on my home computer. I'll see if I can dig it up and post it tonight.

0 Kudos
Message 2 of 8
(3,031 Views)

If you want the Image as an Array Value you have function in LabVIEW Vision (IMAQ ImageToArray VI), From the converted data you can process for your need.

Even you have arithmetic operations for Image datatype.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 8
(3,014 Views)

Try taking a look at this code. I can't guarantee it's completely correct, I just wrote it once quickly for something I was trying to test, but it seems like it's similar to what you want, so maybe it will help you.

Message 4 of 8
(3,008 Views)

Hey prettypwnie, thanks for the reply! I sadly can't open that .vi as i've got an older version of labVIEW. Is there a way to save that as a version compatible with 16.0f2?

Thanks!

 

0 Kudos
Message 5 of 8
(2,979 Views)
Solution
Accepted by cmhargia

This is prettypwnie's example saved for LabVIEW 2016.  A potentially very nice feature of this example is that it uses LabVIEW's Picture functions, rather than the Vision Toolkit, so you can do some "image analysis" without needing any of the IMAQ/IMAQdx functions.  Kudos to prettypwnie (I would not have thought to try this ...).

 

Bob Schor

Message 6 of 8
(2,968 Views)

Thanks so much Bob! This works great: I'm able to take the average brightness value and see it change in realtime. 

My current aim would be to take the first 5 seconds average of this value (determine the baseline for a given test), and then apply a threshold condition for a stop condition. 

I assume the best way to do this would be a for loop running for 5000ms, then continue into another for loop where the value is always compared to this average? 

Thanks so much!

0 Kudos
Message 7 of 8
(2,955 Views)

When you start getting into an architecture where you are thinking about doing one thing in a loop, then finishing and going to the next loop for another thing, etc... it's good to take a step back and think about your architecture first. Maybe if you are only doing those two things one after another every time, this will work okay. But what if later you decide you want your program to go back to do another baseline? It is better to use a more flexible architecture, like a state machine. Here is an example for you:

Message 8 of 8
(2,942 Views)