[Gllug] Faster maths?
Richard Jones
rich at annexia.org
Fri Mar 9 15:03:27 UTC 2007
On Thu, Mar 08, 2007 at 11:11:26PM +0000, Adrian McMenamin wrote:
> I have some perl which indexes and dithers a PNG image to a 256 colour
> palette.
>
> The indexing is pretty fast - a 59K (compressed) PNG image on a 4000
> BogoMIPS machine in about a second.
>
> But I turn on dithering it takes half an hour!!
>
> The bottleneck appears to be calculating the distance of a point in
> colourspace (ie the original colour + diffused error) from any point in
> the palette (to find the closest match).
>
> I don't use sqrt - just compare square with square (and save a match so
> don't have to do the same lookup twice).
There's a fast, high-quality implementation of this algorithm in the
source code to xv. Unfortunately it has a non-free license ...
Rich.
--
Richard Jones
Red Hat
-------------- next part --------------
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list