19
344 bapler 6 w Color Image Processing processing. Ji terms of techniques, the areas of direct color vector processing are nu- merous and include processes such as median and other order filters, adaptive and mor- phological filters, image restoration, image compression, and many others. These processes are not equivalent to color processing carried out on the individual component images of a color image.The references in the followjng section provide a pointer to fur- ther results in this field. Our treatment of noise in color images also points out that the veclor nature of the problem, along with the fact that color images are routinely transformed from one work- ing space to another, has implications on tbe issue of how to reduce noise in these im- ages. Jn some cases, noise filtering can be done on a per-image basis, bur orhers, such as median filtering, require special treatment to reflect the fact that color pixels are vector quantjties, as mentioned in the previous paragraph. Although segmentation is the topic of Chapter 10 and image data compression is the topic of Chapter 8, we gained the advantage of continuity by introducing [hem here in the context of color image processing. As will become evident in subsequent discussions, many of the techniques developed in those chapters are applicable to the discussion in this chapter. References and Further Reading For a comprehensive reference on the science of color. see Malacara [2001]. Regarding the physiology of color,see Gegenfurtner and Sharpe [1999].These two references, along with the early books by LValsh' 119581 and by Kiver [1965], provide ample supplernen~ary material for the discussion in Section 6.1. For hrther reading on coIor models (Section 6.2), see Fortner and Meyer [1997], Poynton [1996], and Fairchild [1998]. For a detailed derivation of the HSI model equations in Section 6.2.3 see the paper by Smith [I9781 or consult the book web site.The topicol pseudocolor (Sechon 6.3) 1s closely tied lo the gen- eral area of data visualization Wolff and Yaeger [I9931 is a good basic reference on the use oi pseudocolor.The book byThorel1 and Smith [I9901 also is of interest. For a dis- cussion on the vector representation of color signals (Secfjon 6.4), see Plataniotis and Venctsanopoulos [2000]. References for Section 6.5 are Benson [1985], Robertson [I 9771, and CIE [I 9783. See also the classic paper by MacAdarn [1942]. The material on color image filtering (Sec- tion 6.6) IS based on the vector formulation introduced in Section 6.4 and on our dis- cussion of spatial filtering in Chapter 3. Segnlentatio~l of color images (Section 6 7) has been a topic of much attention during the past ten years.The papers by Liu and Yang [I9941 and by Shafarenko et al. [I9981 are representative of work in this field. A special issue of Ihe IEEE Transactions on huge Processing I19971 also js of inrerest. Tie dis- cussjon on color edge detection (Section 6.7.3) is from Dj Zenzo [1986].Tbe book by Pla- tanjotis and Venetsanopoulos [2000] does a good job of summarizing a variety of approaches to the segmentation of color images The discussion In Secrion 6.8 is based on the noise models introduced in Section 5.2. References on image compression (Sec- tion 6.9) are listed at the end of Chapter 8. Scc in\& Irmc mvsr Detailed solurions to the Problems prohlerns marked with a sbr can be found in lire 6.1 Give the percentages of red (X), green (Y), and blue (2) light rcquired lo gen- book web sile. The sile erate the point labeled "warm white'' in Fig. 6.5. also contalns suggested projects based on the ma- + 6.2 Consider any two valid colors c, and c2 with coordinates (1,. y,) and (x2. y2) in terra1 in IIIIS chapter. the chromaticity diagram of Fig. 6.5. Derive the necessary general expression(s)

Exercicio Selecionados- Primeira Avaliação

Embed Size (px)

Citation preview

Page 1: Exercicio Selecionados- Primeira Avaliação

344 bapler 6 w Color Image Processing

processing. Ji terms of techniques, the areas of direct color vector processing are nu- merous and include processes such as median and other order filters, adaptive and mor- phological filters, image restoration, image compression, and many others. These processes are not equivalent to color processing carried out on the individual component images of a color image.The references in the followjng section provide a pointer to fur- ther results in this field.

Our treatment of noise in color images also points out that the veclor nature of the problem, along with the fact that color images are routinely transformed from one work- ing space to another, has implications on tbe issue of how to reduce noise in these im- ages. Jn some cases, noise filtering can be done on a per-image basis, bur orhers, such as median filtering, require special treatment to reflect the fact that color pixels are vector quantjties, as mentioned in the previous paragraph.

Although segmentation is the topic of Chapter 10 and image data compression is the topic of Chapter 8, we gained the advantage of continuity by introducing [hem here in the context of color image processing. As will become evident in subsequent discussions, many of the techniques developed in those chapters are applicable to the discussion in this chapter.

References and Further Reading For a comprehensive reference on the science of color. see Malacara [2001]. Regarding the physiology of color,see Gegenfurtner and Sharpe [1999].These two references, along with the early books by LValsh' 119581 and by Kiver [1965], provide ample supplernen~ary material for the discussion in Section 6.1. For hr ther reading on coIor models (Section 6.2), see Fortner and Meyer [1997], Poynton [1996], and Fairchild [1998]. For a detailed derivation of the HSI model equations in Section 6.2.3 see the paper by Smith [I9781 or consult the book web site.The topicol pseudocolor (Sechon 6.3) 1s closely tied lo the gen- eral area of data visualization Wolff and Yaeger [I9931 is a good basic reference on the use o i pseudocolor.The book byThorel1 and Smith [I9901 also is of interest. For a dis- cussion on the vector representation of color signals (Secfjon 6.4), see Plataniotis and Venctsanopoulos [2000].

References for Section 6.5 are Benson [1985], Robertson [ I 9771, and CIE [I 9783. See also the classic paper by MacAdarn [1942]. The material on color image filtering (Sec- tion 6.6) IS based on the vector formulation introduced in Section 6.4 and on our dis- cussion of spatial filtering in Chapter 3. Segnlentatio~l of color images (Section 6 7) has been a topic of much attention during the past ten years.The papers by Liu and Yang [I9941 and by Shafarenko et al. [I9981 are representative of work in this field. A special issue of Ihe IEEE Transactions on h u g e Processing I19971 also js of inrerest. T i e dis- cussjon on color edge detection (Section 6.7.3) is from D j Zenzo [1986].Tbe book by Pla- tanjotis and Venetsanopoulos [2000] does a good job of summarizing a variety of approaches to the segmentation of color images The discussion In Secrion 6.8 is based on the noise models introduced in Section 5.2. References on image compression (Sec- tion 6.9) are listed at the end of Chapter 8.

Scc in\& Irmc mvsr

Detailed solurions to the Problems prohlerns marked with a s b r can be found in lire

6.1 Give the percentages of red (X), green ( Y ) , and blue ( 2 ) light rcquired lo gen- book web si le. T h e si le erate the point labeled "warm white'' in Fig. 6.5. also contalns suggested projects based on the ma- + 6.2 Consider any two valid colors c , and c2 with coordinates ( 1 , . y , ) and ( x 2 . y2 ) in terra1 in IIIIS chapter. the chromaticity diagram of Fig. 6.5. Derive the necessary general expression(s)

Page 2: Exercicio Selecionados- Primeira Avaliação

a Problems 345

for compu~iag the re la tivr percentages of colors c , and c2 composing a given color that is k n o w n lo l ie oil thz s1ratgl)t line joining these two colors.

6.3 Co~lsider a n y three valid colors c , . c.,, and c, with coordinates ( x , , yl). ( x , , y,), and (s?. y,) in the chrornalicity diagram of Fig. 6.5. ~ e r i v e the necessary general ex- pressiori(s) lor conlpuling the relat ive percentages of c , , c,, arid c3 composing a given color tha t is known to lie wirhin the ~ ~ i a n g l e \vl~ose vertices are a t the coordinates of c , . c 2 , and c,.

* 6.4 111 ar! automated asseunbly application, three classes of parts are to be color coded it1 oldel to sirnplify detection. However, only a monochromeTV camera is avail- able to acquire digital images. Propose a technique for using this camera to detect the three different colors.

6.5 I n a simp[e RGB image, the R, G , and B component images have [he horizontal intensiiy profiles shown in thc t'ollowing diagram. What color would a person see in ~ I l c iniddle column ol this image?

* 6.6 Sketcli the R G B components of the following inlageas they would appear on a non no chrome mor,itor. All colors arc at maximum intensity and s a t u r a t i o ~ . It1

working I his problem. consider the middle gray border as part of the image.

6.7 How many different shades of g ray arc there in a color KGB system in which each RGB image is an 8-bit image'?

6.8 Consider tlic RGB cotor cube shown in Fig 6.8. and ansnrer each of the following: * (a) Dcscribe how the gray levels va ry in the R , G, and R primary irnnges thaL

make up the Pront face of the color cubc.

(b) Suppose thar we replace every color in the RGB cube by its CMY color.This new cube is displayed on an RGB monitor. Label with a color n a m e the eight vertices ot the new cube that you would see on the screen.

alopes
Highlight
alopes
Highlight
alopes
Highlight
alopes
Highlight
Page 3: Exercicio Selecionados- Primeira Avaliação

346 Chapter 6 m Color Image Processing

(c) CVt~at can you say about (he colors on the edges OF the RGB c o l o ~ cube se- garding saturation?

6.9 (a) Sketch t h e CMY components of the image in PI-ohlem 6.6 as they would ap- peat on a monochrome nlonilor.

(h) If the CMY components skelched in (a) are fed into lhe red.green,and blue inputs of a color inonitor, respcclively, describe t-he resulting image.

* 6.10 Dcrive the CMY intensity mdpping function of Ecl. (6-5-6.) from i ts RGB coun- terpart in Eq. (6.5-5).

6.11 Consider the ei~tirc 216 safe-color array shown in Fig. 6.10(a). Label cach cell hy its (row. column) designation, s o that the top left cell is ( I . 1) and the rightmost bottom ccll is (12, 18). A1 which cells will you find

(a) The purest green?

(b) The purest blue?

* 6.12 Skelch the HSI components of the image in Problem 6.6 as they would appear on a tnonochrome monitor.

6.13 P1.opose a rncttrod io i generaling a colol- band simila~. to the one show11 in the zoomed section entitled Visible Sprctr-nnz in Fig. 6.2. Notc lhaI the band starts at a dark purple on the left arid proceeds Loward purc I-ed an the riglit. (Hinr: Use the HSI color nlodel.)

Jr 6.14 Propose a method for generating a color version of t h e image sllown diagram- matically in Fig. 6.13(c). Givc you^ answer in rhe form of a [low char[. Ass,ulne that the intensity value js fixed and given. (Hint: Use the HSI color model.)

6.15 Consider the following image colnposed o l solid color squares. For discussing your answer, choose a gray scale consisting of eight shades of gray, 0 lhrougli 7, where O is black and 7 is white. Suppose that the image is conve1,tecl to HS1 color space. In answering the following questions, use specific numbers for the grade shades if they make sense. Otlierwise, the relationships "same as,""lighter than," OJ' "darker than" are sufficient. If you cannot assign a specific gray level or one of these relationships to the image you are discussing, give the reason.

(a) Sketch the hue image.

(b) Sketch the saturation image.

(c) Sketch the intensity image.

Magenta

Green

Cyn n Yellow n White

alopes
Highlight
alopes
Highlight
Page 4: Exercicio Selecionados- Primeira Avaliação

6.16 The following 8-bit images are (left ro right) the H, S, and I co~nporlent images f r o m Fig. 6.16. The numbers indicate gray-level values. Answer the t'oll owi~ig ques- tions, explaining the basis for your answer in each. If it is not possible to answer a question based on the given information, state why you cannot d o so.

* (a) Give the gray-level valuzs of all regions in rhe hue image.

(b) Give the gray-level value of all regions in t h e saturation image.

(c) Give the gray-level values of all regions in the in tens i ty image.

6.17 Rzler to Fig. 6.27 in answering the following:

(a) Why does the image in Fig. 6.27(f) exhibit predorni~lantly red tones'?

(b) Suggest an automated procedure for coding rhe warer in Fig.6.27 in :i bl-ighr- blue color.

(c) Suggesl a n automated procedure for coding the pi.edotninantly man-made components in a bright yellow color. [Hin l : Work with Fig. 6.27(1').1

* 6.18 Show t h a t the saluration component of the complement of a color image canno t be computed from the saturation component of the input image alone.

6.19 Explain the shape of t h e hue transformation function for the complement nppraximation in Eg. 6.33(b) using the HSI color model.

.k 6.20 Derive the CMY cransforrnations to generate t h e compleme~i t of a color image.

6.21 Draw the general shape of the transformation functions used to correct excessive contrast in the RGB color space.

k6.22 ,4ssume that the monilor and printer of all imaging system are imperfectly cali- brated.An image thal looks balanced on the monitor appears yellowish in print. Describe general transformations that might correct the imbalance.

6.23 Compute the L * u * ~ ' ~ components of the image in Problem 6.6 assuming

This matrix equation defines the tristimulus values of t h e colors generated hv slandard National Television System Committee (NTSC) c o l o ~ T V phosphors viewed u n d e r 0 6 5 standard jllurninaLion (Benson [1985J).

* 6.24 How would you implement the color equivalenr of gray scale histogram match- ing (specification) from Section 3.3.2?

6.25 Consider the following 500 X 500 RGB color image-where the squares arc purc red, green, and blue.

alopes
Highlight
alopes
Highlight
Page 5: Exercicio Selecionados- Primeira Avaliação

348 Chrrp~er 6 a Color h a g e Processing

(a) Suppose that we convert this image to HSI, blur the H component image with a 25 X 25 averaging mask, and convert back to RGB. What would the result look like?

(b) Repeat, blurring only the saturation component this time.

6.26 Show that Eq. (6.7-2) reduces to Eq. (6.7-1) when C = I, the identity matrix.

6.27 Sr (a) With reference to the discussion in Section 6.7.2, give a procedure (in flow chart form) for determining whether a color vector (point) z is inside a cube with sides W, centered at an average color vector a. Distance computations are not allowed.

(b) This process also can be implemented on an image-by-image basis if the box is lined up with the axes. Show how you would do it.

6.28 Sketch the surface in RGB space for the points that satisfy the equation

Green

Blue

1 D(z , a) = [ ( z - a)TC-l(z - a)]? = Do

Red

Green

where Do is a specified nonzero constant. Assume that a = 0 and that

6.29 Refer to Section 6.7.3. One might think that a logical approach for defining the gradient of an RGB image at any point ( x , y ) would be to compute the gradient vector (see Section 3.7.3) of each component image and then form a gradient vec- tor for the color image by summing the three individual gradient vectors. Unfor- tunately, this method can at times yield erroneous results. Specifically, it is possible for a color image with clearly defined edges to have a zero gradient if this method were used. Give an example of such an image. (Hin t Set one of the color planes to a constant value to simplify your analysis.)

Page 6: Exercicio Selecionados- Primeira Avaliação

Computer Graphics Principles and Practice Foley * van Dam * Feiner * Hughes

Chapter 12

30/30

alopes
Oval
alopes
Oval
alopes
Oval
Page 7: Exercicio Selecionados- Primeira Avaliação

36 Chapter 1 Graphics Systems and Models

to match the resolution of film and may use light and material effects that cannot be implemented in real time. Even as the power of available hardware and software con-tinues to grow, modeling and rendering have such different goals that we can expect the distinction between a modeling system and a rendering system to survive.

Our next step will be to explore the application side of graphics programming. We use the OpenGL API, which is powerful, is supported on most platforms, and has a distinct architecture that will allow us to use it to understand how computer graphics works, from an application program to a final image on a display.

SUGGESTED READINGS There are many excellent graphics textbooks. The book by Newman and Sproull [New73] was the first to take the modern point of view of using the synthetic-camera model. The various versions of Foley et al. [Fol90, Fol94] have been the standard references for over a decade. Other good texts include Hearn and Baker [Hea04], Hill and Kelly [Hil07], and Shirley et al. [Shi05]. It is interesting to note that the recent editions of almost all these textbooks use OpenGL.

Good general references include Computer Graphics, the quarterly journal of SIGGRAPH (the Association for Computing Machinery's Special Interest Group on Graphics), IEEE Computer Graphics and Applications, and Visual Computer. The proceedings of the annual SIGGRAPH conference include the latest techiques. These proceedings formerly were published as the summer issue of Computer Graphics. Now, they are published as an issue of the ACM Transactions on Graphics and are available on DVD. Of particular interest to newcomers to the field are the state-of-the-art animations available from SIGGRAPH and the notes from tutorial courses taught at that conference, both of which are now available on DVD.

Sutherland's doctoral dissertation, published as Sketchpad: A Man-Machine Graphical Communication System [Sut63] was probably the seminal paper in the de-velopment of interactive computer graphics. Sutherland was the first person to realize the power of the new paradigm in which humans interacted with images on a CRT display. Videotape copies of film of his original work are still available.

Tufte's books [Tuf83, Tuf90, Tuf97] show the importance of good visual design and contain considerable historical information on the development of graphics. The article by Carlbom and Paciorek [Car78] gives a good discussion of some of the relationships between classical viewing, as used in fields such as architecture, and viewing by computer.

Many books describe the human visual system. Pratt [Pra78] gives a good short discussion for working with raster displays. Also see Glassner [Gla95], Wyszecki and Stiles [Wys82], Gonzales and Wood [Gon07], and Hall [Hal89].

EXERCISES 1.1 The pipeline approach to image generation is nonphysical. What are the main

advantages and disadvantages of such a nonphysical approach?

Page 8: Exercicio Selecionados- Primeira Avaliação

Exercises 37

liill FIGURE 1.32 Perspectives of a cube.

1.2 In computer graphics, objects such as spheres are usually approximated by simpler objects constructed from flat polygons (polyhedra). Using lines of lon-gitude and latitude, define a set of simple polygons that approximate a sphere centered at the origin. Can you use only quadrilaterals or only triangles?

1.3 A different method of approximating a sphere starts with a regular tetrahe-dron, which is constructed from four triangles. Find its vertices, assuming that it is centered at the origin and has one vertex on the y-axis. Derive an algo-rithm for obtaining increasingly closer approximations to a unit sphere, based on subdividing the faces of the tetrahedron.

1.4 Consider the clipping of a line segment in two dimensions against a rectan-gular clipping window. Show that you require only the endpoints of the line segment to determine whether the line segment is not clipped, is partially vis-ible, or is clipped out completely.

1.5 For a line segment, show that clipping against the top of the clipping rectangle can be done independently of the clipping against the other sides. Use this result to show that a clipper can be implemented as a pipeline of four simpler clippers.

1.6 Extend Exercises 1.4 and 1.5 to clipping against a three-dimensional right parallelepiped.

1.7 Consider the perspective views of the cube shown in Figure 1.32. The one on the left is called a one-point perspective because parallel lines in one direction of the cube—along the sides of the top—converge to a vanishing point in the image. In contrast, the image on the right is a two-point perspective. Charac-terize the particular relationship between the viewer, or a simple camera, and the cube that determines why one is a two-point perspective and the other is a one-point perspective.

1.8 The memory in a frame buffer must be fast enough to allow the display to be refreshed at a rate sufficiently high to avoid flicker. A typical workstation display can have a resolution of 1280 x 1024 pixels. If it is refreshed 72 times per second, how fast must the memory be? That is, how much time can we take to read one pixel from memory? What is this number for a 480 x 640 display that operates at 60 Hz but is interlaced?

1.9 Movies are generally produced on 35-mm film that has a resolution of approx-imately 2000 x 3000 pixels. What implication does this resolution have for producing animated images for television as compared with film?

alopes
Highlight
alopes
Highlight
alopes
Highlight
Page 9: Exercicio Selecionados- Primeira Avaliação

38 Chapter 1 Graphics Systems and Models

1.10 Consider the design of a two-dimensional graphical API for a specific appli-cation, such as for VLSI design. List all the primitives and attributes that you would include in your system.

1.11 It is possible to design a color CRT that uses a single electron gun and does not have a shadow mask. The single beam is turned on and off at the appropriate times to excite the desired phosphors. Why might such a CRT be more difficult to design, as compared to the shadow-mask CRT?

1.12 In a typical shadow-mask CRT, if we want to have a smooth display, the width of a pixel must be about three times the width of a triad. Assume that a monitor displays 1280 x 1024 pixels, has a CRT diameter of 50 cm, and has a CRT depth of 25 cm. Estimate the spacing between holes in the shadow mask.

1.13 An interesting exercise that should help you understand how rapidly graphics performance has improved is to go to the Web sites of some of the GPU manufacturers, such as NVIDIA and ATI, and look at the specifications for their products. Often the specs for older cards and GPUs are still there. How rapidly has geometric performance improved? What about pixel processing? How has the cost per rendered triangle decreased?

Page 10: Exercicio Selecionados- Primeira Avaliação

158 Chapter 3 Input and Interaction

3.22 Extend Exercise 3.20 to have the user enter a logical expression. Have the program generate a logical diagram from that expression.

3.23 Use the methods of Exercise 3.20 to form flowcharts for programs or images of graphs that you have studied in a data-structures class.

3.24 Plotting packages offer a variety of methods for displaying data. Write an interactive plotting application for two-dimensional curves. Your application should allow the user to choose the mode (polyline display of the data, bar chart, or pie chart), colors, and line styles.

3.25 The required refresh rate for CRT displays of 50 to 85 Hz is based on the use of short-persistence phosphors that emit light for extremely short intervals when excited. Long-persistence phosphors are available. Why are long-persistence phosphors not used in most workstation displays? In what types of applica-tions might such phosphors be useful?

3.26 Modify the polygon program in Section 3.9 using a linked list rather than an array to store the objects. Your program should allow the user to both add and delete objects interactively.

3.27 Redo the polygon program using display lists to store objects. 3.28 Use selection mode for picking in the polygon program. 3.29 Another CAD application that can be developed in OpenGL is a paint pro-

gram. You can display the various objects that can be painted—lines, rectan-gles, circles, and triangles, for example—and use picking to select which to draw. The mouse can then enter vertex data and select attributes such as colors from a menu. Write such an application.

alopes
Highlight
Page 11: Exercicio Selecionados- Primeira Avaliação

Exercises 231

SUGGESTED READINGS There are many texts on vector analysis and linear algebra, although most treat the topics separately. Within the geometric-design community, the vector-space ap-proach of coordinate-free descriptions of curves and surfaces has been popular; see the book by Faux and Pratt [Fau80]. See DeRose [DeR88, DeR89] for an introduction to geometric programming. Homogeneous coordinates arose in geometry [Max51] and were later discovered by the graphics community [Rie81]. Their use in hardware started with Silicon Graphics' Geometry Engine [Cla82]. Modern hardware architec-tures use application-specific integrated circuits (ASICs) that include homogeneous coordinate transformations.

Quaternions were introduced to computer graphics by Shoemaker [Sho85] for use in animation. See the book by Kuipers [Kui99] for many examples of the use of rotation matrices and quaternions.

Software tools such as Mathematica [Wol91] and MATLAB [Mat95] are excellent aids for learning to manipulate transformation matrices.

EXERCISES 4.1 Show that the following sequences commute:

a. A rotation and a uniform scaling b. Two rotations about the same axis c. Two translations

4.2 Twist is similar to rotation about the origin except that the amount of rotation increases by a factor/ the farther a point is from the origin. Write a program to twist the triangle-based Sierpinski gasket by a user-supplied value of/. Observe how the shape of the gasket changes with the number of subdivisions.

4.3 Write a library of functions that will allow you to do geometric programming. Your library should contain functions for manipulating the basic geometric types (points, lines, vectors) and operations on those types, including dot and cross products. It should allow you to change frames. You can also create functions to interface with OpenGL so that you can display the results of geometric calculations.

4.4 If we are interested in only two-dimensional graphics, we can use three-dimensional homogeneous coordinates by representing a point as p = [x y 1 ]T

and a vector as v = [a b 0]T. Find the 3 x 3 rotation, translation, scaling, and shear matrices. How many degrees of freedom are there in an affine transfor-mation for transforming two-dimensional points?

4.5 We can specify an affine transformation by considering the location of a small number of points both before and after these points have been transformed. In

alopes
Highlight
alopes
Highlight
alopes
Highlight
Page 12: Exercicio Selecionados- Primeira Avaliação

232 Chapter 4 Geometric Objects and Transformations

FIGURE 4.64 Symmetric ori-entation of cube.

three dimensions, how many points must we consider to specify the transfor-mation uniquely? How does the required number of points change when we work in two dimensions?

4.6 How must we change the rotation matrices if we are working in a left-handed system and we retain our definition of a positive rotation?

4.7 Show that any sequence of rotations and translations can be replaced by a single rotation about the origin followed by a translation.

4.8 Derive the shear transformation from the rotation, translation, and scaling transformations.

4.9 In two dimensions, we can specify a line by the equation y = mx + h. Find an' affine transformation to reflect two-dimensional points about this line. Extend your result to reflection about a plane in three dimensions.

4.10 In Section 4.8, we showed that an arbitrary rotation matrix could be composed from successive rotations about the three axes. How many ways can we com-pose a given rotation if we can do only three simple rotations? Are all three of the simple rotation matrices necessary?

4.11 Add shear to the instance transformation. Show how to use this expanded instance transformation to generate parallelepipeds from a unit cube.

4.12 Find a homogeneous-coordinate representation of a plane. 4.13 Determine the rotation matrix formed by glRotate. That is, assume that the

fixed point is the origin and that the parameters are those of the function. 4.14 Consider the solution of either constant-coefficient linear differential or dif-

ference equations (recurrences). Show that the solutions of the homogeneous equations form a vector space. Relate the solution for a particular inhomoge-neous equation to an affine space.

4.15 Write a program to generate a Sierpinski gasket as follows. Start with a white triangle. At each step, use transformations to generate three similar triangles that are drawn oyer the original triangle, leaving the center of the triangle white and the three corners black.

4.16 Start with a cube centered at the origin and aligned with the coordinate axes. Find a rotation matrix that will orient the cube symmetrically, as shown in Figure 4.64.

4.17 We have used vertices in three dimensions to define objects such as three-dimensional polygons. Given a set of vertices, find a test to determine whether the polygon that they determine is planar.

4.18 Three vertices determine a triangle if they do not lie in the same line. Devise a test for collinearity of three vertices.

4.19 We defined an instance transformation as the product of a translation, a rota-tion, and a scaling. Can we accomplish the same effect by applying these three types of transformations in a different order?

alopes
Highlight
alopes
Highlight
alopes
Highlight
alopes
Highlight
alopes
Highlight
Page 13: Exercicio Selecionados- Primeira Avaliação

Exercises 233

4.20 Write a program that allows you to orient the cube with one mouse button, to translate it with a second, and to zoom in and out with a third.

4.21 Given two nonparallel, three-dimensional vectors u and v, how can we form an orthogonal coordinate system in which u is one of the basis vectors?

4.22 An incremental rotation about the z-axis can be approximated by the matrix

1 6 0 0

-6 1 0 0

0 0 1 0

0" 0 0 1_

What negative aspects are there if we use this matrix for a large number of steps? Can you suggest a remedy? Hint: Consider points a distance of 1 from the origin.

4.23 Find the quaternions for 90-degree rotations about the x- and y-axes. Deter-mine their product.

4.24 Determine the rotation matrix R = R(0x)R(0JR(0z). Find the corresponding quaternion.

4.25 Redo the trackball program using quaternions instead of rotation matrices. 4.26 Implement a simple package in C++ that can do the required mathematical

operations for transformations. Such a package might include matrices, vec-tors, and frames.

4.27 In principle, an object-oriented system could provide scalars, vectors, and points as basic types. None of the popular APIs does so. Why do you think this is the case?

4.28 Show the sum

P = alP1 + a2P2 + . . . + «„?„.

is denned if and only if

a\ + a2 + • • • + an — *•

Hint: Start with the first two terms and write them as

P = a ^ + a2P2 + . . . = a^ + (a2 + «j - a2)Px + ...

= a^Py - P2) + (a, + a2)P2 + ...

then proceed inductively.

alopes
Highlight
Page 14: Exercicio Selecionados- Primeira Avaliação

Exercises 285

standing the mathematics leads to understanding a pipeline implementation based on concatenation of 4 x 4 matrices. Until recently, application programs had to do the projections within the applications, and most hardware systems did not support perspective projections.

There are three major themes in the remainder of this book. First, we explore modeling further by expanding our basic set of primitives. In Chapter 10, we in-corporate more complex relationships between simple objects through hierarchical models. In Chapter 11, we explore approaches to modeling that do not force us to describe objects through procedures rather than as geometric objects. This approach allows us to model objects with only as much detail as is needed, to incorporate phys-ical laws into our models, and to model natural phenomena that cannot be described by polygons. In Chapter 12, we leave the world of flat objects, adding curves and curved surfaces. These objects are defined by vertices, and we can implement them by breaking them into small flat primitives, so we can use the same viewing pipeline.

The second major theme is realism. Although more complex objects allow us to build more realistic models, we also explore more complex rendering options. In Chapter 6, we consider the interaction of light with the materials that characterize our objects. We look more deeply at hidden-surface-removal methods, at shading models, and in Chapters 8 and 9 at techniques such as texture mapping that allow us to create complex images from simple objects using advanced rendering techniques.

Third, we look more deeply at implementation in Chapter 7. At this point, we have introduced the major functional units of the graphics pipeline. We discuss the details of the algorithms used in each unit. We will also see additional possibilities for creating images by working directly in the frame buffer.

SUGGESTED READINGS Carlbom and Paciorek [Car78] discuss the relationships between classical and com-puter viewing. Rogers and Adams [Rog90] give many examples of the projection matrices corresponding to the standard views used in drafting. Foley et al. [Fol90], Watt [WatOO], and Hearn and Baker [Hea04] derive canonical projection transfor-mations. All follow a PHIGS orientation, so the API is slightly different from the one used here, although Foley derives the most general case. The references differ in whether they use column or row matrices, in where the COP is located, and in whether the projection is in the positive or negative z-direction. See the OpenGL Pro-gramming Guide [Ope05] for a further discussion of the use of the model-view and projection matrices in OpenGL.

EXERCISES 5.1 Not all projections are planar geometric projections. Give an example of a

projection in which the projection surface is not a plane and another in which the projectors are not lines.

Page 15: Exercicio Selecionados- Primeira Avaliação

286 Chapter 5 Viewing

5.2 Consider an airplane whose position is specified by the roll, pitch, and yaw and by the distance from an object. Find a model-view matrix in terms of these parameters.

5.3 Consider a satellite orbiting the earth. Its position above the earth is specified in polar coordinates. Find a model-view matrix that keeps the viewer looking at the earth. Such a matrix could be used to show the earth as it rotates.

5.4 Show how to compute u and v directions from the VPN, VRP, and VUP using only cross products.

5.5 Can we obtain an isometric of the cube by a single rotation about a suitably chosen axis? Explain your answer.

5.6 Derive the perspective-projection matrix when the COP can be at any point and the projection plane can be at any orientation.

5.7 Show that perspective projection preserves lines. 5.8 Any attempt to take the projection of a point in the same plane as the COP

will lead to a division by zero. What is the projection of a line segment that has endpoints on either side of the projection plane?

5.9 Define one or more APIs to specify oblique projections. You do not need to write the functions; just decide which parameters the user must specify.

5.10 Derive an oblique-projection matrix from specification of front and back clip-ping planes and top-right and bottom-left intersections of the sides of the clipping volume with the front clipping plane.

5.11 Our approach of normalizing all projections seems to imply that we could predistort all objects and support only orthographic projections. Explain any problems we would face if we took this approach to building a graphics system.

5.12 How do the OpenGL projection matrices change if the COP is not at the origin? Assume that the COP is at (0, 0, d) and the projection plane is z = 0.

5.13 We can create an interesting class of three-dimensional objects by extending two-dimensional objects into the third dimension by extrusion. For example, a circle becomes a cylinder, a line becomes a quadrilateral, and a quadrilateral in the plane becomes a parallelepiped. Use this technique to convert the two-dimensional maze from Exercise 2.8 to a three-dimensional maze.

5.14 Extend the maze program of Exercise 5.13 to allow the user to walk through the maze. A click on the middle mouse button should move the user forward; a click on the right or left button should turn the user 90 degrees to the right or left, respectively.

5.15 If we were to use orthogonal projections to draw the coordinate axes, the x-and y-axes would lie in the plane of the paper, but the z-axis would point out of the page. Instead, we can draw the x- and y-axes meeting at a 90-degree angle, with the z-axis going off at —135 degrees from the x-axis. Find the matrix that projects the original orthogonal-coordinate axes to this view.

alopes
Highlight
alopes
Highlight
Page 16: Exercicio Selecionados- Primeira Avaliação

Exercises 287

5.16 Write a program to display a rotating cube in a box with three light sources. Each light source should project the cube onto one of the three visible sides of the box.

5.17 Find the projection of a point onto the plane ax + by + cz + d = 0 from a Ught source located at infinity in the direction (dx, dy, dz).

5.18 Using one of the three-dimensional interfaces discussed in Chapter 4, write a program to move the camera through a scene composed of simple objects.

5.19 Write a program to fly through the three-dimensional Sierpinski gasket formed by subdividing tetrahedra. Can you prevent the user from flying through walls?

5.20 In animation, often we can save effort by working with two-dimensional pat-terns that are mapped onto flat polygons that are always parallel to the camera. Write a program that will keep a simple polygon facing the camera as the cam-era moves.

5.21 Stereo images are produced by creating two images with the viewer in two slightly different positions. Consider a viewer who is at the origin but whose eyes are separated by Ax units. What are the appropriate viewing specifications to create the two images?

Page 17: Exercicio Selecionados- Primeira Avaliação

650 Chapter 12 Curves and Surfaces

can often use subdivision very effectively by not rendering a highly subdivided surface when it projects to a small area on the screen.

SUGGESTED READINGS The book by Farin [Far88] provides an excellent introduction to curves and surfaces. It also has an interesting preface in which Bezier discusses the almost simultaneous discovery by him and deCasteljau of the surfaces that bear Bezier's name. Unfor-tunately, deCasteljau's work was described in unpublished technical reports, so de-Casteljau did not receive the credit he deserved for his work until recently. Books such as those by Rogers [Rog90], Foley [Fol90], Bartels [Bar87], and Watt [WatOl] discuss many other forms of splines. See Rogers [RogOO] for an introduction to NURBS. The Catmull-Rom splines were proposed in [Cat74].

The book by Faux [Fau80] discusses the coordinate-free approach to curves and surfaces and the Frenet frame.

Although the book edited by Glassner [Gla89] primarily explores ray tracing, the section by Haines has considerable material on working with quadrics and other algebraic surfaces.

There has been much recent activity on subdivision curves and surfaces. For some of the seminal work in the area, see [Che95], [Deb96], [Gor96], [Lev96], [Sei96], and [Tor96]. Our development follows [War04]. Catmull-Clark subdivision was proposed in [Cat78]. See also [War03] and [Sta03].

EXERCISES 12.1 Consider an algebraic surface f(x, y, z) = 0, where each term in / can have

terms in x, y, and z of powers up to m. How many terms can there be in/? 12.2 Consider the explicit equations y = f(x) and z = g{x). What types of curves

do they describe? 12.3 Suppose that you have a polynomial p(w) = 5ZJb=o **"*• Find a polynomial

<j(v) = Ylk-o dkyk s u c n m£rt, for each point of p in the interval (a, b), there is a point v in the range 0 < v < 1, such thatp(w) = q(v).

12.4 Show that as long as the four control points for the cubic interpolating curve are denned at unique values of the parameter u, the interpolating geometry matrix always exists.

12.5 Show that in the interval (0, 1), the Bernstein polynomials must be less than 1.

12.6 Verify the C2 continuity of the cubic spline. 12.7 In Section 10.9, we showed that we can write a cubic polynomial as a cubic

Bezier polynomial by choosing a proper set of control points or, equivalently,

alopes
Highlight
Page 18: Exercicio Selecionados- Primeira Avaliação

Exercises 651

the proper convex hull. Using this fact, show how to render an interpolating curve using the Bezier Tenderer provided by OpenGL. Find a homogeneous-coordinate representation for quadrics. Suppose that we render Bezier patches by adaptive subdivision so that each patch can be subdivided a different number of times. Do we maintain conti-nuity along the edges of the patches? Explain your answer. Write an OpenGL program that will take as input a set of control points and that will produce the interpolating, B-spline, and Bezier curves for these data. Suppose that you use a set of spline curves to describe a path in time that an object will take as part of an animation. How might you notice the difference between G1 and C1 continuity in this situation? Extend the polygon manipulation program from Chapter 3 to include Bezier curves. The user should be able to manipulate the control points interac-tively. Derive a simple test for the flatness of a Bezier surface patch. Derive the open rational quadratic B-spline with the knots {0, 0, 0, 0, 1, 1, 1, 1} and the weights w0 = w2 = 1 and wl = w. Using the result of Exercise 12.14, show that if w = -^, for 0 < r < 1, you get all the conic sections. Hint: Consider r < j and r > j . Find the zeros of the Hermite blending functions. Why do these zeros imply that the Hermite curve is smooth in the interval (0, 1)? What is the relationship between the control-point data for a Hermite patch and the derivatives at the corners of the patch? For a 1024 x 1280 display screen, what is the maximum number of subdivi-sions that are needed to render a cubic polynomial surface? Suppose you have three points, P0, Pv and P2. First, connect successive points with parametric line segments where u ranges from 0 to 1 for each. Next, linearly interpolate between successive pairs of line segments by connecting points for the same value of u with a line segment and then using the same value of M to obtain a value along this new line segment. How can you describe the curve created by this process? Extend Exercise 12.19 by considering four points. Linearly interpolate, first between the three curves constructed as in that exercise and, second, between the two curves thus created. Describe the final curve determined by the four points. What happens in the cubic Bezier curve if the values of the control points P0

and Pj are the same? Suppose that we divide a Bezier surface patch, first along the M-direction. Then in v, we only subdivide one of the two patches we have created. Show

alopes
Oval
alopes
Oval
Page 19: Exercicio Selecionados- Primeira Avaliação

652 Chapter 12 Curves and Surfaces

how this process can create a gap in the resulting surface. Find a simple solution to this difficulty.

12.23 Write a program to carry out subdivision of triangular or quadrilateral meshes. When the subdivision is working correctly, add the averaging step to form a smoother surface.

12.24 Find the blending polynomials for the cubic Catmull-Rom spline. Find the zeros for these polynomials.

12.25 Find the matrix that converts data for the Catmull-Rom spline to control point data for a Bezier curve that will generate the same curve.