sdh@joevax.UUCP (The Doctor) (09/18/86)
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
bobr@zeus.UUCP (Robert Reed) (09/26/86)
Steve Hawley in <281@joevax.UUCP> provides what he calls a "jaggie remover". This is a very crude algorithm which I would not recommend to anyone seriously interested in anti-aliasing. Ignoring the blantant programming errors in his sample, his technique is a blending algorithm which averages the aliased samples around and including the pixel. I think it is intended to avoid smearing by staggaring the changes behind the leading edge of the averager, but suffers the problems of filtering without oversampling. This algorithm will: o Give believable effects on the edges of large solid polygons. o Wash out thin lines and text o Generally destroy textures. The problem is that the equal weighted sample does NOT take into account the underlying structure of the picture. Consider what it will do to this image of a horizontal line, where we have pixel with 4 levels of brightness. (o = off, + = dim, * = semi-bright, # = bright) before "jaggie removal": oooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooo ######################################## oooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooo after: oooooooooooooooooooooooooooooooooooooooo ++++++++++++++++++++++++++++++++++++++++ **************************************** ++++++++++++++++++++++++++++++++++++++++ oooooooooooooooooooooooooooooooooooooooo The line has been expanded to three rows and dimmed. Once again I emphasize, this is NOT a topic for novice speculation. Much reseearch has been done on this topic, and if you are really interested, consult one of a number of texts which have been mentioned in this newsgroup. Please do not inflict off-the-cuff schemes on this audience. Robert Reed, Tektronix CAE Systems Division, bobr@zeus.TEK
garry@batcomputer.TN.CORNELL.EDU (Garry Wiegand) (09/30/86)
In a recent article bobr@zeus.UUCP (Robert Reed) wrote: >Once again I emphasize, this is NOT a topic for novice speculation. Much >reseearch has been done on this topic, and if you are really interested, >consult one of a number of texts which have been mentioned in this >newsgroup. Please do not inflict off-the-cuff schemes on this audience. Bob, I think you're arrogant and out of line. Serious postings *from anyone* deserve to be treated with at least a small amount of respect and politeness, and should always be encouraged - even if they aren't up to the state of the art. If you want to have a "graphics-wizards-who-know-what-they're-talking-about-only" mailing list, please go off and start it. "Net.graphics" is for everybody. And people who send in code fragments are probably especially appreciated. garry wiegand (garry%cadif-oak@cu-arpa.cs.cornell.edu)
garry@batcomputer.TN.CORNELL.EDU (Garry Wiegand) (10/02/86)
About yesterday's posting, in which I told Bob Reed that he was "arrogant" for giving someone else a bad time about their code: Perhaps I was overly harsh; if so I'd like to apologize to Bob. I certainly wouldn't ever have taken the time and effort to analyze and explain the original "anti-jaggie" code for everybody; I appreciate that Bob did do it. My problem is just that I hate to see anybody *ever* discouraged from making postings. That the poster is not satisfactorily expert in what they're talking about is an especially poor reason. Who ever is "expert"? Anyhow, I consider any posting which elicits information, such as a request for references, to be just moderately worthwhile for me to read. On the other hand, I find a posting which stimulates or continues a discussion to be the most worthwhile. By that standard, the original poster (Steve Hawley) obviously wins :-) Wish there were *more* give-and-take discussions on this group, and more code. Both apprentice-level and wizard-level. garry wiegand (garry%cadif-oak@cu-arpa.cs.cornell.edu)