I have experience, in the sense that I thought about it for a bit recently.Khaz wrote:My thought on this is that I can hopefully write a customized program specifically designed to import graphics to the SNES, which will allow you to generate a table of palettes for a much larger image and then assign each 16x16 block of the image a palette such that you're left with a completely assembled image - all you'd have to do is load the tiles, palettes and a tilemap into your game and you've got any arbitrary image file on screen.
In concept I am sure such a thing is possible, but I'm having a hard time right now coming up with a strategy for doing it. If you quantize the entire image all at once you'll end up with every tile containing mixed palettes, which is useless. If you break it down one tile at a time, each tile will generate a unique palette. What I need is a way to calculate a compromise between each piece's ideal palette to come up with a set of 2-to-3 (or up to 8 depending on whether it's just a static image or an actual "background") palettes that will best represent the whole image. I'm not sure where to start.
Does anyone have experience with this kind of project? Has it been done? Anyone know of a reason I should give up?
Perhaps one could quantize each tile (8x8 or 16x16) separately, and then repeatedly pare down the number of palettes by identifying palette pairs that are the most similar in a least-squares sense, and re-quantizing the set of tiles that use them as a single image. For palettes with free entries, you'd obviously want to avoid comparing colours that aren't actually used; perhaps pixel-weighting the least-squares comparison would work...? Though that raises the possibility of botching very small colour regions; a higher error power might be more resistant to such an effect, but it might skew the overall comparison...
Or perhaps you could just compare the tiles up front and pare them down to N sets that have similar colour requirements, and then just quantize once...
You decide whether or not I'm onto something; I haven't actually tried this.
...
It occurs to me that this technique will most likely result in a visible tile structure unless you're very careful to align nearby colours in different palettes...


