Kevin Vance - My NDS texture compressor is now available for download. It…

Entries | Archive | Friends | Friends' Friends | User Info

01:00 pm

Monday, March 30th, 2009
Previous Entry Share Next Entry
Tags

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 and compressed versions.

It's incredibly slow though. Take a look at these timings for the 512x512 Lena image:
ConfigurationTime (MM:SS)
Core 2 Quad Q6600, Python x86-64, Linux3:59
Core i7 920, Python x86, Windows2: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.
Link )Reply )

Comments
From: zixyer
2009-03-31 12:48 am (UTC)
I thought the days fixed point was faster than floating point were long past us.
(Reply) (Thread)
[User Picture]From: kvance
2009-03-31 01:27 am (UTC)
Good point! Python must really be slowing me down during the dithering phase, or image editors have really efficient dithering code.
(Reply) (Parent) (Thread)