I'm trying to create a histogram of the colors in a png file. For now my VI open the png and then it take the informations such width height ecc, from a cluster. Then i create an array with all colors fro an image with depth 8 bit (0 to 255), what i tried so far is to compare the array with all the pixels of the image and the array of colors, so that i can remove the colors that aren't in the image from the array and make an Histogram to use later to understand how many colors i have in my image and which are.
How can i remove these colors from my Histogram?
Thank you for your time
Solved! Go to Solution.
(I assume you have a paletted image. can you attach the image?)
Initialize an I32 array of zeros with size 256 and put it in a shift register of a FOR loop.
Autoindex on the FOR loop with the image data.
For each pixel, increment the value corresponding to the color index to create a histogram.
At the end, keep only the indices where the element is nonzero. These are the used colors.
Thank you for the answer
I attached the image, but i didn't really understand the two last point.
Can you be more specific please?
Of course you want to add some error handling to detect if the image is not paletted. If so, skip the code and return an error.
Doing the same on a 24bit image would require more expensive algorithms, but is doable.