Computer Graphics Chapter-1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 61

Computer Graphics

Chapter One
Introduction to Interactive Computer Graphics
Contents
 Introduction
 A brief history of computer graphics
 Graphics techniques and terminologies
 Application of Computer Graphics
Introduction
 Computer graphics refers to the creation, storage and manipulation of
pictures and drawings using a digital computer.
 With developments in computing technology interactive computer
graphics has become an effective tool for the presentation of
information in such diverse fields as science, engineering, medicine,
business, industry, government, art, entertainment, advertising,
education, and training.
 There is virtually no field in which graphical displays cannot be used to
some advantage and that is the basic reason why application of
computer graphics is so widespread.
… Cont’D
 It is a fact that one picture is worth a thousand words.
 Therefore, interfaces empowered with graphics enhances the
communication between the computer and its users.
 Representation of a huge set of numbers in the form of a graph or a
picture helps in a better understanding and interpretation of the
characteristics or pattern of the data contained in the set of numbers.
 Graphic displays also improve understanding of complex systems, and
visualization of two-dimensional (2D), three-dimensional (3D) objects.
Graphics techniques and terminologies
 Graphics terminologies are the terms used during the rendering.
 There also processes or techniques that are used during rendering.
 We will see them one by one in coming slides!
Graphics terminologies
 The process by which mathematical and image data is transformed
into a 3D or 2D dimensional image is called rendering.
 When used as a verb, it is the process that your computer goes
through to create the two or three dimensional image.
 Rendering is also used as a noun, simply to refer to the final image
produced.
 Rendering is the process involved in the generation of a two-
dimensional or three-dimensional image from a model by means of
application programs.
… Cont’D
 Rendering is mostly used in architectural designs, video games, and
animated movies, simulators, TV special effects and design
visualization.
 The techniques and features used vary according to the project.
 Rendering helps increase efficiency and reduce cost in design.
 There are two categories of rendering: pre-rendering and real-time
rendering.
 The striking difference between the two lies in the speed at which the
computation and finalization of images takes place.
… Cont’D
 Real-Time Rendering: The prominent rendering technique using in
interactive graphics and gaming where images must be created at a rapid
pace. Because user interaction is high in such environments, real-time
image creation is required. Dedicated graphics hardware and pre-compiling
of the available information has improved the performance of real-time
rendering.
 Pre-Rendering: This rendering technique is used in environments where
speed is not a concern and the image calculations are performed using
multi-core central processing units rather than dedicated graphics
hardware. This rendering technique is mostly used in animation and visual
effects, where photorealism needs to be at the highest standard possible.
… Cont’D
 Transformation is the process of introducing changes in the shape
size and orientation of the object using scaling rotation reflection
shearing & translation etc. In general, transformation means changing
some graphics into something else by applying rules.
 The process of converting the description of objects from world
coordinates to viewing coordinates is known as projection. The
production of the 2D display of the 3D scene is called projection. The
plane in the area into which we transform (project) objects is called
the 'Table'.
… Cont’D
 In computer graphics “rasterization” is the process through which a
vectorial image (in which the image is recorded as a set of curves and
hence is size-independent) is transformed in a bitmap image (which is
size-dependent). The actual drawing, or filling in of the pixels between
each vertex to make the lines is called rasterization.
 Texture mapping is a graphic design process in which a two-
dimensional (2-D) surface, called a texture map, is "wrapped around"
a three-dimensional (3-D) object. Texture mapping is the electronic
equivalent of applying wallpaper, paint, or veneer to a real object. A
texture is simply a picture that we map to the surface of a triangle or
polygon.
… Cont’D
 Blending allows us to mix different colors together. Blending is a term
used often in art, particularly in painting and drawing. It is the
technique of gently intermingling two or more colors or values to
create a gradual transition or to soften lines. As an artist, it's
important to practice blending in any medium you choose to work
with.
 Scan Conversion is the process of converting basic, low level objects
into their corresponding pixel map representation.
Graphics techniques
 Typically graphics packages allows user to specify which part of the
defined picture is to be display and where that part is to be placed on
the display devices.
 Transformation from world to device coordinates involve translation,
rotation, rotation and scaling operations, as well as procedures for
deleting those parts of the picture that are outside the limits of the
selected display areas.
 A world-coordinate area selected for display is called a window.
 An area on a display device to which a window is mapped is called a
viewport.
… Cont’D

Window Viewport
 In computer graphics, a window is a  A viewport is a polygon viewing region
graphical control element. in computer graphics.
 A window defines a rectangular area in  The viewport is an area expressed in
world coordinates. rendering device-specific coordinates.
 You can define the window to be larger
than, the same size as, or smaller than the  A viewport defines in normalized
actual range of data values, depending on coordinates a rectangular area on the
whether you want to show all of the data display device where the image of the
or only part of the data. data appears.
 The window defines what is to be viewed.  The viewport defines where it is to be
displayed.
Window-To-Viewport Coordinate
transformation
 Mapping of a part of the world coordinate scene to device coordinate
is simply referred to as a viewing transformation.
 Sometimes the 2D viewing transformation is referred to as the
window to viewport transformation or the windowing transformation.
 If a coordinate position is at the center of viewing window, for
instance, it will be displayed at the center of the viewport.
… Cont’D
… Cont’D
 If (xwmin, ywmin) and (xwmax, ywmax) are bottom-left and top-right
corners of the window and if (xvmin, yvmin) and (xvmax, yvmax) are
those for the viewports then the window to viewport scaling
transformation is given by:
 Sx= (xvmax-xvmin)/ (xwmax-xwmin), Sy = (yvmax-yvmin)/ (ywmax-
ywmin). Where sx and sy are the scaling factor along x and y axes
respectively.
 Example 0: Consider a window with (2, 3) and (6, 8) are bottom-left
corner and top-right corners coordinated and (1, 2) and (4, 5) are those
for a viewport. Find the value of the scaling factors that are needed to
transform the given window into viewport.
Clipping
 Generally, any procedure that identifies those portion of picture that
are either inside or outside of specified region of space is referred to
as a clipping algorithm or simply clipping.
 The region against which an object is clipped is called a clip window.
 Following three situations may occur:
Case 1: The object may be completely outside the window.
Case 2: The object may be seen partially i.e., some part of it may lie
outside the window.
Case 3: The object may be completely seen within the window.
Point Clipping
 Assuming that the clip window is rectangle in standard position, we
save a point P (x, y) for display if the following inequalities are
satisfied:
• Xwmin <= x <= Xwmax
• Ywmin <= y <= Ywmax
 If any one of these four inequalities is false, the point is outside the
window and it is not displayed.
Line Clipping
 All line segments fall into one the following clipping categories:
• Visible: Both end points of the line lie within the window.
• Invisible: The line lies outside the window.
• Partially visible (or clipping candidate): A line is partially visible when some
part of it lies within window.
 Here we will see the following line clipping algorithms:
• Cohen-Sutherland Line Clipping Algorithm
• Midpoint Subdivision Line clipping algorithm
… Cont’D
Cohen-Sutherland Line Clipping
Algorithm
 This is one of the oldest and most popular line-clipping procedures.
 It is an efficient procedure for determining the category of line
segment. The algorithm proceeds in three steps:
Step 1: Assign a four bit code to each end point of the line. The end
point lies in one of the above nine regions of the plane shown in the
above picture.
 4-bit code is assigned as
Bit 4 Bit 3 Bit 2 Bit 1
Top Bottom Right Left
… Cont’D
 Starting from the left most bit, each bit of the code is set to 0 or 1 as
per the following rule:
• Bit-1 is set to 1 if point 'P' lies to the left of the window.
• Bit-2 is set to 1 if point 'P' lies to the right of the window.
• Bit-3 is set to 1 if point 'P' lies to the bottom of the window.
• Bit-4 is set to 1 if point 'P' lies to the top of the window.
 A point with region code 0000 is inside the window.
… Cont’D
Step 2: The line is visible if both endpoint region codes are 0000, not
visible if the logical AND (bit by bit multiplication) of the region codes is
not 0000, and the line is candidate for clipping if the logical AND of the
end point region code is 0000.
Step 3: If the line is candidate for clipping, find the intersection of the
line with the four boundaries of the window and check the visible
portion of the line.
 Example 1: Given a clipping window A (5, 5), B (15, 5), C (15, 20), D (5,
20). Using Cohen-Sutherland line clipping algorithm, find the visible
portion of line with end points P (7, 7) and Q (12, 18).
… Cont’D
 Solution 1: End point region code of P is 0000. And end point region
code of Q is also 0000. Since both end points region codes are (0000),
the line is completely visible. The visible portion of the line is from P
(7, 7) to Q (12, 18).
 Example 2: Given a clipping window A (5, 5), B (15, 5), C (15, 20), D (5,
20). Using Cohen-Sutherland line clipping algorithm, find the visible
portion of line with end points P (3, 10) and Q (3, 20).
… Cont’D
 Solution 2: point region code of P is 0001. And end point region code
of Q is also 0001. The line is not completely visible. Now we have to
test whether the line is partially visible or not. To do this we need to
find the logical AND (bit by bit multiplications of both end points
region codes.
0001
Logical AND 0001
0001
 Conclusions: Since the result is not 0000, the line is totally invisible.
… Cont’D
 Example 3: Given a clipping window A (5, 5), B (20, 5), C (20, 15), D (5,
15). Using Cohen-Sutherland line clipping algorithm, find the visible
portion of line with end points P (3, 7) and Q (15, 20).
… Cont’D
 Solution 3: point region code of P is 0001. And end point region code
of Q is also 1000.
 Since both end points region codes are not (0000), the line is not
completely visible. Now we have to test whether the line is partially
visible or not. To do this we need to find the logical AND (bit by bit
multiplications) of both end points region codes.
0001
Logical AND 1000
0000
… Cont’D
 Since the result is 0000, the line may be partially visible. We can use
the following equation to find the equation of the given line:
y -y1 = (y2 -y1) (x -x1)
x2 -x1
 After substituting the values of (x1, y1) and (x2, y2), we get
y -7 = (20 -7) (x -3)
15 -3
y -7 = 13(x -3)
12
… Cont’D
12y -84 = 13x -39
13x -12y = -45
 Above equation is the equation of the given line.
 (1) Intersection of line with left edge (x =5) of the window.
13 * 5 -12y= -45
 y = 110/12 = 9.16 = 9 (which is greater than ywmin (5) and less than
ywmax (15) and hence this intersection point is accepted.
… Cont’D
 (2) Intersection of line with the right edge (x =20) of the window
13 * 20 -12y = -45
 y = 305/12 = 25.41 = 25 (which is greater than ywmax (15) and hence
intersection point is rejected.
 (3) Intersection of the line with the bottom edge (y =5) of the window
13x -12*5 = -45
 x =15/13= 1.15=1(which is less than xwmin (5) hence intersection
point is rejected.
… Cont’D
 (4) Intersection of the line with the top edge (y =15)
13x -12 * 15 = -45
 x = 135/13 =10.38=10 (which is greater than xwmin (5) and less than
xwmax (20) and hence the intersection point is accepted.
 Conclusion: Since the two intersection points are accepted the visible
portion of the line is from (5, 9) to (10, 15).
Midpoint Subdivision Line clipping
algorithm
 An alternative to finding intersection points by equation solving is
based on bisection method of numerical analysis.
 The line segment is divided at its midpoint into two smaller line
segments.
 The clipping categories of the new line segments are then
determined.
 Each segment in category 3 is divided again into smaller segments and
categorized.
 The bisection and categorization process continues until all segments
are in category 1(visible) or category 2 (invisible).
… Cont’D
 The midpoint coordinates (xm, ym) of a line segment joining P1(x1,
y1) to P2(x2, y2) are given by:
xm = x1 + x2
2
ym = y2 +y1
2
 The algorithm is formalized in the following three steps:
 For each end point:
… Cont’D
Step 1: If the end point is visible, then process is complete. If not, continue.
Step 2: If the line is trivially invisible, no output is generated. The process is
complete. If not, continue.
Step 3: divide the line P1P2 at its midpoint Pm. Apply the previous tests to
the two segments P1Pm and PmP2. If PmP2 is rejected as trivially invisible,
the midpoint is an overestimation of the furthest visible point. Continue
with P1Pm. otherwise the midpoint is an underestimation of the furthest
visible point. Continue with P2Pm. If the segment becomes so short that
the midpoint corresponds to the accuracy of the machine or, as specified
to the end points, evaluate the visibility of the point and the process is
complete. Note: Midpoint algorithm uses only integer value.
… Cont’D
 Example 4: Given clipping window A(0,0), B(40,0), C(40,0), D(0,40).
Using midpoint subdivision line clipping algorithm, find the visible
portion, if any, of the line with endpoints P (-10, 20) and Q (50, 10).
… Cont’D
 Solution 4: Region code of P is (0001) and region code of Q is (0010).
 Since both endpoints region codes are not (0000), the line is not
completely visible. Now we have to test whether the line is partially
visible or not. To do this we need to find the logical AND (bit by bit
multiplication) of both end points region codes.
0001
Logical AND 0010
0000
 Since the result is 0000, the line may be partially visible
… Cont’D
 Midpoint is:
xm= x1 + x2=-10 +50=20
2 2
ym= y2 +y1= 20+10= 15
2 2
 End point region code for midpoint (xm , ym) is (0000). Neither segment PPm
nor PmQ is either totally visible or trivially invisible. Let us keep segment PPm
for latter procession, and we continue with PmQ. This subdivision process
continues until we find the intersection point with window edge i.e.(40, y).
Following table shows how the subdivision continues:
 Conclusion: Visible portion of line segment PQ is from (0, 17) to (40, 11).
… Cont’D
Application of Computer Graphics
 Computers have become a powerful tool for the rapid and economical
production of pictures.
 There is virtually no area in which graphical displays cannot be used to
some advantage, and so it is not surprising to find the use of computer
graphics so widespread.
 Although early applications in engineering and science had to rely on
expensive and cumbersome equipment, advances in computer
technology have made interactive computer graphics a practical tool.
 Today, we find computer graphics used routinely in such diverse areas as
science, engineering, medicine, business, industry, government, art,
entertainment, advertising, education, and training.
Computer Aided Design
 Used in design of buildings, automobiles, aircraft, watercraft,
spacecraft, computers, textiles & many other products.
 AutoCAD software was the first CAD program.
 Graphics design package provides standard shapes.
 Animations are also used in CAD applications.
 Realistic displays of architectural design.
Presentation Graphics
 Help for making reports
 Summarize financial, statistical, mathematical, scientific,
economic data for research reports, managerial reports.
 Presentation Slides
• Bar charts, Line graphs, Pie charts etc.
 It provides predefined backgrounds and sample page layouts.
 Project Management (Schedule & Progress)
Presentation Graphics
 Help for making reports
 Summarize financial, statistical, mathematical, scientific,
economic data for research reports, managerial reports.
 Presentation Slides
• Bar charts, Line graphs, Pie charts etc.
 It provides predefined backgrounds and sample page layouts.
 Project Management (Schedule & Progress)
… Cont’D
 Movie Industry:
• Used in motion pictures, music, videos, and television shows.
• Used in making of cartoon animation films.
… Cont’D
• Computer Graphics is about animation (films).
… Cont’D
 Game Industry:
• Focus on interactivity
• Cost effective solutions
• Avoiding computations and other tricks
Education and Training
 Computer generated models of physical, financial and
economic systems are used as educational aids.
 Models of physical systems, physiological systems, population
trends, or equipment such as color-coded diagram help trainees
understand the operation of the system.
 Specialized systems used for training applications.
• Simulators for practice sessions or training of ship captains.
• Aircraft pilots
… Cont’D
• Heavy equipment operators
• Air traffic control personnel
Computer Art
 Computer art typically refers to any form of graphic art or digital
imagery which is produced with the aid of a computer.
 Used in Fine Art & Commercial Art.
• Includes artist’s paint brush programs, paint packages, CAD
packages and animation packages.
• These packages provides facilities for designing object
shapes & specifying object motions.
• Examples: Cartoon drawing, paintings, product
advertisements, logo design.
… Cont’D
… Cont’D
 Electronic painting
• Picture painted electronically on a graphics tablet.
 Morphing
• A graphics method in which one object is transformed into
another.
… Cont’D
Visualization
 Visualization is the process of representing data graphically and
interacting with these representations in order to gain insight
into the data.
 Scientific Visualization
• Producing graphical representations for scientific,
engineering, and medical data sets.
• Scientists, engineers, medical personnel, business analysis,
and others often need to analyze large amounts of
information or to study the behavior of certain processes.
… Cont’D
 Medical Visualization
… Cont’D
 Scientific Visualization
Image Processing
 Image Processing applies techniques to modify or interpret
existing pictures.
 There are different examples of image processing in our daily
life. It is used in:
• Image enhancement.
• Law Enforcement.
• Medical.
• Moving object tracking...etc.
… Cont’D
 Image Enhancement is used to improve quality, remove noise
from image.
… Cont’D
 Law Enforcement
• Number Plate Recognition

• Finger print Recognition


Graphical User Interface
 Computer graphics is used to design: Menus, icons, cursors,
dialog boxes, scroll bars, valuators, grids, 3d interface.
 Lay user can easily use the computer with the help of GUI.
 User don’t have to remember commands.
 More interactive interface.
… Cont’D
Conclusion
 Applications of computer graphics are increasing day by day.
 Computer graphics affect everyone's life in almost every aspect.
 Importance of computer graphics in our lives cant be denied
now we can’t imagine our lives without computer graphics...
THANK YOU

You might also like