[Gllug] Faster maths?

Tethys sta296 at astradyne.co.uk
Fri Mar 9 01:08:35 UTC 2007


Adrian McMenamin writes:

>There must be a better way as I know C libraries obviously don't take
>this long (do they?) and the difference in speed is so great it cannot
>simply be perl versus C that is the issue.

Correct. It's late, and I'm not entirely sober, but if I understand your
dithering algorithm correctly, it sounds very computationally intensive,
which I think is where the problem lies.

>I know this is a bit of a specialist subject - but anybody know of
>faster ways to calculate distances in a three dimensional space and/or
>work out how to compare with a smaller range of numbers than the whole
>24 bit palette?

All you need to do is calculate a suitable dithering "ramp" (albeit one
in multiple dimensions), and map your chosen pixel onto it. Calculating
the ramp is a relatively cheap operation (I'm assuming you've already
quantized to your chosen palette by this point), and from there, it's
just a simple lookup.

The details can be found in Robert Ulichney's "Digital Halftoning", which
is pretty much the definitive reference for this sort of stuff.

As a quick and dirty way to get started, you could try looking at the
source for pnmremap (or historic versions of ppmquant).

Tet
-------------- 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