1 / 59

Chapter 4. Attributes of Graphics Primitives

Chapter 4. Attributes of Graphics Primitives. attribute parameter. primitive 의 디스플레이 방법에 영향을 줌 lines : dotted or dashed, fat or thin, blue or orange areas: one color or multicolor pattern text: from left to right, across screen, vertical columns characters: fonts, colors, sizes

noel-sweet
Download Presentation

Chapter 4. Attributes of Graphics Primitives

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. Chapter 4. Attributes of Graphics Primitives Chapter 4. Attributes of Graphics Primitives

  2. attribute parameter • primitive의 디스플레이 방법에 영향을 줌 • lines : dotted or dashed, fat or thin, blue or orange • areas: one color or multicolor pattern • text: from left to right, across screen, vertical columns • characters: fonts, colors, sizes • object edges: intensity variation for smoothing out the raster stairstep effect Chapter 4. Attributes of Graphics Primitives

  3. attribute option을 그래픽스 패키지에 첨가하는 방법 • 파리미터 리스트에 attributes를 첨가 • 예) line-drawing function에 color, width, or other properties등을 endpoint coordinates에 첨가 • 또 다른 방법으로 현재 attribute values에 대한 시스템 리스트를 유지시키는 방법 • system attribute list를 update하는 함수에 의해 attribute setting이 이루어짐 Chapter 4. Attributes of Graphics Primitives

  4. OpenGL state variables • State variables or state parameters: output primitive 속성 및 기타 parameter (frame buffer의 현재 위치 등) 를 말함 • OpenGL state parameters 에는 color, other primitive attributes, current matrix mode, model-view matrix, current position for the frame buffer, lighting parameters 등이 속함. • OpenGL 의 그래픽스 프리미티브들은 현재의 상태리스트(state list) 속성들과 함께 디스플레이된다. • 속성 변화는 OpenGL 상태의 변경 이후에 지정된 프리미티브에만 영향을 미친다. 상태 변화 이전에 정의된 프리미티브는 속성을 그대로 유지. • 즉, green line 을 그린 후, 현재 color 를 red 로 바꾼 뒤에, red line 을 그림 Chapter 4. Attributes of Graphics Primitives

  5. Color and Grayscale Levels • general purpose raster-scan systems: wide-range of colors 제공, random-scan monitor는 색의 선택 수가 적다. • color options는 0이상의 양수로 코드화되고 CRT 모니터에서는 이러한 코드가 electron beam의 intensity-level settings로 전환된다. • Color plotter는 ink-jet or pen selection을 컨트롤한다. • color information을 frame buffer에 저장하는 방법 1)     칼라 코드를 직접 프레임 버퍼에 저장하는 법 • 칼라를 저장할 최소 기억장소로는 픽셀당 3비트 필요 (Table 4-1) • 픽셀 당 6비트를 이용한다면 R,G, B각각의 electron gun이 2비트씩 이용하여 64 칼라값을 갖게 됨 • 1024*1024의 full-color (24-bit per pixel) RGB system : 3 megabytes 의 기억장소가 필요하게 됨 -> 3byte * 106이므로 3megabytes Chapter 4. Attributes of Graphics Primitives

  6. Table 4-1 The eight color codes for a three-bit per pixel frame buffer (TABLE 4-1) The eight color codes for a three-bit per pixel frame buffer Color Stored color values In frame buffer Displayed Color Red Green Blue Code Black Blue Green Cyan Red Magenta Yellow White 0 1 2 3 4 5 6 7 • 0 0 0 • 0 0 1 • 0 1 0 • 0 1 1 • 0 0 • 1 0 1 • 1 1 0 • 1 1 1 Chapter 4. Attributes of Graphics Primitives

  7. 2) 칼라 코드를 별도의 테이블에 저장하고 인덱스에 의해 테이블에서 픽셀값을 검색하여 이용하는 방법 • 프레임버퍼 값은 칼라테이블의 인덱스로 이용됨 • (그림4-1)의 경우 1700만 칼라팔렛트 중에서 256칼라를 동시에 선택할 수 있음 • 동시에 디스플레이 되는 칼라 수와 프레임버퍼 크기를 1 megabyte로 축소시킨다. • 그래픽스 시스템에 따라 픽셀당 9비트를 제공하는 경우가 있다. • 유저에게 512칼라를 제공하게 됨 -> 29 = 512로부터 Chapter 4. Attributes of Graphics Primitives

  8. Figure 4-1 A color lookup table with 24 bits per entry that is accessed from a frame buffer with 8 bits per pixel Color lookup table 0 y 196 x 196 2081 255 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 Red Green Blue Chapter 4. Attributes of Graphics Primitives

  9. Gray Scale • color capability가 없는 모니터의 경우에도 color function을 이용하여 grayscale (명암)을 표시 • 0에서 1사이의 숫자로 grayscale level을 표시하고 바이너리 코드로 전환됨. • 픽셀당 3비트를 이용한다면 8 gray level을 표시 • 픽셀당 8비트를 이용한다면 256 개 명암을 표시할 수 있다. Chapter 4. Attributes of Graphics Primitives

  10. Intensity Codes for a Four-Level Grayscale System Intensity Codes Stored Intensity Values In the Frame Buffer (Binary Code) Displayed Grayscale Black Dark gray Light gray White 0.0 0.33 0.67 1.0 0 (00) 1 (01) 2 (10) 3 (11) Chapter 4. Attributes of Graphics Primitives

  11. OpenGL Color Functions • glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); • glColor3f (0.0, 1.0, 1.0); • glColor3fv (colorArray); • glColor3i (0, 255, 255); • glIndexi (196); // Color-Index Mode • glutsetcolor (index, red, green, blue); • glEnable (GL_BLEND); • color blending: source color 와 destination color 를 합침 • source color: 첫 객체의 color를 frame buffer 에 올린 후에 두 번째 객체의 color를 프레임버퍼 컬러와 결합한다. • glDsiable (GL_BLEND); Chapter 4. Attributes of Graphics Primitives

  12. glEnableClientState (GL_COLOR_ARRAY); • color 위치와 형식 지정 • glColorPointer (nColorComponents, dataType, offset, colorArray); typedef Glint vertex3 [3], color3 [3]; vertex3 pt[8] = { {0, 0, 0}, {0, 1, 0}, … } color3 hue[3] = {{1, 0, 0}, {1, 0, 0}, …} glEnableClientState (GL_VERTEX_ARRAY); glEnableClientState (GL_COLOR_ARRAY); glVertexPointer (3, GL_INT, 0, pt); glColorPointer (3, GL_INT, 0, hue); Chapter 4. Attributes of Graphics Primitives

  13. Other OpenGL Color Functions • glClearColor (red, green, blue, alpha); • glClear (GL_COLOR_BUFFER_BIT); • glClearIndex (index); Chapter 4. Attributes of Graphics Primitives

  14. Point Attributes • 점의 기본 속성: color, size • 점의 color 와 size 는 현재의 attribute list 에 저장된 값으로 결정됨 • raster system 에서는 point size는 pixel size의 복수배로 표시 Chapter 4. Attributes of Graphics Primitives

  15. Line Attributes • 직선의 기본 속성: type, width, color • Line type: solid-lines, dashed lines, dotted lines • line drawing algorithm에서 line path를 따라 디스플레이되는 solid section의 길이와 간격을 지정하여 선분을 생성하도록 한다 • pixel mask이용하여 span length 및 interspan spacing • 1과 0을 이용하여 그릴 픽셀 위치를 지정 • Line width • output device 능력에 좌우됨 • line-width value로 선분의 두께를 지정 • 기울기가 1보다 작을 때: 선분의 두께를 수직상에 있는 픽셀 수로 나타냄 (그림4-2) • 기울기가 1보다 클 때: 수평상의 픽셀로 선분의 두께를 나타냄 (그림4-3) Chapter 4. Attributes of Graphics Primitives

  16. Figure 4-2 A double-wide raster line with slope |m| < 1.0 generated with vertical pixel spans Chapter 4. Attributes of Graphics Primitives

  17. Figure 4-3 A raster line with slope |m| > 1.0 and a line width of 4 plotted using horizontal pixel spans Chapter 4. Attributes of Graphics Primitives

  18. 문제점 • 선분의 기울기가 두께에 영향을 미침: 45도 선분이 수평이나 수직선에 비해 얇다 • 선분의 끝처리 문제 : line caps 로 해결 (그림4-4) • 서로 다른 기울기의 선분이 합쳐진 경우 두선분이 결합된 위치에서 별도의 처리 필요 (그림4-5) – miter poin, round join, bevel join • Pen and brush options • shape, size, pattern 포함 (그림4-7) • pixel mask에 여러가지 모양을 저장해 두고 선분을 따라 해당 모양을 디스플레이 함 Chapter 4. Attributes of Graphics Primitives

  19. Figure 4-4 Thick lines drawn with (a) butt caps, (b) round caps, and (c) projected square caps Chapter 4. Attributes of Graphics Primitives

  20. Figure 4-5 Thick line segments connected with a miter join (a), a round join (b), and a bevel join (c) Chapter 4. Attributes of Graphics Primitives

  21. Curve Attributes • colors, widths, dot-dash patterns, pen or brush options를 변화시켜 곡선의 속성을 바꿈 • pixel mask 이용 • dashed, dotted pattern생성시 (그림4-12) • 예) 11100을 이용한다면 • 다양한 폭으로 raster curve를 생성할 때: horizontal or vertical pixel spans를 이용 • 기울기가 1보다 작으면 vertical span, 1보다 크면 horizontal span을 이용 (그림4-10) • thick curve 디스플레이 • 2개 평행한 curve paths사이의 area를 채우는 방법으로 해결 • 지정된 curve path를 one boundary로 이를 inside or outside로 shift한 것을 second boundary로 한다. Chapter 4. Attributes of Graphics Primitives

  22. Figure 4-12 A dashed circlular arc displayed with a dash span of 3 pixels and an inter-dash spacing 2 pixels Chapter 4. Attributes of Graphics Primitives

  23. Figure 4-10 A circular arc of width 4 plotted with either vertical and horizontal pixel spans, depending on the slope Chapter 4. Attributes of Graphics Primitives

  24. pen or brush displays of curves • 선분의 경우와 비슷하게 처리 • 곡선의 line path를 따라 pen shape 을 복제해 감 • 펜의 중심이 curve shape를 따라 연속적으로 이동함 Chapter 4. Attributes of Graphics Primitives

  25. OpenGL Point-Attribute Functions • glPointSize (size); • Point size 1.0: a single pixel • Point size 2.0: 2 by 2 pixel array glColor3f(1.0, 0.0, 0.0); glBegin (GL_POINTS); glVertex2i (50, 100); glPointsize (2.0); glColor3f (0.0, 1.0, 0.0); glVertex2i (75, 150); glPointsize (3.0); glColor3f (0.0, 0.0, 1.0); glVertex2i (100, 200); glEnd( ); Chapter 4. Attributes of Graphics Primitives

  26. OpenGL Line-Attribute Functions • OpenGL Line-Width Function • glLineWidth (width); • OpenGL Line-Style Function • glLineStipple (repeatFactor, pattern); Chapter 4. Attributes of Graphics Primitives

  27. Area-Fill Attributes • Fill Options: • solid color or patterned fill중에 선택 • color와 pattern의 선택 • brush, transparency parameter 이용 • polygon region or 곡선 내부의 영역에 fill options을 적용 • Fill style (그림4-17) • hollow, solid, pattern, hatch • other fill options: edge type, edge width, edge color 등 • Pattern Fill • tiling: 직사각형 패턴으로 영역을 채우는 것을 말함 • 평행사변형 영역에 흑백의 패턴을 디스플레이 • scanline procedure에서 스캔라인 위를 패턴이 지나가도록 영역을 채워나감 Chapter 4. Attributes of Graphics Primitives

  28. Figure 4-17 Basic polygon fill styles: hollow, solid, patterned Chapter 4. Attributes of Graphics Primitives

  29. Hatch (평행선) fill (그림4-18) • 여러 개 평행선이 디스플레이되도록 영역을 채워나감 • hatch line의 간격이나 기울기는 hatch table의 파라미터로서 세트된다 • Soft Fill (or tint-fill algorithm) • fill color와 background color를 결합하여 영역을 나타냄 • 경계선에서의 fill color를 흐리게 하여 엣지의 antialias현상을 희미하게 만드는데 이용 • 원래 반투명이었던 brush를 brush color와 background color의 혼합으로 칼라 영역을 다시 칠하는데 이용 Chapter 4. Attributes of Graphics Primitives

  30. Figure 4-18 Area filled with hatch patterns: diagonal hatch, diagonal crosshatch Chapter 4. Attributes of Graphics Primitives

  31. linear soft-fill algorithm • foreground color F와 background color B 를 합쳐서 다시 칠하는 방법 • 한 영역 내의 각 픽셀의 칼라 P는 F와 B의 linear combination으로 다시 구해짐 • P = tF + (1-t) B t: transparency factor, 0 에서 1사이의 한 값을 가짐 • P = (PR, PG, PB) • F = (FR, FG, FB) • B = (BR, BG, BB) Chapter 4. Attributes of Graphics Primitives

  32. Filled-area primitives • solid-color or patterned polygon area • 두 가지 방법으로 area를 채움 : •  area를 지나는 scan lines들이 area에 겹치는 구간을 결정해 가는 방법 (scan line polygon fill algorithm) • 주어진 내부의 한 점으로 부터 바깥쪽으로 경계선까지 픽셀을 채워가는 방법 (Boundary fill algorithm) • Scan-Line Polygon Fill Algorithm • 스캔라인이 폴리곤을 지나칠 때 스캔라인과 폴리곤의 엣지를 교차하는 점들을 구해 소트해서 각 교차점의 쌍들간을 지정된 색으로 채움 • (그림4-20) • 엣지와의 교차점의 수가 홀수이더라도 왼쪽부터 2개씩 짝지워 처리할 수 있는 경우가 있고 짝수인데도 두개씩 짝지우면 원하는 결과가 나오지 않을 경우도 있다. -> (그림4-21) • 스캔라인에 대한 교차하는 선분의 상대적 위치로 해결 • 두 개 교차하는 엣지가 스캔라인으로부터 서로 다른 쪽에 위치할 경우엔 별도의 처리를 한다 : 교차점을 2개로 하지 않고 1개로 한다. Chapter 4. Attributes of Graphics Primitives

  33. Figure 4-20 Interior pixels along a scan line y x 10 14 18 24 Chapter 4. Attributes of Graphics Primitives

  34. Figure 4-21 Intersection points along scan lines 1 Scan Line y’ 1 2 2 1 1 1 Scan Line y Chapter 4. Attributes of Graphics Primitives

  35. 폴리곤의 경계를 시계방향 혹은 반시계방향으로 추적하면서 엣지를 구성하는 끝점의 y값의 비교 위치를 검사한다. • 두 개 연속된 엣지들의 y 값이 단조 증가 혹은 단조 감소일 경우엔 스캔라인과 두 엣지가 교차하는 중간의 점을 단일 교차점으로 계산한다. • 연속된 두 엣지들의 y값이 단조증가나 단조감소가 아닌경우엔 공유된 점은 local extremum (minimum or maximum)의 형태를 구성하는 경우로 그대로 2개 교차점으로 생각한다. • 단조증가 혹은 단조감소로 한 점이 공유되어 있을 경우엔 아래쪽에 위치한 엣지의 y 값을 1 증가 혹은 감소시켜 스캔라인과의 교차점을 한개가 되도록 처리한다 (그림4-22) Chapter 4. Attributes of Graphics Primitives

  36. Figure 4-22 Adjusting endpoints y values for a polygon Scan Line y+1 Scan Line y Scan Line y-1 Chapter 4. Attributes of Graphics Primitives

  37. Boundary-Fill Algorithm • 내부 한점에서 출발하여 경계선을 향하여 색칠해가는 방법(그림4-26) • interactive painting packages에 유용 • Procedure • 내부의 한 점 (x, y), fill color, boundary color를 입력받아, (x, y)에서 출발하여 인접한 픽셀이 boundary color인지를 첵크하여 아니면 fill color를 주고 다시 인접한 픽셀로 테스트를 계속해감 • two methods: (그림4-27) • 4-connected • 8-connected Chapter 4. Attributes of Graphics Primitives

  38. Figure 4-26 Example color boundaries for a boundary-fill procedure Chapter 4. Attributes of Graphics Primitives

  39. Figure 4-27 Fill methods applied to a 4-connected area and to an 8-connected area Chapter 4. Attributes of Graphics Primitives

  40. Polygon Fill Areas • polygon: • vertex 라고 부르는 좌표점으로 구성된 평면의 모양으로 이 점들은 선분으로 연결되어 있음. • Polygon Classifications • Convex polygon • Concave polygon Chapter 4. Attributes of Graphics Primitives

  41. Character Generation • typeface (활자): characters를 위한 design style을 말함: • 수백개의 typeface가 있슴 • 예) Courier, Helvetica, New York, .... • font: 특정 사이즈와 포맷으로 된 문자체을 말함 • 예) 10-point Courier Italic등 • 요즘엔 typeface와 구별 없이 씀 • typeface (or font)는 두 타입으로 분류 • serif: 문자 획의 끝에 small lines 혹은 accents 포함 • more readable • good for longer blocks of text • sans-serif: accents를 포함하지 않음 • easier to recognize • good for labeling and short heading Chapter 4. Attributes of Graphics Primitives

  42. computer font의 표현 방법 (그림4-35) • 사각형의 그리드 패턴 이용하는 방: bitmap font라고 함 • frame-buffer위치와 그대로 매핑되므로 간단하나 space의 낭비가 있다. • bold나 italic 같은 경우에 별로 좋은 결과를 주지 않음 • 문자형을 직선이나 곡선을 이용하는 방법: outline font라고 함 • storage를 절약하나 시간이 걸리는 단점이 있다. : 계산 후 다시 frame-buffer로 스캔 컨버트해야 하므로 Chapter 4. Attributes of Graphics Primitives

  43. Figure 4-35 The letter B represented with 8 by 8 bitmap pattern and with an outline shape 1 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 Chapter 4. Attributes of Graphics Primitives

  44. Character Attributes • font, size, color, orientation 등으로 속성을 나타냄 • Text attributes • font및 각 폰트에 대해 underlining styles, boldface, italics, outline, shadow를 가짐 • text size: • character width의 크기를 조정하거나 height, width의 크기로 조정함 • point: size of the body of a character를 나타냄 • 1 point는 0.013837 inch (1/72 inch)이며 point로 문자의 몸체(body)의 크기를 나타냄 • 지정된 사이즈의 폰트 내에서 어느 문자도 topline과 bottom line의 거리가 일정하다. • character height: base line과 cap line의 거리를 의미하며 height만으로도 텍스트의 크기를 조정할 수 있다 Chapter 4. Attributes of Graphics Primitives

  45. Chapter 4. Attributes of Graphics Primitives

  46. proportionally spaced fonts: • i, j, l과 같은 narrow characters는 w, m과 같은 broad characters에 비해 폭이 좁게 표시된다 • kerned characters (b, h, f, p, g, y등 상하로 돌출한 부분): bottom line을 벗어나게 표현됨 Chapter 4. Attributes of Graphics Primitives

  47. Antialiasing • aliasing: raster algorithm으로 디스플레이된 물체는 sampling process에 의해 discrete integer pixel position의 좌표점들을 표시하기 때문에 계단식의 들쑥날쑥한 모양을 나타내게 된다. 이와 같이 low-frequency sampling때문에 나타난 현상을 aliasing이라고 하고 antialising method로 개선할 수 있다. • antialiasing methods의 종류 • supersampling (postfilitering): 실제 이용할 수 있는 것보다 작은 그리드인 것처럼 스크린을 처리하여 sampling rate를 증가시켜 higher resolution의 특징으로 샘플링한 다음 low resolution에 다시 디스플레이하는 방법 • area sampling (prefiltering): 디스플레이될 물체와 각 픽셀이 overlap하는 부분을 계산하여 pixel intensity를 정함 • pixel phasing: pixel areas의 디스플레이 위치를 shift시킴 (물체의 geometry에 대해electron beam을 micropositioning) Chapter 4. Attributes of Graphics Primitives

  48. Supersampling Straight Line Segments • 각 픽셀을 subpixel로 분할하고 line path가 통과하는 subpixel의 수를 세어, 각 픽셀의 intensity를 이러한 subpixel count로서 정함 (gray-scale display에서) (그림4-47) • 각 픽셀을 9개 서브픽셀로 나누었을 때 intensity level을 3개로 나눌 수 있다 • intensity level의 수를 증가시키려면 서브픽셀의 수를 증가시킴. 예를 들어 16개 서브픽셀은 4개의 intensity level을 가질 수 있다 • 선분의 폭을 생각한 경우엔 각 픽셀에 대한 intensity level의 수가 9개로 증가시킬 수 있슴 (각 픽셀을 9개 서브픽셀로 나누었을 경우, 그림4-48) • color display일 경우 background color를 고려하여 라인의 색을 정할 수 있음 Chapter 4. Attributes of Graphics Primitives

  49. 예) subpixel intensities를 평균한 픽셀 값을 계산할 수 있음 • red line의 경계내부에 5개 subpixel이 존재하고 남은 4개 subpixel이 blue background area에 있다면 이 픽셀을 위한 색을 • pixelcolor = (5 * red + 4 * blue) / 9 로 나타낼 수 있다. • pixel-weighting masks • pixel area의 중앙에 가깝게 위치한 subpixel에 weight를 크게 주도록 실행할 수 있슴 (그림4-49) Chapter 4. Attributes of Graphics Primitives

  50. Figure 4-47 Supersampling subpixel positions along a straight line segment 22 21 20 10 11 12 Chapter 4. Attributes of Graphics Primitives

More Related