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
Xén tỉa - Clipping
Nhiệm vụ cơ bản trong đồ họa là giữ các
phần của đối tượng lựa chọn nằm bên
ngoài đồ hoạ.
Xén tỉa là việc di chuyển tất cả các đối
tượng hoặc các phn ca i tng thuc
mô hình ngữ cảnh ra bên ngoài của sổ thế
giới thực
Định nghĩa
Việc loại từng điểm ảnh của đối tượng
thường chậm nhất là khi đối tượng mà
phần lớn nằm ngoài cửa sổ hiển thị.
Kỹ thuật thực hành là cần thiết để nâng
cao tốc độ trong t
3
(c) SE/FIT/HUT 2002
Clipping đoạn thẳng
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
4
(c) SE/FIT/HUT 2002
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
Giải thuật 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.
boundary
clipping by identifying edge and corner regions
7
(c) SE/FIT/HUT 2002
Nếu Pk = 0 : điều đó tương đương với việc
đoạn thẳng đang xét song song với cạnh
thứ k của hình chữ nhật clipping.
a) Nếu qk < 0 ⇒ vô nghiệm)
thoả mãn.
9
(c) SE/FIT/HUT 2002
Pk < 0 và uk < 0
uk ≤ u< 0 thoả mãn bất phương trình sẽ không nằm
trên đoạn thẳng cần xét.
=> uk sẽ nhận là 0 khi uk<0
Pk > 0 và uk > 1
=> uk tương ứng sẽ nhận giá trị 1.
sau:
U1 ≤ u ≤ U2
11
(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
Algorithm)
Giải_thuật_đường_biên ( x, y )
Color : biến mầu
Begin
Color = Readpixel ( x, y );
If ( Color = mầu tô ) or ( Color = mu ng biên )
Kết thúc vì chạm biên
hoặc chạm phần đã tô
Else
Giải_thuật_đường_biên ( x+1, y );
Giải_thuật_đường_biên ( x-1, y );
Giải_thuật_đường_biên ( x, y+1 );
Giải_thuật_đường_biên ( x, y-1 );
// Thực hiện lại giải thuật với các điểm lân cận
End.
15
(c) SE/FIT/HUT 2002
(Pattern Filling)
Phương pháp 1
Phương pháp 2
17
(c) SE/FIT/HUT 2002
Hiệu ứ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 lấy mẫu tần số thấp
sampling frequency
ứng bậc thang – staircase effect
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:
sampling rate.
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 đủ
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:
- bai_giang_do_hoa_hien_thuc_ao_bai_3_cac_giai_thuat_co_so_le.pdf