Bài giảng Đồ họa hiện thực ảo - Bài 3: Các giải thuật cơ sở - Lê Tấn Hùng

Bài 3:  
Các gii thut cơ sở  
Le Tan Hung  
0913030731  
1
(c) SE/FIT/HUT 2002  
Ni dung  
„ Các gii thut xén ta - Clipping  
„ Các thut toán tô min kín  
„ Phép tô mu  
„ Phép xlý Antialiasing  
2
(c) SE/FIT/HUT 2002  
Xén ta - Clipping  
„ Nhim vcơ bn trong đồ ha là gicác  
phn ca đối tượng la chn nm bên  
ngoài đồ ho.  
„ Xén ta là vic di chuyn tt ccác đối  
tượng hoc các phn ca i tng thuc  
mô hình ngcnh ra bên ngoài ca sthế  
gii thc  
„ Định nghĩa  
Clipping đim  
„ Vic loi tng đim nh ca đối tượng  
thường chm nht là khi đối tượng mà  
phn ln nm ngoài ca shin th.  
„ xmin x xmax  
ymin y ymax  
„ Kthut thc hành là cn thiết để nâng  
cao tc độ trong t
3
(c) SE/FIT/HUT 2002  
Clipping đon thng  
„ Lines are defined by their endpoints, so it should be  
possible just to examine these (in a similar way to points) and  
determine whether or not to clip without considering every  
pixel on the line  
„ We often have windows that are either very large, i.e. nearly  
the whole scene fits inside, or very small, i.e. most of the  
scene lies inside the window  
„ Hence, most lines may be either trivially accepted or rejected  
4
(c) SE/FIT/HUT 2002  
Gii thut Cohen Sutherland  
Outcode  
„ The Cohen-Sutherland line-clipping algorithm is particularly  
fast for “trivial” cases, i.e. lines completely inside or outside  
the window.  
„ Non-trivial lines, i.e. ones that cross a boundary of the  
window, are clipped by computing the coordinates of the new  
boundary endpoint of the line where it crosses the edge of the  
window  
5
(c) SE/FIT/HUT 2002  
6
(c) SE/FIT/HUT 2002  
Gii thut Cyrus-Beck  
Lyang Barsky  
„ The Cohen-Sutherland algorithm requires the window  
to be a rectangle, with edges aligned with the co-  
ordinate axes  
„ It is sometimes necessary to clip to any convex  
polygonal window, e.g. triangular, hexagonal, or  
rotated.  
„ The, and Liang-Barsky line clippers better optimise the  
boundary  
„ Nicholl-Lee-Nicholl reducing redundant boundary  
clipping by identifying edge and corner regions  
7
(c) SE/FIT/HUT 2002  
P = − Dx  
1
q = x x  
1
P = Dx  
2
q = x x  
2
M
1
P3 = − Dy  
P4 = Dy  
q3 = y1 ym  
q4 = yM y1  
8
(c) SE/FIT/HUT 2002  
„ Nếu Pk = 0 : điu đó tương đương vi vic  
đon thng đang xét song song vi cnh  
thk ca hình chnht clipping.  
„ a) Nếu qk < 0 vô nghim)  
„ b)Nếu qk >= 0 thì bt phương trình luôn  
thomãn.  
9
(c) SE/FIT/HUT 2002  
„ Nếu Pk 0 :  
„ uk = qk/Pk.  
„ Pk < 0  
u qk/Pk Ù u uk.  
„ Pk > 0  
u uk u qk/Pk  
u uk vi uk = qk/Pk  
đon thng có dng đi ttrong ra ngoài so vi  
cnh k.  
10  
(c) SE/FIT/HUT 2002  
„ Pk < 0 và uk < 0  
„ uk u< 0 thomãn bt phương trình skhông nm  
trên đon thng cn xét.  
„ => uk snhn là 0 khi uk<0  
„ Pk > 0 và uk > 1  
„ => uk tương ng snhn giá tr1.  
„ đim nm trong ca sclipping sdng như  
sau:  
„ U1 u U2  
11  
(c) SE/FIT/HUT 2002  
qk  
{ }  
U = min 1 u : u = , P > 0  
2
k
k
k
P
k
qk  
{ }  
U = max 0 u : u = , P < 0  
1
k
k
P
k
12  
(c) SE/FIT/HUT 2002  
Nicholl-Lee-Nicholl clipping  
„ Some edges are irrelevant to  
a
clipping, particularly if one vertex  
lies inside region.  
„ Cases:  
„ x1 in  
„ x1 in corner region  
a
„ x1 in edge region  
„ For each case, we generate  
specialized test regions for x2, which  
use simple tests (slope, >, <), and  
tell which edges to clip against.  
13  
(c) SE/FIT/HUT 2002  
Nicholl-Lee-Nicholl (2)  
„ Special cases for each endpoint location and slope  
„ Number of cases explodes in 3D, making it  
1
2
unsuitable  
Reject  
3
4
Top  
Left  
Left, bottom  
Top, Bottom  
14  
(c) SE/FIT/HUT 2002  
Gii thut đường biên (Boundary - File  
Algorithm)  
„ Gii_thut_đường_biên ( x, y )  
Color : biến mu  
Begin  
Color = Readpixel ( x, y );  
If ( Color = mu tô ) or ( Color = mu ng biên )  
Kết thúc vì chm biên  
hoc chm phn đã tô  
Else  
Gii_thut_đường_biên ( x+1, y );  
Gii_thut_đường_biên ( x-1, y );  
Gii_thut_đường_biên ( x, y+1 );  
Gii_thut_đường_biên ( x, y-1 );  
// Thc hin li gii thut vi các đim lân cn  
End.  
15  
(c) SE/FIT/HUT 2002  
Gii thut dòng quét-Scanline cho vic tô  
mu vùng  
round down  
round up  
AET =  
yma current x denominator current numerator  
x
16  
(c) SE/FIT/HUT 2002  
Gii thut tô vùng kín theo mu  
(Pattern Filling)  
„ Phương pháp 1  
„ Phương pháp 2  
17  
(c) SE/FIT/HUT 2002  
Hiu ng răng cưa  
Aliasing  
„ SPATIAL ALIASING, IN PICTURES  
„ moire patterns arise in  
„ image warping & texture mapping  
„ jaggies arise in rendering  
„ TEMPORAL A
„ when resampling an audio signal at a lower  
sampling frequency,  
„ e.g. 50KHz (50,000 samples per second) to  
10KHz  
„ TEMPORAL ALIASING, IN  
FILM/VIDEO  
„ strobing and the “wagon wheel effect”  
„ jaggies in foreground.  
„ jaggies  
18  
(c) SE/FIT/HUT 2002  
Antialiasing  
„ Méo thông tin trong quá trình ly mu tn sthp  
sampling frequency  
„ In raster images – leads to jagged edges with hiu  
ng bc thang – staircase effect  
„ We can reduce effects by antialiasing methods to  
compensate for undersampling  
19  
(c) SE/FIT/HUT 2002  
Occur?  
„ During image synthesis:  
„ when sampling a continuous (geometric) model to create a raster  
image,  
„ e.g. scan converting a line or polygon.  
„ Sampling: converting a continuous signal to a discrete signal.  
„ During image processing and image synthesis:  
„ when resampling a picture, as in image warping or texture mapping.  
sampling rate.  
Example: “zels to snx by sny pixels  
s>1: called upsampling or interpolation  
can lead to blocky appearance if point sampling is used  
s<1: called downsampling or decimation  
can lead to moire patterns(acn)dSEj/aFgIgTi/eHsUT 2002  
20  
Tải về để xem bản đầy đủ
pdf 39 trang yennguyen 13/04/2022 3560
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Đồ họa hiện thực ảo - Bài 3: Các giải thuật cơ sở - Lê Tấn Hùng", để tải tài liệu gốc về máy hãy click vào nút Download ở trên

File đính kèm:

  • pdfbai_giang_do_hoa_hien_thuc_ao_bai_3_cac_giai_thuat_co_so_le.pdf