+ All Categories
Home > Documents > UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional...

UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional...

Date post: 24-Jun-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
33
UNIT-III 4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com By: Abhishek Khare SVIM Indore Email Id: [email protected] Website: http://abhishekkharecloud.wordpress.com 1 Computer Graphics & Multimedia
Transcript
Page 1: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

UNIT-III

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com

By: Abhishek KhareSVIM Indore

Email Id: [email protected]: http://abhishekkharecloud.wordpress.com

1

Computer Graphics & Multimedia

Page 2: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 2

Page 3: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

• Viewing coordinates, Window, view port,clipping, Window to view port transformation,line clipping

• Algorithm; Cohen Sutherland, polygon clipping;Sutherland hodgman algorithm, 3D clipping :Normalized view volumes, view port clipping,clipping in homogeneous coordinates.

• Illumination model: Light sources, diffusereflection specular reflection, reflected light,intensity levels,

• Surface shading; phong shading groundshading, color models like RGB, YIQ, CMY, HSVetc.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 3

Page 4: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Course Contents

• Two-Dimensional Viewing and Clipping• Three-Dimensional Clipping• Illumination Model and Surface Rendering

Methods• Color Models

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 4

Page 5: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Windowing and Clipping

• Typically a graphics package allows us tospecify which part of a defined picture is tobe displayed.

• Use of Scaling, translation and rotationtechnique.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 5

Page 6: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

The process of selecting and viewingthe picture with different views is calledwindowing.

A process which divides each elementof the picture into its visible and invisibleportions, allowing the invisible portion tobe discarded is called clipping.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 6

Page 7: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Viewing Transformation• World Co-ordinate System (WCS)

– The picture is stored in the computer memory using any convenient Cartesian co-ordinate system.

• Physical Device Co-ordinate System(PDCS)– When picture is displayed on the display device it is

measured in pdcs.

Mapping: WCS PDCS= Viewing Transformation

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 7

Page 8: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com

Displaying an image of a picture involvesmapping the co-ordinates of the co-ordinatesof the points and lines that form the picture intothe appropriate physical device co-ordinatewhere the image is to be displayed. Thismapping of co-ordinates is achieved with theuse of co-ordinate transformation known asViewing Transformation.

8

Page 9: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

How to achieve Viewing Transformation

– Normalization Transformation(N)

– Workstation Transformation(W)

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 9

Page 10: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Normalization Transformation(N)

• Different display devices may have different screen sizes as measured in pixels.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com

Less Resolution

MoreResolution

10

Page 11: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Contd.

• To avoid this and to make out programs to be device independent-

Normalized device co-ordinates

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com

(1,1)(0,1)

(0,0)(1,0)

(0.5,0.5)

11

Page 12: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

InterpreterNormalized device co-ordinate to the Actual device

coordinate• Formula

X = Xn * Xw

Y = Yn * Yh

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com

WhereX : Actual device x co-ordinateY : Actual device y co-ordinateXn : Normalized x co-ordinate Yn : Normalized y co-ordinateXw : Width of actual screen in pixelsYh : Height of actual screen in pixels

The transformation which maps the world co-ordinate to normalized device co-ordinate is called normalization transformation.

It involves scaling of x and y thus it is also refereed to as scaling transformation.

12

Page 13: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Workstation Transformation(W)

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 13

The transformation which maps the normalizeddevice co-ordinate to physical device co-ordinate is called workstation transformation.

Viewing transformation = Normalization transformation * Workstation transformation

V = N*W

Page 14: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Two dimensional viewing transformation

Workstation Transformation[ Translation Scaling Translation]

Device co-ordinate(DC)

Normalization Transformation

Normalized coordinate(NC)

World co-ordinate(WC)

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 14

Page 15: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Window and Viewport

World co-ordinate system(WCS) is infinite Device display area is finite.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 15

To perform a viewing transformation we select a finite world co-ordinate area for display called a window

An area on a device to which a window is mapped is called a viewport.

Page 16: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

• The window define what is to be viewed• The viewport defines where it is to be

displayed.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 16

Page 17: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

How to achieve workstation transformation

W = T.S.T-1

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 17

Sx 0 0

0 Sy 0

Xvmin-Xwmin.Sx Yvmin-Ywmin.Sy 1

Sx = Xvmax – Xvmin/Xwmax - Xwmin

Sy = Yvmax – Yvmin/Ywmax - Ywmin

Where

Page 18: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Numerical

Q1. Find the normalization transformationwindow to viewpoint, with window lower leftcorner at (1,1) and upper right corner at (3,5)onto a viewpoint with lower left corner at(0,0) and upper right corner at (1/2,1/2).

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 18

Sx = 0.25Sy= 0.125

0.25 0 0

0 0.125 0

-0.25 -0.125 1

Page 19: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

PPTsIntroduction to multimedia, multimedia components,(UNIT-5)

Roll No- 1 to 5 (25/26 March)

multimedia ha(UNIT-5)rdware, SCSI, IDE, MCI

Roll No- 6 to 10 (6/7 April)

Multimediadata and file formats, RTF, TIFF, MIDI, JPEG, DIB, MPEG(UNIT-5)

Roll No- 11 to 17 (8/9 April)

Multimedia tools, presentations tools,Authoring tools, presentations. (UNIT-5)

Roll No- 18 to 22 (13/15 April)

Illumination model: Light sources, diffuse reflection specular reflection(UNIT-3)

Roll No- 23 to 27 (16/17 April)

Reflected light, intensity levels, (UNIT-3) Roll No- 28 to 30 (20/22 April)

Surface shading; phong shading ground shading(UNIT-3)

Roll No- 31 to 35 (23/24 April)

Color models like RGB, YIQ, CMY, HSV etc(UNIT-3)

Roll No- 36 to Last (27/28/29/30 April)

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 19

Page 20: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Numerical

Q2. Find the normalization transformationwindow to viewpoint, with window lower leftcorner at (1,1) and upper right corner at (3,5)onto a viewpoint for entire normalized devicescreen.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 20

Sx = 1/2Sy= 1/4

0.5 0 0

0 0.25 0

-0.5 -0.25 1

Page 21: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Numerical

Q3. Find the normalization transformationwindow to viewpoint, with window lower leftcorner at (0,0) and upper right corner at (4,3)onto the normalized device screen so thatthe aspect ratio is preserved.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 21

Sx = 1/4Sy= 1/4

1/4 0 0

0 1/4 0

0 0 1

View port (0.0) (1,3/4)

Window(0.0) (4,3)

Page 22: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Aspect ratio• A property of video monitors is aspect ratio.• This number gives the ratio of vertical points

to horizontal points necessary to produceequal-length lines in both directions on thescreen.

• An aspect ratio of 3/4 means that a verticalline plotted with three points has the samelength as a horizontal line plotted with fourpoints.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 22

Page 23: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Clipping

A procedure which identifies the part of apicture that are either inside or outside of thespecified region of the space.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 23

Before mapping the window onto viewport the partof the picture outside the window is to be discarded .This process of discarding is called “clipping”.

Page 24: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Line Clipping

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 24

Page 25: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Four-bit codes for nine regions

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 25

Page 26: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Sutherland and Cohen Subdivision Line Clipping Algorithm

• This algorithm uses a four digit (Bit) code toindicate which of nine regions contain the endpoint on line.

• The four bit codes are called region codes orout codes.

• These codes identify the location of the pointrelative to the boundaries of the clippingrectangle.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 26

Page 27: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Contd.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 27

• Set Bit 1- if the end point is to the left of thewindow.

• Set Bit 2- if the end point is to the right of thewindow.

• Set Bit 3- if the end point is to the below ofthe window.

• Set Bit 4- if the end point is to the above ofthe window.

• Otherwise, the bit set to zero

Page 28: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

Algorithm: Steps

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 28

P1(x1,y1)

P2(x2,y2)

(Wx1 , Wy1)

(Wx2 , Wy2)

Page 29: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 29

P1(0,2)

P2(5,7)

(2 , 5)

(7 , 0)

0001

1000

Page 30: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

1. Read two end point of the line say P1(x1,y1) and P2(x2,y2).

2. Read two corners (left-top and right-bottom) of the window say (Wx1,Wy1) and (Wx2,Wy2).

3. Assign the region codes for two endpoints P1 and P2 using following steps:– Set Bit 1 – if (x < Wx1)– Set Bit 2 – if (x > Wx2)– Set Bit 3 – if (y < Wy2)– Set Bit 4 – if (y > Wy1)

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 30

Page 31: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

4. Check for visibility of line P1P2a) If region codes for both endpoints P1 and P2

are zero then the line is completely visible.Hence draw the line and go to step 9.

b) If region codes for endpoints are not zero andthe logical ANDing of them is also nonzerothen the line is completely invisible, so rejectthe line and go to step 9.

c) If region codes for two endpoint do notsatisfy the conditions in 4(a) and 4(b) the lineis partially visible.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 31

Page 32: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

5. Determine the intersecting edge of theclipping window by inspecting the region codeof two endpoints.a) If region codes for both the end points are

non-zero, find intersection points P1’ and P2’with boundary edges of clipping window withrespect to point P1 and point P2 respectively.

b) If region code for any one end point is nonzero then find intersection point P1’ or P2’with the boundary edge of the clippingwindow with respect to it.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 32

Page 33: UNIT-III - WordPress.com › 2015 › 01 › unit-3-11.pdfCourse Contents • Two-Dimensional Viewing and Clipping • Three-Dimensional Clipping • Illumination Model and Surface

6. Divide the line segments considering intersection points.

7. Reject the line segment if any one end point of it appears outsides the clipping window.

8. Draw the remaining line segments.9. Stop.

4/8/2015 @Copyrights UNIT-3|Abhishek Khare| http://abhishekkharecloud.wordpress.com 33


Recommended