Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!agate!linus!nixbur!nixpbe!peun11!josef From: josef@nixdorf.de (Moellers) Newsgroups: comp.graphics Subject: Re: Scaling Transformation on Bitmap Characters. Message-ID: Date: 8 Nov 90 07:22:14 GMT References: <1990Nov5.022837.15506@ucselx.sdsu.edu> Sender: news@nixpbe.nixdorf.de Lines: 57 In <1990Nov5.022837.15506@ucselx.sdsu.edu> brian@ucselx.sdsu.edu (Brian Ho) writes: >Hello out-there, > I am some problems which you may give me a hand. I am trying to scale > some bitmap images, those images are characters (e.g. A B a b 1 2 ..etc) > which have the same font but with different sizes. The goal of the scaling > transformation is to normalized those characters into the same size, 20pt. > Currently, I am using a very simple transformation algorithm, which is > looking for the height/width from the original image, then determine the > scaling factor, sx and sy. And apply the scaling factor to the old image. > The result is not as good as we expected. Somehow, characters with different > sizes resulting different shapes after the transformation, and it is > no way to tell they are actually has the same font. The goal we are > trying to achieve is to retain the shape/features of the character after > transformation. [ rest deleted ] I tried an approach described in the "Weekly automated posting": When scaling from a larger font size to a smaller one (the reverse doesn't work), I first determine the dimensions of the smaller font. Example: I want to scale a font from 30 points to 20 points. A character measuring 50x40 pixels is scaled to 33x27 pixels. Next, I loop through the destination pixels, regarding each pixel as a square portion of the whole character. In scaling, each destination pixel is a mapping of part of the source character. I determine the exact area that the pixel under examination is mapped from and calculate how much "black" is mapped from the source into the destination pixel. This number (an FP number) ranges from 0 to (src-pt-size - dst-pt-size)^2 in the example given above this number may range from 0 to 2.25. This number is the divided by it's upper bound, yielding a number from 0 to 1 (inclusive). One can now use this number to provide anti-aliasing or one can use a threshold to determine if "enough" black is mapped into this pixel to make it black. My program, which is too crude to be published, scales an entire HPLJ-softfont from a given source point size to a given destination point size using an (optional) threshold as described above. It is very crude, as it first converts each character from the HPLJ-bitmap into an ASCII representation (using '*' and ' '), scaling that array and then converting back into a bitmap. The program even takes care of the various sizes encoded in the headers. Hope this helps. BTW I don't know nothing about any mathematical model. PS Don't send a REPLY, as the address recorded in the header of this posting is wrong. Please use the address given below! -- | Josef Moellers | c/o Siemens Nixdorf Informatonssysteme AG | | USA: mollers.pad@nixdorf.com | Abt. PXD-S14 | | !USA: mollers.pad@nixdorf.de | Heinz-Nixdorf-Ring | | Phone: (+49) 5251 104662 | D-4790 Paderborn |