LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

identifying number of red pixels

Hi,

 

I have the following vi I need to create and I just wanted some input on how to go about it.  I have a color jpeg image and I want to identify the number of pixels in the image of a specific color.

 

Thanks

Chris 

0 Kudos
Message 1 of 6
(2,919 Views)

Hi Chris,

do you mean a fixed color with RGB representation or a range like red or green so that light green is also a result? You can use the image functions to read your picture and search in the image array. If you have an RGB value to find, then you can use the "search array" function to get the result, if you need to find a range like "red", then i would transfer all pixels to HSV representation.

 

Hope it helps.
Mike

Message 2 of 6
(2,908 Views)

Mike,

 

It is a fixed color RGB image so there is only 1 shade of each color.  So your recommendation is to get the RGB value for this color change the image to an array and scan the array to identify the amount of pixels of the selected RGB value?

 

Thanks

Chris

0 Kudos
Message 3 of 6
(2,902 Views)

Hi Chris,

in this case i would calculate an U32 representation of the image data and use the "search 1d Array" function in a loop.

 

edit:

It's also possible without a loop, see the example.

 

Mike

Message Edited by MikeS81 on 05-27-2009 05:21 PM
Message 4 of 6
(2,899 Views)

Thanks Mike,

 

Sounds good (easy is good!).

 

But just for my future knowledge you mentioned earlier if I were to specify a range you would convert to an HSV image.  Why is this?  And how would you calculate the amount of pixels in the range if this was the case?

 

Chris

0 Kudos
Message 5 of 6
(2,891 Views)

Hi Chris,

i think with HSV it's easier to specify a range, there you can define red from angle 340-30.

See this wikipedia link for more information

http://en.wikipedia.org/wiki/HSL_and_HSV

 

Mike

Message 6 of 6
(2,887 Views)