0% found this document useful (0 votes)
134 views63 pages

COMPUTER GRAPHICS AND MULTIMEDIA Unit 1

The document discusses computer graphics and multimedia. It defines computer graphics and describes how images are represented using pixels. It discusses the differences between computer graphics, computer vision, and image processing. It also outlines several applications of computer graphics like CAD, simulations, animations, and user interfaces. Finally, it discusses some hardware and software used for computer graphics.

Uploaded by

Shambhavi Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views63 pages

COMPUTER GRAPHICS AND MULTIMEDIA Unit 1

The document discusses computer graphics and multimedia. It defines computer graphics and describes how images are represented using pixels. It discusses the differences between computer graphics, computer vision, and image processing. It also outlines several applications of computer graphics like CAD, simulations, animations, and user interfaces. Finally, it discusses some hardware and software used for computer graphics.

Uploaded by

Shambhavi Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 63

COMPUTER GRAPHICS AND

MULTIMEDIA

Shubhangi Krishna
INTRODUCTION
• Computer graphics is a field of computer
science, which deals with creation,
representation and management of images on
the computer screen.
• Computer graphics deals with the
technological and theoretical aspects of
computerized image synthesis.
• An image created by a computer can illustrate
a simple scene as well as complex scenes.
• Computer graphics covers many important
elements in the field of computer science, such
as the processing of images, interaction with
images, representation of images, and display of
images.
• Due to these important elements, today,
computer graphics have become an important
aspect of our daily lives.
• Computer graphics is used in almost all the fields
today, such as games, weather reports, or all
kinds of medical investigation and surgical
procedures.
IMAGE REPRESENTATION
• In computer graphics, a graphic object is
represented as a collection of discrete picture
elements, called pixels.
• Hence, a pixel is smallest addressable screen
element.
• It is the smallest piece of display screen which
can be controlled.
• This control is achieved by setting the intensity
and color of pixel, which compose the screen.
• Each pixel represent a region, which
theoretically can contain infinite no of points.
• But in general a point is represented by the
integer part of x coordinates, and y
coordinates.
• For example, P1 are represented by (4, 3),
irrespective of their exact values.
• There are special procedure which determine,
which pixel will provide best approximation to
the desired picture or graphic objects.
• The process of determining the appropriate
pixels for representing picture or graphic
object is called rasterization.
• The process of representing continuous
picture or graphic object as a collection of
discrete pixels is called scan conversion.
COMPUTER GRAPHICS VS COMPUTER VISION

COMPUTER GRAPHICS COMPUTER VISION


• Its about drawing things on • It is concerned with
the screen with pixels, using interpretation of images &
mathematics & physics videos
concepts to give impression • It takes an incoming image(or
of objects to human view. series ) & uses it to create
new image information.
• Locating & identifying faces,
license plates, street signs etc.
in random imagery.
• Used to analyze & pull
semantic content from
images & videos of real world.
COMPUTER GRAPHICS VS IMAGE PROCESSING

COMPUTER GRAPHICS IMAGE PROCESSING


• Its about drawing things on • It is about taking a digital
the screen with pixels, using input (color or black n white
mathematics & physics photo), scanned image etc.
concepts to give impression and using mathematics &
of objects to human view. physics concepts to extract
details of object in that i/p .
• o/p requirements may be
simple like finding lines or
detecting colors or complex
like finding faces or detecting
emotions.
APPLICATIONS OF COMPUTER GRAPHICS
• Computer Aided Design (CAD)
• Presentation Graphics
• Computer Art
• Entertainment
• Education & Training
• Visualization
• Image Processing
APPLICATIONS OF CG: USER INTERFACE
• Types of interfaces: Command Line & GUI.
• Graphical interfaces provide an attractive and
easy interaction between users and computers.
• Built in graphics provided with user interfaces
use visual control items like buttons, menus,
icons, scroll bars etc.
• Hence allowing user to interact with computer
by mouse click.
APPLICATIONS OF CG: PLOTTING
• Computer Graphics is most commonly used to
create 2D, 3D graphs of mathematical,
physical & economic functions in form of
histograms, bars, charts and pie charts.
• Essential in fields like industry, business,
government and educational organizations.
• Plays vital role in decision making process.
5
4.5
4
3.5
3
2.5 Series 1
Series 2
2 Series 3
1.5
1
0.5 Series 3
0 Series 2
Category 1
Category 2 Series 1
Category 3
Category 4
APPLICATIONS OF CG: SIMULATION &
ANIMATION
• Use of graphics in simulation makes
mathematic models and mechanical systems
more realistic and easy to study.
• The interactive graphics supported by
animation software proved their use in
production of animated movies and cartoon
films.
APPLICATIONS OF CG: CAD
• Computer Aided Design (CAD) is the use of
computers to aid in the creation, modification,
analysis and optimization of a design.
• Its major use is in design processes,
particularly for engineering & architectural
systems.
• Its routinely used in design of buildings,
automobiles, aircraft, spacecraft, textiles etc.
• It increases the productivity of designer &
improve quality of design.
APPLICATIONS OF CG: CARTOGRAPHY
• Cartography is the science and art of map
making. i.e. field of study dealing with
conception, production and study of maps.
• Computer graphics is also used to represent
geographic maps, weather maps,
oceanographic maps, population density maps
and so on.
• It enhances the visual clarity and accurateness
of all kind of maps in cartography.
ADVANTAGES OF COMPUTER GRAPHICS

• High quality graphics displays of personal computer


provide one of the most natural means of
communicating with a computer.
• It provides tools for providing not only concrete real
world objects, but also of abstract, synthetic objects,
such as mathematical surfaces in 3D and of data that
has no inherent geometry, such as survey results.
• It has ability to show moving pictures and thus it is
possible to produce animations with computer
graphics.
• With computer graphics, we can control the
animations by adjusting the speed, the portion of
the total scene in view, the geometric relationship
of the objects to one another , the amount of
detail shown and so on.
• It provides motion dynamics tools through which
user can move and tumble object with respect to
a stationary observer, or he can make objects
stationary and the viewer moving around them.
• Another tool, Update dynamics, user can change
the shape, color or other properties of the objects
being viewed.
CONCEPT FOR PIXEL
• Pixel stands for Picture Element.
• It carries information about intensity of colour
under it. e.g. brightness level, illumination level.
• A pixel carries three basic color, Red, Blue Green.
• With the help of theses three colors, 16777216
different colors can be formed, just by controlling
and manipulating their intensities.
PIXEL DENSITY
• Pixel density is the number of pixels present in
square unit area.
• Unit: pi (pixel per inch)
• Resolution of an image is the Number of Pixels
in an image.
• Aspect Ratio is the relationship (ratio) between
height and width of screen.
• Whenever scaling of an image is done, its
aspect ratio needs to be maintained same.
HARDWARE FOR COMPUTER GRAPHICS
• Hardware can be categorized in form of
– Input Devices
– Output Devices
– Storage Devices
– Processing Devices
• Mouse:
– It is used to navigate around digital graphics software. It
is also used to navigate around a computer, and to
launch programs/applications.
• Keyboard :
– It is used to type instructions plus navigate from one
interface to another.
• Monitors/Screen:
– It displays picture or image output, that u may editing
using digital graphics software.
• RAM:
– It is a volatile memory, which stores data & instructions
which are needed by CPU in current state.
• Hard Disk:
– It is a type of magnetic memory, which stores data and instruction
in bulk form permanently.
• Digital Camera:
– It is used to take pictures and videos, which later can be used by
graphics software for manipulation and editing.
• CPU:
– Central Processing Unit executes commands that are given to it. It
executes the instructions from graphics software and provides the
output,
• Printer:
– It is used to produce the printout (hard copy) of outputs, produced
by CPU.
• Scanner:
– It is used to produce digital copies of images from real world hard
copies of images. Later these digital copies can be manipulated
using appropriate software.
• Graphic Tablet :
– It is used to navigate around graphics software or to
enhance, manipulate or create digital images.
• Light Pens:
– It is a pen like device used to digitally write in an
graphics interface.
• Graph Plotter:
– It is a graphical device to plot and produce hard
copies of graphs from some graphics software.
• Joystick:
– It is a pointer device which is used to navigate in an
graphic interface environnent like games etc.
SOFTWARES FOR COMPUTER GRAPHICS
• Adobe Photoshop:
– It is used to enhance and manipulate photos and
create original digital art.
• Adobe Illustrator:
– It is program used by both artists and graphic
designers to create vector images.
– These images are then used for company logos,
promotional material both in print and digital
form.
• Others like Page maker, Corel Draw, Paint etc.
VECTOR VS RASTER IMAGES
VECTOR IMAGES RASTER IMAGES
• A vector graphic file is • A raster graphic such
composed of path or as .jpeg, or .gif is
lines, that are either composed of pixels, is
straight or curved an array of pixels of
• The data files for a various colors, which
vector image contains together form an image.
the points from where a • Its data file contains the
path start and ends. information about
properties of pixels at
various locations of
image.
CONCEPTUAL FRAMEWORK OF
INTERACTIVE GRAPHCIS
• It consist of input and output devices, graphics
systems, application program and application
model.
• A computer receives input from input devices, and
output images to a display device.
• There are three software components of
conceptual framework :
• Application Model
• Application Program
• Graphic System
APPLICATION MODEL
• It captures all the data and objects to be
pictured on the screen.
• It also captures the relationship among them.
• These relationships are stored in the database
called application database, and referred by
the application programs
APPLICATION PROGRAM
• It creates application model and communicates
with it to receive and store data and information
of object’s attribute.
• It also handles user input and produces views by
sending series of graphic output commands to
the graphics system.
• It is also responsible for interaction handling by
event handling loops.
GRAPHICS SYSTEMS
• It accept the series of graphics output commands
from application program.
• The output command contains both a detailed
geometric description of what is to be viewed and
the attributes, describing how the objects should
appear.
• The graphics system is responsible for actually
producing the picture from the detailed description
and for passing the user’s input to application
program for processing.
SCAN CONVERSION
• The process of representing continuous
graphics objects as a collection of discrete
pixels is called Scan Conversion.
• For example, line is defined by its two end
points, and the line equation, where a circle is
defined by its radius, center position and circle
equation.
• For generating graphical object, many
algorithms have been developed.
ADVANTAGES OF USING ALGO
• Algorithms can generate graphics objects at a
faster rate.
• Using algorithms memory can be used
efficiently.
• Algorithms can develop a higher level of
graphical objects.
SCAN CONVERSION OF A POINT
• Each pixel on the graphics display does not
represent a mathematical point.
• Instead, it means a region which theoretically
can contain an infinite number of points.
• Scan-Converting a point involves illuminating
the pixel that contains the point.
SCAN CONVERSION OF A LINE
• A straight line may be defined by two
endpoints & an equation.

y (x2,y2)

y=mx+c
y

x
(x1,y1) x
PROPERTIES OF LINE ALGORITHM
• Line should appear straight
• The lines must be generated parallel or at 45°
to the x and y-axes.
• Lines should terminate accurately.
• Line density is proportional to the no. of dots
displayed divided by the length of the line.
• To maintain constant density, dots should be
equally spaced.
• Line density should be independent of line
length and angle.
• Line should be drawn rapidly.
• There are three algorithms for line drawing:
– Direct use of line algorithm
– DDA
– Bresenham’s Algorithm
DIRECT USE OF LINE ALGORITHM
• Declare variables x1,x2,y1,y2,dx,dy,c,m
• Enter values of x1,x2,y1,y2.
• Calculate dx = x2- x1
• Calculate dy = y2-y1
• Calculate m = dy/dx
• Calculate c = y1-(m* x1)
• Set (x, y) equal to starting point
• xend=largest value of x
• If dx < 0
then x = x2
y = y2
xend= x1
If dx > 0
then x = x1
y = y1
xend= x2
• Check whether the complete line has been drawn
if x=xend
• Plot a point at current (x, y) coordinates
• Increment value of x, i.e., x = x+1
• Compute next value of y from equation y = mx + c
DDA ALGORITHM
• DDA stands for Digital Differential Analyzer.
• It is an incremental method of scan conversion
of line.
• In this method calculation is performed at each
step but by using results of previous steps.
• Plotting of same point twice is not possible as it
detects change in value.
• Faster method than direct line algorithm.
DDA ALGORITHM
• Take starting point as (x1,y1) and ends at (x2,y2)
• Calculate Δx and Δy
– Δx = x2-x1
– Δy = y2-y1
– m = Δy/Δx
• Set the initial point of the line as (x1,y1).
• Loop through the x-coordinates of the line,
incrementing by one each time, and calculate the
corresponding y-coordinate using the equation
y = y1 + m(x – x1).
• Plot the pixel at the calculated (x,y)
coordinate.
• Repeat previous steps (last two) until the
endpoint (x2,y2) is reached.
STEPS TO CALCULATE
1. Slope(m)= (y2-y1)/(x2-x1)
2. Find Δx and Δy.
3. Δx = Δy/m
DECISION PARAMETER
4. Δy= m Δx.
5. Case1: if | Δx|>=| Δy|
1. Assign Δx=1
2. x(i+1)=xi + 1
3. y(i+1)=yi+ m
6. Case2: if | Δx|<| Δy|
1. Assign Δy=1
2. x(i+1)=xi + 1/m
3. y(i+1)=yi+ 1
BRESENHAM’S ALGORITHM
• It is an efficient method because it involves
only integer addition, subtraction and
multiplication.
• These operations can be performed very
rapidly so lines can be generated quickly.
• It resolves the disadvantage of getting floating
values of x and y like in DDA.
• In this method, next pixel selected, is that one
which has least distance from true line
• The basic principle of Bresenham’s line
algorithm is to select the optimum raster
location to represent a straight line.
• To accomplish this, the algorithm always
increment either x or y by one unit, depending
on the slope of line.
• The increment in the other variable is
determined by examining the distance
between the actual line location and nearest
pixel.
• This distance is called decision variable.
BRESENHAM’S ALGORITHM
1. Read the line end points (x1,y1) and (x2,y2)
such that they are not equal.
2. Δx=|x2-x1| and Δy= |y2-y1|
3. [Initialize starting point] x=x1; y=y1
4. e= 2* Δ y- Δ x; [Initialize value of decision
variable or error.]
5. i=1 [Initialize counter]
6. plot (x,y)
7. while(e>=0)
{
y=y+1;
x = x +1;
e= e-2*Δx + 2* Δy
}
8. else
9. x=x+1; e= e+ 2*Δy
10. i=i+1
11. if(i<= Δx) then go to step 6
12. STOP
STEPS TO CALCULATE
1. Slope m= (y2-y1)/(x2-x1)
2. Decision parametric p= 2Δy – Δx(for m<1)
3. Decision parametric p=2Δx- Δy(for m>=1)
4. If m<1
– p<0 - p>=0
– x(i+1)= xi+1 - x(i+1)=xi+1
– y(i+1)=yi - y(i+1)=yi+1
– p(i+1)=pi +2Δy - p(i+1)=pi+2Δy-2Δx
5. If m>=1
– p<0 - p>=0
– xi+1=xi - xi+1=xi+1
– yi+1=yi+1 - yi+1=yi+1
– pi+1=pi+2Δx - pi+1=pi+2Δx-2Δy
6. Value of Δx and Δy is always the initial calculate
one. It is not calculated every single time.
SCAN CONVERSION OF A CIRCLE
• Circle is an eight-way symmetric figure.
• The shape of circle is the same in all quadrants.
• In each quadrant, there are two octants.
• If the calculation of the point of one octant is done,
then the other seven points can be calculated
easily by using the concept of eight-way symmetry.
• The seven octants are calculated using property of
reflection.
• The reflection is accomplished by reversing x, y co-
ordinates.
1 2

8 3

7 4
6 5

Eight-way symmetric figure of a circle


MIRROR IMAGE

QUADRANT 1
QUADRANT 4
(X,Y)
(-X,Y)
OCTANT 8 OCTANT 1
(-X,Y) (X,Y)

OCTANT 2
OCTANT 7
(Y,X)
(-Y,X)

OCTANT 6 OCTANT 3
(-Y,-X) (Y,-X)

OCTANT 5 OCTANT 4
(-X,-Y) (X,-Y)
QUADRANT 3 QUADRANT 2
(-X,-Y) (X,-Y)
MID-POINT CIRCLE ALGORITHM
• Coordinates of the points is calculated using
Pythagorean theorem:
– (x’)2+(y’)2=r2
• Decision parameter:
– 5/4-r
– Since 5/4 is almost equal to 1, for numerical
purposes take p= 1-r
1. Assume coordinates as (x, y) and radius=r
2. Find p=1-r and take starting points as x=0
and y=r
3. If p>=0
 xnew= x+1
 ynew= y-1
 p= pold+2xnew-2ynew+1
4. If p<0
 xnew=x+1
 ynew=y
 p= 2*xnew+1+pold
5. If the given centre point (X0, Y0) is not (0, 0),
then do the following and plot the point-
 Xplot = Xnew + X0
 Yplot = Ynew + Y0
6. Keep repeating Step-03 and Step-04 until
Xplot >= Yplot.
SCAN CONVERSION OF AN ELLIPSE
• Ellipse is defined as the geometric figure which is the set of
all points on a plane whose distance from two fixed points
remains a constant.
• It consists of two axes: major and minor axes where the
major axis is the longest diameter and minor axis is the
shortest diameter.
• The ellipse has four-way symmetry property which means
that only the quadrants are symmetric while the octants
are not.
• If the points for one quadrant is calculated then the points
for the remaining three can be calculated using the former
points.
• Equation of an ellipse:
• r y 2 x 2 + r x2 y 2 - r x2 r y 2 = 0
– where,
– ry : semi-minor axis
– rx : semi-major axis
• Slope of ellipse:
• m =dx / dy = - (2 ry2 x /2 rx2 y ) = -1
• In the ellipse each quadrant is divided into two
regions: R1 and R2 respectively.
• The region R1 has the value of slope as m<-1
while R2 has the value of slope as m > -1.
MID-POINT ELLIPSE ALGORITHM
• Step 1: Start
• Step 2: Declare rx , ry , x , y , m , dx , dy , P , P2.
• Step 3: Initialize initial point of region1 as
• x=0 , y = ry
• Step 4: Calculate P= ry2 + rx2 / 4 - ry rx2
• dx = 2 ry2 x
• dy = 2 rx2 y
• Step 5: Update values of dx and dy after each
iteration.
• Step 6: Repeat steps while (dx < dy):
Plot (x,y)
if(P < 0)
Update x = x+1 ;
P += ­ry2 [2x + 3 ]
Else
Update x = x + 1
y= y - 1
• Step 7: When dx ≥ dy, plot region 2:
• Step 8: Calculate P2 = ry2 ( x+1 / 2)2 + rx2 (y -1)2- rx2ry2
• Step 9: Repeat till (y > 0)
If (P2 > 0)
Update y = y-1 (x will remain same)
P2 =­P2 -2 y rx2 + rx2
else
x = x+1
y = y-1
P2=­P2+ 2 ry2 [2x] -2 y rx2 + rx2
• Step 10: End

You might also like