From: Daniel Egger <[EMAIL PROTECTED]>
   Date: Sun, 27 Feb 2005 16:03:14 +0100

   this is my suggested patch for getting the speeds improvements
   as mentioned in the other thread by having a thread-local PRNG
   initialized with a seed from the still existing blend tool local

   It looks bigger than it is because I took the liberty to remove
   the nasty special casing on the existence of the RNG inside the
   innermost loop because we now have it outside already.

   There seems to be more room for obvious optimisations in the
   loops. Also I would recommend splitting the two cases into
   two separate functions to make the code easier to read, and
   remove more conditionals.

   PS: If this is okay, I'd do exactly the same for the gray
   blending stuff...

In addition to being very slow, this will also yield noisy results.
There are a lot of dither algorithms that are both much faster and
yield better results.  While you may not need full-blown
Floyd-Steinberg or EvenTone dithering for this purpose (and they're
hard to use in a multi-threaded fashion), a simple dither matrix is
fast, free of most artifacts, trivial to parallelize (you're only
reading from the matrix, so no serialization is necessary), and
reasonably low noise.

In Gutenprint we have several precomputed matrices, designed for 1:1,
2:1, and 4:1 aspect ratios.  You would need only a 1:1 ratio matrix.
Also, our matrices are large (about 64K elements each, since they need
16 bit resolution), but you wouldn't need anything that big.  There's
a very simple iterated matrix that can generate any desired power of 2
matrix size (which makes for even faster lookup), but it does suffer
from patterning.  That may not matter for this purpose, since the
steps are very small.

We use the same matrix for all color channels, but offset the starting
address for each channel to decorrelate the channels.

Let me know if you're interested.

Robert Krawitz                                     <[EMAIL PROTECTED]>

Tall Clubs International  -- or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail [EMAIL PROTECTED]
Project lead for Gimp Print   --

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton
Gimp-developer mailing list

Reply via email to