Presentation is loading. Please wait.

Presentation is loading. Please wait.

Anti Aliasing.

Similar presentations


Presentation on theme: "Anti Aliasing."— Presentation transcript:

1 Anti Aliasing

2 Anti-aliasing Anti-aliasing is a technique used to diminish the jagged edges of an image or a line, so that the line appears to be smoother; by changing the pixels around the edges to intermediate colors or gray scales. E.g. Anti-aliasing disabled: E.g. Anti-aliasing enabled:

3 Anti-aliasing Anti-aliasing disabled Anti-aliasing enabled

4 Anti aliasing techniques
1) Pre-Filtering and Post Filtering are the two types general purpose anti-aliasing technique. 2) The Concept of filtering originates from the field of signal processing. 3) Where the intensity values are continuous signals that consist of elements of various frequencies. 4) Constant intensity Values that correspond to a uniform region are at low end of the frequency range. 5) Intensity values that change Abruptly and correspond to sharp edge are at a high end of the spectrum.

5 6) In order to lessen the jagged appearance of lines and other contours in the image space we seek to smooth out sudden intensity changes, or in signal processing terms to filter out the high frequency components. 7) A pre-Filtering technique works on the true signal in the continuous space to derive proper values for individual pixel(Filtering before sampling) 8) A post Filtering technique takes discrete samples of the continuous signal and uses the samples to compute pixel values( Sampling Before Filtering).

6 Area Sampling: Area Sampling is a pre-filtering technique in which we superimpose a pixel grid pattern onto continuous object definition. For each pixel area that intersects the object, we calculate the percentage of overlap by the object. This percentage determines the portion of the overall intensity value of the corresponding pixel that is due to the object contribution. In other words the higher the percentage of overlap the greater influence the object has on the pixel’s overall intensity value.

7 Super Sampling In this approach we subdivide each pixel into sub pixels and check the position of each sub pixel in relation to the object to be scan converted. The object contribution to a pixel overall intensity value is proportional to the number of sub pixels that are inside the area occupied by the object. Super sampling is often regarded as a post-filtering technique since discrete samples are first taken and then used to calculate pixel values

8 MID-POINT ELLIPSE

9 Scan Converting Ellipses
F(x,y)<0(x,y) inside the ellipse F(x,y)=0 on the ellipse F(x,y)>0 outside the ellipse 2a is the length of the major axis along the x axis. 2b is the length of the minor axis along the y axis. The midpoint can also be applied to ellipses. For simplicity, we draw only the arc of the ellipse that lies in the first quadrant, the other three quadrants can be drawn by symmetry Computer Graphics, KKU. Lecture 6

10 Scan Converting Ellipses: Algorithm
j > i in region 1 j < i in region 2 Firstly we divide the quadrant into two regions Boundary between the two regions is the point at which the curve has a slope of -1 the point at which the gradient vector has the i and j components of equal magnitude

11

12

13

14 int a,b,xc,yc; float aa,bb,aa2,bb2,fx,fy,x,y,p; void setpixel(int,int,int,int); cout<<"Enter the co-ordinates of centre"; cin>>xc>>yc; cout<<"Enter the major and minort co-ordinates"; cin>>a>>b; x=0; y=b; setpixel(xc,yc,x,y); aa=a*a; bb=b*b; aa2=aa*2; bb2=bb*2; fx=0; fy=aa2*b; p=bb-aa*b+0.25*aa while(fx<fy) { x++; fx=fx+bb2; if(p<0) p=p+fx+bb; else y--; fy=fy-aa2; p=p+fx+bb-fy; } setpixel(xc,yc,x,y); p=bb*(x+0.5)*(x+0.5)+aa*(y-1)*(y-1)-aa*bb; while(y>0) { y--; fy=fy-aa2; if(p>=0) p=p-fy+aa; } else x++; fx=fx+bb2; p=p+fx-fy+aa; setpixel(xc,yc,x,y); getch();

15 void setpixel(int xc, int yc, int x, int y) { putpixel(xc+x, yc+y,11); putpixel(xc-x, yc+y,11); putpixel(xc+x, yc-y,11); putpixel(xc-x, yc-y,11); }

16 Ellipses: Algorithm (cont.)
At the next midpoint, if a2(yp-0.5)<=b2(xp+1), we switch region 1=>2 In region 1, choices are E and SE Initial condition: dinit = b2+a2(-b+0.25) For a move to E, dnew = dold+DeltaE with DeltaE = b2(2xp+3) For a move to SE, dnew = dold+DeltaSE with DeltaSE = b2(2xp+3)+a2(-2yp+2) In region 2, choices are S and SE Initial condition: dinit = b2(xp+0.5)2+a2((y-1)2-b2) For a move to S, dnew = dold+Deltas with Deltas = a2(-2yp+3) For a move to SE, dnew = dold+DeltaSE with DeltaSE = b2(2xp+2)+a2(-2yp+3) Stop in region 2 when the y value is zero. Computer Graphics, KKU. Lecture 6

17 Midpoint Ellipse Algorithm
Computer Graphics, KKU. Lecture 6

18 Midpoint Ellipse Algorithm (cont.)
Computer Graphics, KKU. Lecture 6


Download ppt "Anti Aliasing."

Similar presentations


Ads by Google