05-27-2009 09:46 AM
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
05-27-2009 10:08 AM
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
05-27-2009 10:13 AM
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
05-27-2009 10:16 AM - edited 05-27-2009 10:21 AM
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
05-27-2009 10:23 AM
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
05-27-2009 10:30 AM
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