Images, Hues and Forests
Friday, March 27th, 2009Another night of coding. I’m working on a small tool that will decompose images into various color regions. It’s actually an interesting problem. I tried two different methods, both of which resulted in “not quite what I wanted”.
One approach was to use a DisjointSetForest to split the image into adjoining regions of similar color using a simple Euclidean distance formula (considering R, G, B to be “coordinates” in 3-space). While it works pretty well, it generates far too many disjoint areas to be useful given our typical input to the tool.
The other approach was to sepeate the image using Hues (from the HSB color space). While this did an adequate job, it still generated far too many sub-images to be of use for the problem we are trying to solve.
I ended up with a simple breakdown of the image based on Hue and then an additional pass to recombine various “detail” areas back together assuming their Hues were close enough. It actually results in a reasonable output from the tool, so I’m happy for tonight. There is plenty more to do with it (and since we haven’t described WHY we want such a tool, I’ll leave that to your imagination).
And the project advances one small step in the positive direction…