(OK, I’m posting three notes quickly to sort of catch up. I’ll edit pictures into them later when I get the chance.)
Friday, 15 Feb 2008 - I continued work on my graphcis app project which I’m calling Doink. This is really perfect for doing software on the time-budget that thing-a-day promotes because I can get real functional results and call them a unit of productivity in an hour. I wrote routines to merge two images of the same size (which I’ll adapt to handle differently sized images) and one to identify whether an image is mostly of one of the following: red, green, blue, cyan, magenta or yellow and a set of routines that work together to reduce the number of colors used in an image.
So, the variables that the user can set with this doink (the first one I made user-configurable) are: the total number of colors to use, whether to force black and white and whether to force the most prevalent of the six colors mentioned above. So continuing to use my daughter’s halloween picture as a model (previous parts 1 and 2), the following illustrates some results:
This one is just black and white. The application looked at every pixel and tried to determine whether it was closer to black or closer to white. I’d guess that sophisticated programs have more clever algorithms to maintain texture, etc, but this is what I have.
This one didn’t mandate black and white but did mandate the pure form which turns out to be cyan. I really dig finding the tonal areas that the app IDs as closer to cyan than white that it IDed in the image above as being closer to white than black
This one uses the “pure” color (which will always be cyan, for this original image) and then finds four other tones that are very common and not so close to one another as to be silly.
Finally, this one forced the use of pure cyan and black and white and then seventeen other tones. You can really see detail at this point.
the algorithm that determines which tones to use selects the most frequently occurring colors, one after the next and tests it to see if it’s far enough away from the other colors that have thus far been selected for use. It does that by looking at the difference between the red, blue and green factors (scale is 0-255) and adding the squares of the differences. If that sum is less than 300, it discards them as too close and grabs the next one and so on. I think I’ll update the app so that the user can change that 300.