Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!msi.umn.edu!umeecs!zip!spencer From: spencer@eecs.umich.edu (Spencer W. Thomas) Newsgroups: comp.graphics Subject: Re: Finding nearest point Message-ID: Date: 19 Feb 91 21:43:45 GMT References: <1991Feb14.181028.7851@engin.umich.edu> <16827@accuvax.nwu.edu> <3639@ssc-bee.ssc-vax.UUCP> Sender: news@zip.eecs.umich.edu Organization: University of Michigan EECS Dept Lines: 18 In-Reply-To: coy@ssc-vax's message of 16 Feb 91 21:19:05 GMT If indeed you're trying to map RGB colors to representatives, then I've got code for you. It's part of the Utah Raster Toolkit (3.0, patch level 2, see FAQ posting for retrieval info), and can be found in the subroutine lib/inv_cmap.c. It quantizes the input data (typically to 5 or 6 bits) and builds a NxNxN (where N=2^5 or 2^6, typically) cube. You use the quantized color to index this cube, and immediately get the nearest color (up to the quantization limit). I'm working on making it do better with colors that are closer together than the quantization cell size. Apple has a similar scheme they use in Color Quickdraw, but their inverse colormaps are far from optimal. It's faster than my method, though. Where I might take 12 seconds to build a 2^5^3 inverse map, they take only about 1 second (but 2^5 is the largest they will go). -- =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F)