Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!caip!princeton!allegra!ulysses!gamma!zeta!sabre!petrus!magic!joevax!sdh From: sdh@joevax.UUCP (The Doctor) Newsgroups: net.graphics Subject: jaggie remover Message-ID: <281@joevax.UUCP> Date: Wed, 17-Sep-86 18:03:16 EDT Article-I.D.: joevax.281 Posted: Wed Sep 17 18:03:16 1986 Date-Received: Wed, 24-Sep-86 22:13:20 EDT Distribution: net Organization: Bell Communications Research Inc., Morristown, NJ Lines: 56 Ok, here is a snippet of code to smooth out all jaggies in an image #define VERTRES some integer #define HORZRES some integer struct attr { /* whatever you need to define a pixel */ } smooth() { register int x, y; struct attr average[3][HORZRES], avgpix(); for (y = 0; y < VERTRES + 2; y++) { for (x = 0; x < HORZRES; x++) { if (y>2) { /* change pixel only after its out of range */ diddle(average[(y - 2) % 3][x], x, y); } if (y < VERTRES) { /* save pixel average only while on screen */ average[y % 3][x] = avgpix(x, y); } } } } stuct attr avgpix(x, y) int x, y; { /* this routine should average all the attributes of the 8 * pixels around x,y and x,y * and return the averages. */ } diddle(avg, x, y) struct attr avg; int x, y; { /* this routine should get the attributes for the pixel at x,y * and change them according some function of their difference. */ struct attr curr_pixel; curr_pixel = get_attr(x, y); /* diddle it here */ set_attr(curr_pixel, x, y); } That's it. It should work very well on objects with plain backgrounds. On very complex pictures it will probably give the effect of going out of focus. Steve Hawley joevax!sdh