"Adam Wozniak" <[EMAIL PROTECTED]> wrote in message
news:4915@palm-dev-forum...
> Is multiply more expensive than test-and-branch...?

Multiply takes about 70 cycles, so it is indeed much slower than test and
branch. Thinking geometrically, the question we're asking is whether the
distance is below a threshold (the distance to closest color found so far).
Well, if the delta X, delta Y, or the delta Z is greater than that
threshold, then of course the distance will be greater too, so we could do
these faster tests first. Most colors should fail these tests once the
closest color was found (on average, half way through the scan). I'd say
profiling would be needed to determine whether this optimization would help
in practice.

The proper way to find the closest point in 3-space is to pre-process the
point set to generate a 3D voronoi diagram. A voronoi diagram is a
partitioning of space into regions, each of which contains all points which
are closer to one point than to any others. These regions are polyhedra.
There are algorithms for efficiently finding which region a point falls in.
Of course, all this is overkill, since you shouldn't be doing RGB to index
conversions in time-critical inner loops!



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to