Posterize adds extra colors?
in
Programming Questions
•
8 months ago
Maybe I'm going crazy: I'm trying to find the most common colors in an image. Using filter(POSTERIZE, n) seems the easiest solution. However, if I put in a number of values, the result is always more than the # specified.
For example:
2 steps = 5 colors
3 steps = 13 colors
4 steps = 23 colors!
Many of these are grayscale values, which leads me to suspect that POSTERIZE limits to colors + grayscale? Any ideas on getting rid of those "extra" grayscale values but leave them if they are really the most dominant?
If it makes any difference, I'm posterizing the image, then loading the pixels into a HashSet to remove duplicates quickly, then spitting the results back out as a color array. Maybe something weird is happening there?
For example:
2 steps = 5 colors
3 steps = 13 colors
4 steps = 23 colors!
Many of these are grayscale values, which leads me to suspect that POSTERIZE limits to colors + grayscale? Any ideas on getting rid of those "extra" grayscale values but leave them if they are really the most dominant?
If it makes any difference, I'm posterizing the image, then loading the pixels into a HashSet to remove duplicates quickly, then spitting the results back out as a color array. Maybe something weird is happening there?
1