LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Color histogram of an image file

Hello everyone,

I have never done this basically but while having a coffee I thought this would help me out a lot. I have an image file from a certain experiment and have to identify different regions of the image based on its color (brown, black, silver etc). I have never used VisionAssistant but am wondering if there is a possibility of making a histrogram of the different colors present in the image file? I have seen a matlab code for doing this. And wondering if anyone has tried this with labview.

 

regards,

0 Kudos
Message 1 of 4
(3,458 Views)

There may be fancier ways to do this, but you read the file in as an image and then use "unflatten pixmap.vi" to get a 2D array of all the image pixels.  For example, indexing an element out of this array and feeding it into a color box indicate will show you the colour of the pixel.

You can then sort through this array counting all elements of a particular colour or within a particular range of colours, giving you all the info you need for your histogram. It will also allow you to compare different areas of the image by comparing different 'areas' of the 2D array.

 

Ian

0 Kudos
Message 2 of 4
(3,453 Views)

example attached - can't help but wonder if there are some unnecessary steps in converting to a 1D array for the histogram vi. Anyone?

 

colour histogram bitmaps_BD.png

0 Kudos
Message 3 of 4
(3,449 Views)

Is the image paletted or RGB?

 

If it is RGB, a histogram does no make much sense unless you have a way to logically group very similar colors.

If it is paletted, initialize an I32 array with the size of the colormap and increment elements according to the color index. (shift register, stacked loops, in place element structure & some trimmings)

Message 4 of 4
(3,446 Views)