Docsity

Computer Graphics, lecture notes, UPTU, Study notes of Computer Graphics and Animation

Toggle sidebar
bg1
Concept based notes
Computer Graphics
M.Sc. IT
Bindiya Patel
BE (I.T.)
Lecturer
Deptt. of Information Technology
Biyani Girls College, Jaipur
Syllabus
M.Sc. IT
Computer Graphics
1. Graphic Application and Hardware : Need of Graphics, Display and
Input
Devices.
2. Transformation : Matrix Representation and Homogeneous Coordinates :
Basic
Transformations-2-dimensions and 3-dimensions : Translations, Scaling and
Rotations.
3. Output Primitives : Line Drawing Algorithms : DDA Bresenham Line
Drawing,
Circle Drawing Midpoint Algo, Ellipse Generating Midpoint Algo.
4. Clipping : Sutherland – Cohen Algo, Cyrus, Beck Algo.
5. Hidden Surface Removal : Back Face Detection, Depth Buffer, Depth
Sorting,
Scan Line and A Buffer Techniques.
6. Curves and Surface : Hermit Curves, Bezier Curves, B – Spline Curves,
Properties and Continuity Concepts.
7. Image Processing : Capture and Storage of Digital Images, File Formats,
Basic
Digital Techniques like Convolutions the Holding and Histogram
Manipulations,
Image Enhancement, Geometric Manipulation and their Applications the
Automatic Identification and Extraction of Objects of Interest.
8. Multimedia : Hardware, Software Application, Non Temporal Media : Text,
Hypertext, Images, Cameras, Scanner, Frames Grabbers, Formats; Audio :
Analog Video Operations, Compression, Digital Video MPEG, JPEG; Graphics
Animation : Tweaking, Morphing Motion Specification, Simulating
Acceleration.
□ □ □
For more detail: - http://www.gurukpo.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37

Partial preview of the text

Download Computer Graphics, lecture notes, UPTU and more Study notes Computer Graphics and Animation in PDF only on Docsity!

Concept based notes

Computer Graphics

M.Sc. IT

Bindiya Patel

BE (I.T.)

Lecturer

Deptt. of Information Technology

Biyani Girls College, Jaipur

Syllabus

M.Sc. IT

Computer Graphics

  1. Graphic Application and Hardware : Need of Graphics, Display and Input Devices.
  2. Transformation : Matrix Representation and Homogeneous Coordinates : Basic Transformations-2-dimensions and 3-dimensions : Translations, Scaling and Rotations.
  3. Output Primitives : Line Drawing Algorithms : DDA Bresenham Line Drawing, Circle Drawing Midpoint Algo, Ellipse Generating Midpoint Algo.
  4. Clipping : Sutherland – Cohen Algo, Cyrus, Beck Algo.
  5. Hidden Surface Removal : Back Face Detection, Depth Buffer, Depth Sorting, Scan Line and A Buffer Techniques.
  6. Curves and Surface : Hermit Curves, Bezier Curves, B – Spline Curves, Properties and Continuity Concepts.
  7. Image Processing : Capture and Storage of Digital Images, File Formats, Basic Digital Techniques like Convolutions the Holding and Histogram Manipulations, Image Enhancement, Geometric Manipulation and their Applications the Automatic Identification and Extraction of Objects of Interest.
  8. Multimedia : Hardware, Software Application, Non Temporal Media : Text, Hypertext, Images, Cameras, Scanner, Frames Grabbers, Formats; Audio : Analog Video Operations, Compression, Digital Video MPEG, JPEG; Graphics Animation : Tweaking, Morphing Motion Specification, Simulating Acceleration.

For more detail: - http://www.gurukpo.com

Content

S.No. Name of Topic Page No.

1. Graphics Application and Hardware 7- 1.1 Introduction to Computer Graphics 1.2 Application of Computer Graphics 1.3 Video Display Devices 1.4 Raster Scan Displays 1.5 Random Scan Displays 1.6 Color CRT Monitor 1.7 Shadow Mask Methods 2. Transformation 20- 2.1 Transformation in 2-dimension & 3-dimension 2.2 Rotation in 2-dimansion & 3-dimension 2.3 Scaling in 2-dimansion & 3-dimension 2.4 Composite Transformation 2.5 Reflection 2.6 Shear 3. Output Primitives 31- 3.1 Line Drawing Algorithms (a) DDA (b) Bresenham’s Algorithm 3.2 Circle Drawing Algorithm 3.3 Ellipse Drawing Algorithm 3.4 Boundary Fill Algorithm 3.5 Flood Fill Algorithm 4. Clipping Algorithm 50- 4.1 Introduction to Clipping 4.2 Application of Clipping 4.3 Line Clipping Methods (a) Cohen Sutherland Method (b) Cyrus – Beck Algorithm For more detail: - http://www.gurukpo.com **S.No. Name of Topic Page No.

  1. Visible Surface Detection** 59- 5.1 Depth Buffer Method 5.2 Z – Buffer Method 5.3 Object Space Method 5.4 Image Space Method 5.5 Painter’s Algorithm 5.6 Back – Face Detection 5.7 A – Buffer Method 5.8 Scan Line Method 6. Curves and Surfaces 71- 6.1 Bezier Curves and Surfaces 6.2 Properties of Bezier Curves 6.3 B - Spline Line and Surfaces 6.4 Properties of B – Spline Curves 6.5 Hermite Interpolation 6.6 Continuity Conditions

(8) Graphical user Interface : It is common now for software packages to provide a graphical Interface. For more detail: - http://www.gurukpo.com Q.2 What are Video Display Devices? or Explain how Cathode Ray Tube works including details how colors are achieved? Ans.: The primary output device in a graphics system is a video controller. The operation of most video monitors is based on the standard cathode-ray tube (CRT) design. Refresh Cathode Ray Tube : Fig (1) illustrates the basic operation of a CRT The primary components of an electron gun in a CRT are the heated metal cathode and control guide as in Fig 2. Here electron beam is emitted by the electron gun in a CRT. It passes through focusing and deflection system that directs the beam towards specified position on the phosphor coated system. The light emitted by the phosphor fades very rapidly. In order to maintain the screen picture or to keep the phosphor is to redraw the picture repeatedly by quickly directing the electron beam over the same point. This process is called refresh CRT. Fig. Fig. For more detail: - http://www.gurukpo.com Heat is supplied to the cathode by directing a current through a coil of wire called filament, inside the cylindrical cathode structure this heats up the electrons & the heated up electrons move with high positive voltage towards the phosphor screen. Intensity of the electron beam is controlled by setting voltage levels on the control grid. A high negative voltage will shut off the beam by repelling electrons & stopping them from passing through. Amount of light emitted depend on number of electron striking the screen. Focusing system in a CRT is needed to force the electron beam to coverage into a small spot as it strikes the phosphor. Otherwise electron would repel each other. Focusing is accomplished with either electric or magnetic fields. Electrostatic focusing is commonly used in television and computer graphics monitors. With electrostatic focusing, the electron beam passes through a positively charged metal cylinder that forms an electron lens, as shown in Fig. 2-3, The action of the electrostatic lens focuses the electron beam at the center of the screen, in exactly

the same way that an optical lens focuses a beam of light at a particular focal distance. Similar lens focusing effects can be accomplished with a magnetic field setup by a coil mounted around the outside of the CRT envelope. Magnetic lens focusing produces the smallest spot size on the screen and is used in special purpose device. Additional focusing hardware is used in high-precision system to keep the beam in focus at all screen position. The distance that the electron beam must travel to different points on the screen varies because the radius of curvature for most CRTs is greater than the distance from the focusing system to the screen center. There fore, the electron beam properly only at the center of the screen. As the beam moves to the outer edges of the screen, displayed images become blurred. To compensate for this, the system can adjust the focusing according to the screen position of the beam. As with focusing, deflection of the electron beam can be controlled either with electric fields or with magnetic fields. Cathode-ray tubes are now commonly constructed with magnetic deflection coils mounted on the outside of the CRT envelope, as illustrated in Fig. 2-2. Two pairs of coils are used, with the coils in each pair mounted on opposite sides of the neck of the CRT envelop. One pair is mounted on the top and bottom of the neck, the magnetic field produced by each pair of coils results in a transverse deflection force that is perpendicular both to the direction of the magnetic field and to the direction of travel of the electron beam. Horizontal deflection is accomplished with one pair of coils, and vertical deflection by the other pair. The proper deflection amounts are attained by adjusting the current through the coils. When electrostatic deflection is used, two pairs of parallel palates are mounted inside the CRT envelope. One pair of plates For more detail: - http://www.gurukpo.com is mounted horizontally to control the vertical deflection, and the other pair is

number of points per centimeter that can be plotted horizontally and vertically, For more detail: - http://www.gurukpo.com although it is often simply stated as the total number of points in each direction. Spot intensity has a Gaussian distribution (Fig. 2-5), so two adjacent spot will appear distinct as long as their separation is greater than the diameter at which each spot has intensity in Fig. 2-6. Spot size also depends on intensity. As more electrons are accelerated toward the phosphor per second, the CRT beam diameter and the illuminated spot increase. In addition, the increased excitation energy tends to spread to neighboring phosphor atoms not directly in the path of the beam, which further increases the spot diameter. Thus, resolution of a CRT is dependent on the type of phosphor, the intensity to be displayed, and the focusing and deflection system. Typing resolution on high-quality system is 1280 by 1024, with higher resolution available on many systems. High resolution systems are often referred to as high-definition system. The physical size of a graphics monitor is given as the length of the screen diagonal, with sizes varying form about 12 inches to 27 inches or more. A CRT monitor can be attached to a variety of computer systems, so the number of screen points that can actually be plotted depends on the capabilities of the system to which it is attached. Another property of video monitors is aspect ratio. This number gives the ratio of vertical points to horizontal points necessary to produce equal-length lines in both directions on the screen. (Sometimes aspect ratio is stated in terms of the ratio of horizontal to vertical points.) An aspect ratio of ¾ means that a vertical line plotted with three points has the same length as a horizontal line plotted with four points. Q.3 Write short note on Raster–Scan Displays and Random Scan Displays. Ans.: Raster–Scan Displays : The most common type of graphics monitor employing a CRT is the raster-scan display, based on television technology. In a rater- scan

system, the electron beam is swept across the screen, one row at a time from top to bottom. As the electron beam moves across each row, the beam intensity is turned on and off to create a pattern of illuminated spots. Picture definition is stored in a memory area called the refresh buffer or frame buffer. This memory area holds the set of intensity values for all the screen points. Stored intensity values are then retrieved from the refresh buffer and “Painted” on the screen one row (scan line) at a time (Fig. 2-7). Each screen point is referred to as a pixel or pel (shortened forms of picture element ). The capability of a raster-scan system to store intensity information for each screen point makes it well suited for the realistic display of scenes containing subtle shading and color patterns. Home For more detail: - http://www.gurukpo.com television sets and printers ate examples are examples of other system using raster-scan methods. Intensity range for pixel positions depends on the capability of the raster system. In a simple black-and –white system, each screen point is either on or off, so only one bit per pixel is needed to control the intensity of screen position. For a bilevel system, a bit value of 1 indicates that the electron beam is to be turned on at that position, and a value of 0 indicates that the beam intensity is to be off. Additional bits are needed when color and intensity variations can be displayed. Up to 24 bits per pixel are included in high-quality system, which can require several megabytes of storage for the frame buffer, depending on the resolution of the system. A system with 24 bits per pixel and a screen resolution of 1024 by 1024 requires 3 megabytes of storage for the frame buffer. On a black-and- white system with one bit per pixel, the frame buffer is commonly called a bitmap. For system with multiple bits per pixel, the frame buffer is often referred to as a pixmap. Refreshing on raster-scan displays is carried out at the rate of 60 to 80 frames per

random-scan system in any specified order (Fig. 2-9). A pen plotter in a similar way and is an example of a random-scan, hard-copy device. For more detail: - http://www.gurukpo.com Refresh rate on a random-scan system depends on the number of lines to be displayed. Picture definition is now stored as a set of line-drawing commands in an area of memory referred to as the refresh display file. Sometimes the refresh display file is called the display list, display program, or simply the refresh buffer. To display a specified picture, the system cycles through the set of commands in the display file, drawing each component line in turn. After all line drawing commands have been processed, the system cycle back to the first line command in the list. Random-scan displays are designed to draw all the component lines of a picture 30 to 60 times each second. High-quality vector systems are capable of handling approximately 100,000 “short” lines at this refresh rate. When a small set of lines is to be displayed, each refresh cycle is delayed to avoid refresh rates greater than 60 frames per second. Otherwise, faster refreshing of the set of lines could burn out the phosphor. Random-scan systems are designed for line-drawing applications and can-not display realistic shaded scenes. Since picture definition is stored as a set of linedrawing instruction and not as a set of intensity values for all screen points, vector displays generally have higher resolution then raster system. Also, vector displays produce smooth line drawings because the CRT beam directly follows the line path. A raster system, in contrast, produces jagged lines that are plotted as discrete point sets. Q.4 Write short note on Color CRT Monitor. Explain Shadow Mask Method. Ans.: A CRT monitor displays color picture by using a combination of phosphor that emit different-colored light. By combining the emitted light from the different phosphor, a range of colors can be generated. The two basic techniques for producing color displays with a CRT are the beam-penetration method and the shadow-mask method. For more detail: - http://www.gurukpo.com The beam-penetration method for displaying color pictures has been used with

random-scan monitors. Two layers of phosphor, usually red and green, are coated onto the inside of the CRT screen, and the displayed color depends on how far the electron beam penetrates into the phosphor layers. A beam of slow electrons excites only the outer red layer. A beam of very fast electron penetrates through the red layer and excites the inner green layer. At intermediate beam speeds, combinations of red and green light are emitted to show two additional colors, orange and yellow. The speed of the electrons, and hence the screen color at any point, is controlled by the beam-acceleration voltage. Beam penetration has been an inexpensive way to produce color in random-scan monitor, but only four colors are possible, and the quality of picture is not as good as with other methods. Shadow-mask methods are commonly used in raster-scan system (including color TV) because they produce a much wider range of colors than the beam penetration method. A shadow-mask CRT has three phosphor color dots at each pixel position. One phosphor dot emits a red light, another emits a green light, and the third emits a blue light. This type ofCRT has three electron guns, one for each color dot, and a shadow-mask grid just behind the phosphor-coated screen. Figure 2-10 illustrates the delta-delta shadow-mask method, commonly used in color CRT system. The three beams are deflected and focused as a group onto the shadow mask, which contains a series of holes aligned with the phosphordot patterns. When the three beams pass through a hole in the shadow mask, For more detail: - http://www.gurukpo.com they activate a dot triangle, which appears as a small color spot on the screen. The phosphor dots in the triangles are arranged so that each electron beam can activate only its corresponding color dot when it passes through the shadow mask. Another configuration for the three electron guns is an in-line arrangement in which the three electron guns, and the corresponding red- greenblue

swept across the screen, one row at a time from top to bottom. In this, the electron beam is directed only to the parts of the screen where a picture is to be drown.

  1. The pattern is created by illuminated spots. Here a picture is drawn one line at a time.
  2. Refreshing on Raster Scan display is carried out at the rate of 60 to 80 frames per second. Refresh cycle is displayed to aroid refresh rate greater than 60 frames per second for small set of lines. Refresh rate depends on number of lines to be displayed.
  3. This display porous produces smooth line drawings as the CRT beam directly follows the line path. In this display it produces jagged lines that are potted as discrete point sets.
  4. This provides higher resolution. This provides lower resolution.

For more detail: - http://www.gurukpo.com

Chapter-

Transformation

Q.1 What is Transformation? What are general Transformations Techniques? Ans.: Transformation are basically applied to an object to reposition and resize two dimensional objects. There are three transformation techniques. (1) Translation : A translation is applied to an object by repositioning it along a straight line path from one coordinate location to another. We translate a two-dimensional point by adding translation distances t x^ and ty^ to the

original coordinate position (x, y) to more the point to a new position (x’, y’). x’ = x + t x^ , y^ ’^ = y + ty^ _ _ _ (1) The translation distance pair (tx^ , ty^ ) is called translation vector on shift vector : P 1 2 x x F 0 3 D

F 0 2 0^  , P’ 1 2 x ' = x'     , T x y t t   F 0 3 D

F 0 2 0^    _ _ _ (2) 2 – dimensional translation matrix form : P’ = P + T _ _ _ (3) In this case, we would write in matrix as row : P = [x, y] , T = [t x^ , ty^ ] Translation is a rigid body transformation that moves object without deformation. That is T^1 every point on the object is translated by the same amount. A straight line segment is translated by applying the transformation equation (3) to each of the line end point & redrawing the line between the new end point positions. (2) Rotation : A two dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. To generate a rotation, we specify a rotation angle and the position (x, y) of the rotation point (or pivot pt) about which the object is to be rotated figure (1) For more detail: - http://www.gurukpo.com P’ Yr^ θ P Xr This transformation can be described as a rotation about a rotation axis that is perpendicular to the xy plane & passes through the pivot point. We can express the transformation in terms of angle θ & Ø as :

y       = x y s 0 0 s       x y       _ _ _ (11) Or P’ = S. P _ _ _ (12) Where S is 2x2 scaling in eq.(11) any positive numeric values can be assigned to the scaling factors Sx^ and S^ y^ values less than 1 reduce the size of object; values greater than 1 reduce the size of object & specifying a value of 1 for both Sx and Sy^ leaves the size of object unchanged. When Sx^ and S^ y^ are assigned the same value, a uniform scaling is produced that maintains relative object proportions unequal values of S x^ and S^ y^ result in a differential scaling that is often used in design application where picture are constructed form a few basic shapes that can be adjusted by scaling & positioning transformation. Q.2 What are composite Transformation? Give the 3-types of Composite Transformation. Ans.: Composite transformation Matrix can be obtained by calculating. The matrix product of the individual transformations forming products of transformation matrix is often referred to as concatenation or composition of matrices. For more detail: - http://www.gurukpo.com (1) Translation : If two successive translation vectors (t x1^ , ty1^ ) and (tx2^ , ty2^ ) are applied to a coordinate position P, final transformed location P’ is calculated as : P’ = T (tx2^ , ty2^ ). {T (tx1^ , ty1^ ). P} = {T(t^ x2^ , ty2^ ) .T(t^ x1^ , ty1^ )}. P^ _ _ _^ (3) Where P and P’ are represented as homogenous – coordinate column

vectors. We can verify this result by calculating the matrix product for the tow associative groupings. Composite Matrix for this sequence is : x y 1 0 t 0 1 t 0 0 1         x y 1 0 t 0 1 t 0 0 1         = x1 x y1 y 1 0 t + t 0 1 t + t 0 0 1         _ _ _ (4) Or T(t x2, t^ y2^ ). T(tx1^ , t^ y1) = T(t^ x1^ + tx2^ , t^ y1^ + t^ y2)^ _ _ _^ (5) Which shows that two successive translations are additive. (2) Rotations : Two successive rotations applied to point P produce the transformed position : P’ = R(θ 2 ). {P(θ^1 ). P} = {R(θ^2 ). R(θ^1 )}. P _ _ _ (6) By multiplying 2–rotation matrices, we can verify that two successive rotations are additive : R(θ^2 ). R(θ^1 ) = R(θ^1 +^ θ^2 ) _ _ _ (7) So that final rotated coordinates can be calculated with the composite rotation matrix as : P’ = R(θ 1 +^ θ^2 ). P _ _ _ (8) (3) Scaling : Concatenating transformation matrices for 2-successive scaling operations produce the following composite scaling matrix: x y s 0 0 0 s 0 0 0 1  

Fig. 1 Fig-2 : Reflection of an object about y-axis (i) Reflection about the line y =o, the x-axis is accomplished with transformation matrix : 1 0 0 0 -1 0 0 0 1         _ _ _ (8) This transformation keeps x-values the same but flips the y-values of coordinate positions. (ii) Reflection about the y-axis flips x-coordinates keeping ycoordinates the same The matrix for this transformation is : -1 0 0 0 1 0 0 0 1         _ _ _ (9) For more detail: - http://www.gurukpo.com Now elements of the reflection matrix can be set to values other then ± values whose magnitudes are greater than 1 shift the mirror Image farther from the reflection axis & values with magnitude less than 1 brings the mirror image closer to the reflection axis. (2) Shear : A transformation that distorts the shape of an object such that the transformed shape appears as if the object were composed of internal layer that had been caused to slide over each other is called a shear two common shearing transformations are those that shift coordinate x values and those that shift y values. An x-direction shear relative to the x-axis is produced with transformation Matrix. x 1 Sh 0 0 1 0 0 0 1         _ _ _ (3) Which transforms coordinate position as :

x' = x +Shx. y y’ = y _ _ _ (4) Any real number can be assigned to shear parameter Sh x. We can rene5rate x-direction shears relative to other reference lines with. x x ry 1 Sh - Sh .y 0 1 0 0 0 1         _ _ _ (5) With coordinate position transformed as : x' = x + Sh x^ (y -y^ ry) , y’ = y^ _ _ _^ (6) A y-direction shear relative to the line x = x ry^ is generated with translation matrix : y y ry 1 0 0 Sh 1 - Sh .x 0 0 1         _ _ _ (7) Which generates transformed coordinate position x' = x , y’ = Shy^ (x -x^ ry) + y _ _ _ (8) Q.4 Explain 3-different types of Transformations in 3- dimension? Ans.: The there different types of transformations are : For more detail: - http://www.gurukpo.com (1) Translation (2) Rotation (3) Scaling (1) Translation : In three dimensional homogenous coordinate representation a point is translated from position P = (x, y, z) to position P’ = (x’, y’, z’) with the matrix operation : x’ 1 0 0 tx^ x y’ = 0 1 0 ty^ y _ _ _ (1) z’ 0 0 1 t z^. z 1 0 0 0 1 1 Or P’ = T. P _ _ _ (2) Parameter t x, t^ y, t^ z^ specifying translation distance for the coordinate direction x, y, z are assigned any real values. The matrix representation in eq.(1) is x' = x + tx^ , y’ = y + t^ y^ , z’ = z + t^ z^ _ _ _ (3) y-axis (x’, y’, z’)