Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!cbmvax!cbmehq!cbmger!peterk From: peterk@cbmger.UUCP (Peter Kittel GERMANY) Newsgroups: comp.sys.amiga.programmer Subject: Re: xxx to HAM algorithm Message-ID: <785@cbmger.UUCP> Date: 28 Jan 91 10:19:06 GMT References: <1991Jan23.170826.6194@uni-paderborn.de> Reply-To: peterk@cbmger.UUCP (Peter Kittel GERMANY) Organization: Commodore Bueromaschinen GmbH, West Germany Lines: 45 In article <1991Jan23.170826.6194@uni-paderborn.de> massa@uni-paderborn.de (Michael Janich) writes: > >I'm searching for a GOOD algorithm to convert more than 32 colors to HAM. I >saw the following: > >(ppmtoilbm) > -Color map are the 16 gray scales (000, 111, ...) > -calculate for the 4 possibilities (change red, blue, green or take > color map) the differences like > delta_green = abs(oldred - red) + abs(oldblue-blue); > -take the minimum of these differences. > >I tried > -Color map are the 16 most used colors > - First optimization to consider is the coice of the 16 base colors. I tried several attempts but am not yet really satisfied: A) Eliminate neighbored colors (difference only one step or some other "tolerance distance") and let only survive the more used one. I drove this algorithm down to only 16 remaining colors, by starting with a tolerance distance of 1, and when the current tolerance distance leaves too many colors alive, then start again with an increased tolerance, until you end up with 16 colors. But this is VERY time consuming and you get stuck with some very odd colors that appear only in very few (unimportant) pixels, and the net result of all this is also not much better. So I ended up in using only a moderate tolerance distance of 1, max. 2 steps and then using the 16 most used colors. Oh, one detail to add to explanation: When one color is eliminated in favor of a neighbored one, then its count has to be added to the one of the surviving one. >Can anybody please help me - perhaps with the HamLab algorithm? Do I have to >use weighted expressions to calculate the 'delta_[|colmap]'? B) Yes, I also tried weighted distance calculation. My intention was to give more accent to the color tone and lesser to the brightness. Well, but either I did something wrong with my vector formulae (:-) in the 3D color space or this assumption was bad. The result was worse than the normal way. -- Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk