LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counting white pixels

So I've been trying for a while now to create a VI that counts the number of white pixels there are in an image. I have a 16-bit image that consists of only white and black pixels (that I processed from Vision Assistant). I know exactly how I should do it, but no idea of what it takes. I'm guessing the best thing would be to change the image into an array, and then run a search on it for pixels with an intensity of 255, but it seems like there are no VIs to help with this. Does anyone have any idea about how I work this out?
0 Kudos
Message 1 of 11
(4,580 Views)

Hi Ayi.

The VIs IMAQ Histograph and IMAQ Histogram are suited for this job. Both VIs are located in Vision's Analysis palette.

Regards, Guenter

Message 2 of 11
(4,571 Views)
I agree.  You could use the IMAQ Histogram VI, and specify the Number of Classes to be 2.  Then it is just a matter of unbundling the information.
Brian K.
Message 3 of 11
(4,552 Views)
Thanks for the information. However the problem I have is that IMAQ Histogram throws an 'Not an Image' exception. To get the number of white pixels I multiply the mean intensity by the number of pixels. But the image I feed to it is of one subtracted from another, and because the two images are fairly close in pixel intensity (except for one spot), I guess I'm having precision issues with pixels. Is there a way I can tell IMAQ Histogram to do something else if it gets a non-image or almost black image? Or is there something more precise?
0 Kudos
Message 4 of 11
(4,547 Views)

Hi Ayi.

I expect that the 'Not an Image' exception is caused by the image type. As you can take from the Vision Help these VIs support the image types U8, I16 and SGL. What kind of image do you wire to IMAQ Histogram?

Regards, Guenter

0 Kudos
Message 5 of 11
(4,529 Views)
I'm wiring a 16-bit image (I16). I'm guessing that the difference between the images is within the margin of error for pixel calculations. Which just gives a nonsensically dark image, perhaps. Do I have to change it?
0 Kudos
Message 6 of 11
(4,523 Views)

The more I think about it the less ideas I get.  Can you write that image to a file and post it to this thread to let us see what is happening?

Thanks, Guenter

0 Kudos
Message 7 of 11
(4,515 Views)
Ah..well. I sorted myself out. The issue was with the CCD driver I was using, and not Vision Assistant. I wonder though, about Intensity Graphs. Is there a way of having set ranges for color values ie. rather than have the values wired to it range on some big, graduated Z scale, could one have 3 colors, say white, red and black corresponding to 3  or more different ranges (these will, of course, encompass all possible values that could be wired to the graph)? If so, how could it be done? Thanks.
0 Kudos
Message 8 of 11
(4,472 Views)
Hi,

If understand you correctly you are trying to devide the intensity displayed on the intensity graph in three different catigories.  There isn't a way to do that in LabVIEW.  The intensity graph can only display the insenity of pixel values.  I hope this helps.  Let me know if I misinterpreted your question.

Regards,

GG
0 Kudos
Message 9 of 11
(4,448 Views)
What I'm trying to do is that I'm passing a 2D array of values, which I want to be mapped as intensites, however I want the graph to display just 3 colours (say red for 0 to x, green for x to y, and white for y and above). You say this is not possible? Do you know of any other VI that could help if this isn't possible with the Intensity Graph?

0 Kudos
Message 10 of 11
(4,443 Views)