1 / 30

3 장 . 2 차원 기본 객체를 그리기 위한 기본적인 래스터 그래픽스 알고리즘

3 장 . 2 차원 기본 객체를 그리기 위한 기본적인 래스터 그래픽스 알고리즘. 한림대학교 정보통신공학부 송 창근. 그림 3.1 사각형 모양의 클리핑 영역에서 SRGP 기본객체 클리핑하기 (a) 기본 객체와 클리핑 사각형 (b) 클리핑된 결과. 3.1 개관 (Overview). 3.1.1 디스플레이 시스템 구조 (Implications of Display-System Architecture). 그림 3.2 응용 프로그램과 그래픽스 시스템의 중개자인 SRGP 는 입출력 파이프라인을 제공한다.

juliet
Télécharger la présentation

3 장 . 2 차원 기본 객체를 그리기 위한 기본적인 래스터 그래픽스 알고리즘

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3장. 2차원 기본 객체를 그리기 위한 기본적인 래스터 그래픽스 알고리즘 한림대학교 정보통신공학부 송 창근

  2. 그림3.1 사각형모양의클리핑영역에서SRGP 기본객체클리핑하기 (a)기본객체와클리핑사각형(b) 클리핑된결과

  3. 3.1 개관(Overview) 3.1.1 디스플레이시스템구조 (Implications of Display-System Architecture) 그림3.2 응용프로그램과그래픽스시스템의중개자인SRGP는입출력파이프라인을제공한다

  4. 그림 3.3 SRGP가구동하는두가지유형의디스플레이시스템. (a)디스플레이컨트롤러와프레임버퍼를가진디스플레이주변장치(b) 디스플레이컨트롤러를갖지않은메모리공유프레임버퍼

  5. 3.2 직선의주사변환(Scan Converting Lines) 그림3.4 주사변환한직선

  6. 3.2.1 기본적인점증알고리즘(The Basic Incremental Algorithm) 그림3.5 (x,y)의점증계산

  7. 프로그램3.1 (직선주사변환을위한점증알고리즘) void Line(int x0, int y0, int x1, int y1, int value) { /* Assumes -1 <= m <= 1, x0 < x1 */ int x; /* x runs from x0 to x1 in unit increments.*/ float dy,dx,y,m; dy = y1 - y0; dx = x1 - x0; m = dy/dx; y = y0; for( x=x0; x<=x1; x++ ){ WritePixel(x,(int)floor(y+0.5),value); /* Set pixel to value */ y+=m; /* Step y by slope m */ } }

  8. 3.2.2 중간점직선알고리즘(Midpoint Line Algorithm) void MidpointLine(int x0, int y0, int x1, int y1, int value) { int dx, dy, incrE, incrNE, d, x, y; dx = x1 - x0; dy = y1 - y0; d = dy*2 - dx; /* Initial value of d */ incrE = dy*2; /* Increment used for move to E */ incrNE = (dy-dx)*2; /* Increment used for move to NE */ x = x0; y = y0; WritePixel(x, y, value); /* The start pixel */ while(x < x1){ if(d <= 0){ /* Choose E */ d += incrE; x++; }else{ /* Choose NE */ d += incrNE; x++; y++; } WritePixel(x, y, value); /* The selected pixel closest to the line */ } } 프로그램3.2 중간점직선주사변환알고리즘

  9. 그림3.6 중간점직선알고리즘을위한픽셀격자

  10. 그림3.7 점(5,8)에서점(9,10)까지의중간점직선

  11. 3.2.3 문제점들(Additional Issues)

  12. 그림3.9. 기울기의함수로직선의강도에변화를줌

  13. 3.3 원의주사변환(Scan Converting Circles) 그림3.10 x 값을하나씩증가시켜가며y값을계산하여원을그려만들어진4분원

  14. 3.3.1 8 방향대칭성(Eight-way Symmetry) 그림3.11 원위의8개의대칭점

  15. Void CirclePoints (float x, float y, int value); { WritePixel(x,y,value); WritePixel(y,x,value); WritePixel(y,-x,value); WritePixel(x,-y,value); WritePixel(-x,-y,value); WritePixel(-y, -x,value); WritePixel(-y,x,value); WritePixel(-x,y,value); } CirclePoint 함수

  16. 그림3.12 중간점원일고리즘을위한픽셀격자

  17. void MidpointCircle(int radius, int value) { int x, y; float d; x = 0; /* Initialization */ y = radius; d = 5.0/4 - radius; CirclePoints(x, y, value); while(y > x){ if(d < 0){ /* Select E */ d += x*2.0 + 3; x++; }else{ /* Select SE */ d += (x - y)*2.0 + 5; x++; y--; } CirclePoints(x, y, value); } } 프로그램3.3 (중간점원주사변환알고리즘)

  18. void MidpointCircle(int radius, int value) { int x, y, d; x = 0; /* Initialization */ y = radius; d = 1 - radius; CirclePoints(x, y, value); while(y > x){ if(d < 0){ /* Select E */ d += x*2 + 3; x++; }else{ /* Select SE */ d += (x -y )*2 + 5; x++; y--; } CirclePoints(x, y, value); } } 프로그램3.4 (정수형중간점원주사변환알고리즘)

  19. 그림3.13 두번째8분원은중간점알고리즘으로, 첫번째8분원은대칭성을이용하여만들어졌다

  20. void MidpointCircle(int radius, int value) { /* This function uses second-order partial differences to compute increments in the decision variable. Assumes center of circle is at origin. */ int x, y, d, deltaE, deltaSE; x = 0; /* Initialization */ y = radius; d = 1 - radius; deltaE = 3; deltaSE = 5 - radius * 2; CirclePoints(x, y, value); while (y > x) { if (d < 0) { /* Select E */ d += deltaE; deltaE += 2; deltaSE += 2; x++; } else { /* Select SE */ d += deltaSE; deltaE += 2; deltaSE += 4; x++; y--; } CirclePoints(x, y, value); } } 프로그램3.5 (2차편차를이용한중간점원주사변환알고리즘)

  21. 3.4 사각형채우기(Filling Rectangles)

  22. 3.5 다각형채우기(Filling Polygons) 그림3.14 다각형과8번주사선 : (2, 4.5, 8.5, 13)

  23. 그림3.15 다각형을위한스팬. 양끝점은검은색으로, 내부픽셀은회색으로그려짐. (a)양끝점은중간점알고리즘으로계산되었다. (b) 다각형내부에놓여진양끝점.

  24. 다각형 채우기의 3단계 • 다각형의 모든 선분과 주사선의 교차점을 구한다. • 그 교차점들을 x가 증가하는 방향으로 정렬한다 • 교차점 쌍들 사이의 모든 픽셀을 채운다. • 3.1 교차점의 값이 실수값일 때, 그 교차점의 어느쪽 픽셀을 내부로 결정할 것인가? • 3.2 교차점의 픽셀 좌표가 정수일 때 어떻게 처리하는가? • 3.3 공유하는 꼭지점들은 어떻게 처리할 것인가? • 3.4 수평 선분의 픽셀들은 어떻게 처리할 것인가?

  25. 3.5.1 수평선분(Horizontal Edges) 그림3.16 다각형의수평선분.

  26. 3.5.2 끝이뽀족한다각형(Silvers) 그림3.17 끝이뾰족한다각형의주사변환

  27. 3.5.3 선분일관성과주사선알고리즘(Edges Coherence and the Scan-Line Algorithm) void LeftEdgeScan(int xmin, int ymin, int xmax, int ymax, int value) { int x, y, numerator, denominator, increment; x = xmin; numerator = xmax - xmin; denominator = ymax - ymin; increment = denominator; for (y = ymin; y < ymax; y++) { WritePixel(x, y, value); increment += numerator; if (increment > denominator) { /* Overflow, so round up to next pixel and decrement the increment */ x += 1; increment -= denominator; } } } 프로그램3.6 (다각형왼쪽선분의주사변환)

  28. 그림3.18 그림3.14 의다각형에대한버켓정렬된선분테이블(Edge Table, ET)

  29. 그림3.19 그림3.14의다각형에대한활동-선분테이블 (AET, Active Edge Table) (a)9번주사선(b) 10번주사선

  30. 주사선 알고리즘 • ET의 비어 있지 않은 첫 버켓 번호를 스팬 생성을 시작할 주사선의 위치 Y로 잡는다. • AET 가 비어 있도록 초기화 시킨다. • AET와 ET 가 비워질 때가지 다음을 반복한다. • ET의 버켓 Y의 모든 선분을 AET로 옮기고, AET 의 모든 선분을 주사선과 교차하는 x 좌표값 X가 증가하는 방향으로 정렬한다. • AET의 X 쌍을 사용해서 주사선 Y에 원하는 픽셀을 채운다. • Y=ymax 인 선분, 즉, 다음의 주사선 Y+1 과 교차하지 않는 선분을 AET에서 지운다. • Y를 1만큼 증가 시킨다. • AET에 남아 있는 선분 중 수직 선분이 아닌 모든 선분의 X값을 새로운 주사선과 교차하는 점의 x 좌표값으로 수정한다.

More Related