Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get RGB mean pixel values?

Hi,
 
I'm quite new to LabVIEW and still looking around to find the functions I need. I have LabVIEW 8.2 and Vision 8.5 installed. I use an color-USB camera, which works good with the USB drivers for Vision. I want to measure the mean pixel intensity in different regions in my picture, but I can only find this VI for grayscale images. One solution is to let my camera take the picture in grayscale, but when I do this (I get a setup-windom from the camera manufacter) the image is still in 32-bit mode, but the three pixel values are all the same, which results in an image looking grayscale but infact still is a 32 bit color image (if I understood it right). Another solution (I guessed at least) is to use the IMAQ Cast Image, but doing this on my 32-bit RGB picture doesn't work; I still can't use the function for calculating mean intensities for a grayscale picture.
 
I also tried extracting for example the intensity plane, but looking at the picture coming out makes me wondering; it's a color picture. This is not the same picture as was the case when I tried using the extraction tool of intensity plane in vision assistant, so I don't know what's wrong here.
 
I guess I could extract the pixel values for R, G, and B respectively, (for example via ColorImageToArray) and process the arrays, and calculate the mean values, but this seems to be a not very efficient way. The application will need to be fast to work good.
 
It would be OK if I get the grayscale mean intensity, as long as it is transformed in a proper way from a color image.
 
Hope you are having a good day!
/Alex
0 Kudos
Message 1 of 6
(8,595 Views)

A couple of methods:

Use Image Color Histogram to get statistics on each color plane.  This includes the mean of each color plane.

You could also use Extract Color Plane to get the Intensity, which is the grayscale image.  Use Quantify or Histogram to get the mean value.

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 6
(8,588 Views)
Absolutely agree with bruce and in addition i will suggest you use vision assistant first since u have mentioned that u are new to labVIEW.In vision assistant select extract color planes and play around u will get a good idea.
Message 3 of 6
(8,577 Views)

Thanks a lot, it seems to work just as I want it to work! I didn't read the description for the histogram function enough, I thought it only would give a plot of the histogram for the image.

 

/Alex

0 Kudos
Message 4 of 6
(8,573 Views)

 Where can i find the "Image Color Histogram"?

I´m using Vision Assistant 8.5 but in the first Tab "Image" there is only the choice of "Histogram" and nothing with Color Histogram.

Or do i have to install also another product for more options in the Vision Assistant?

Thanks and best regards

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

The color histogram is in LabVIEW.  I'm not sure what histogram functions are supported in Vision Assistant.  If the color histogram is not available, you could do it in two steps.  First extract the color plane (R,G, or B) that you want a histogram of, then use the grayscale histogram.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 6 of 6
(8,183 Views)