My NDS texture compressor
is now available for download. It requires python 2.5 and a laundry list of python libraries. There's also a simple test program that lets you pan around the compressed image on NDS hardware/emulators.
It's generating okay output I think. On the standard computer graphics Lena image, compare the original
It's incredibly slow though. Take a look at these timings for the 512x512 Lena image:
|Core 2 Quad Q6600, Python x86-64, Linux||3:59|
|Core i7 920, Python x86, Windows||2:39|
There's a lot of places you could optimize this. Obviously, moving from python and numpy to C and assembly would help tons. The depth crushing and dithering could use fixed point instead of float, and so could k-means. And the final pass where we eliminate egregiously bad blocks is really bad. It runs PIL's color quantizer 1-3 times for each palette for each bad block! Not feasible for the entire image unless you have a nice supercomputer under your desk. That should probably do some kind of nearest-neighbor search for decent palettes to try.
I'd worry about image quality before optimization though. By default, we only use 4-color palettes since 2-color ones never seem to have good results. There are a lot of blocky artifacts. Is there an algorithm to reduce that? (Error diffusion over the image gradient on block boundaries?) Python is much more useful for that kind of exploration. The image dithering also may be causing more harm than good, since it's adding noise. Perhaps only dithering where it's really necessary, or applying some kind of adaptive blur would help in this area.