0% found this document useful (0 votes)
14 views

UNIT 1 Notes

Uploaded by

Harsh Dewangan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

UNIT 1 Notes

Uploaded by

Harsh Dewangan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

UNIT: 01

Syllabus
Unit – I (12 hours)
Overview of Graphics System: Video Display Units, Raster-Scan and Random
Scan Systems, Graphics Input and Output Devices. Output Primitives: Line
drawing Algorithms: DDA and Bresenham’s Line Algorithm, Circle
drawing Algorithms: Midpoint Circle Algorithm and Bresenham’s Circle
drawing Algorithm. Two Dimensional Geometric Transformation: Basic
Transformation (Translation, Rotation, Scaling) Matrix Representation,
Composite Transformations, Reflection, Shear, Transformation between
coordinate systems.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

Computer graphics is an art of drawing pictures on computer screens with the help of
programming. It involves computations, creations, and manipulation of data. In other words, we can say
that Computer graphics is a rendering tools for the generation and manipulation of images. Whereas Image
processing is defined as how to process to a captured image for object detection and identification.
Pixel : Pictorial unit of the image or graph.
Resolution : The number of pixel per unit length i.e. Horizontal as well as vertical direction.
Aspect ratio : The ratio of width to its height, measured in unit length or number of pixel.
Bitmap : One bit for one pixel called as Bitmap.
Pixmap : number of bits for one pixel called as Pixmap.

CATHODE RAY TUBE (CRT):

Five Component of CRT


i. Electron Gun
ii. Control Electrode
iii. Focusing Electrode
iv. Deflection Amplifier
v. Phosphor Coated Screen
Working Principle:
A cathode (-ve Charge) will be heated until the electron formed, it will be attracted to the
highly charged +ve anode which is phosphor coated inside on the screen. It flows continuously. The
electrons simply flood in the entire face of CRT with a bright glow. However the electrons focused
into a narrow bean with an electron lance. At this point, the focused electron bean produce a single
bright spot at the center of the CRT and the electron beam will deflected or positioned to the left to
right of the center.
 Electron Gun: It is the combination of cathode surrounded by the heater coil. When the
heater will be heat the gun will produce a cathode ray at end point of the gun towards
the CRT screen.

[I.1]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

 Control Electrode: Mainly it used to regulate the flow of electrons. It connected to an


amplifier which in turn is connected to the output circuit of the CRT. The allowing the
circuit to control, when the electron beam is turn OFF or ON.
 Focusing Electrode: It used to create clear picture by focusing the electron into a narrow
beam. It serves his purpose by extracting an electromagnetics force on the electrons. The
effects of this on the electron beam resemble that of a glass lens on the light wave.
 Deflection Amplifier: It used to control the direction of the beam. It creates a magnetic
field which will bend the electron bean as it passes through the field.
 Phosphor Coated Screen: it is a coating on the inside of the front surface of every CRT.
It coated with spatial crystal called Phosphor that will glow when it will heat by high
energy electron beam. The glow given off by the phosphor during exposure to the
electron bean known as fluorescence, the continuity glow given off after the beam is
removed is known as phosphorescence and duration of phosphorescence is called as
persistence.
Persistence is the time for which the phosphor in the CRT emit light until the next electrons is fired.

RASTER SCAN:
In the raster scan system, the electron beam is
swept across the screen, one row at a time from top to
bottom, As the electron beam moves across each row, the
beam intensity is turns on and off to create a pattern of
illuminated spots.
Picture definition is stored in memory area called
Refresh Buffer or Frame Buffer. The memory area holds
the set of intensity values from the all the screen points. Stored intensity values are then retrieved from the
refresh buffer and pointed on the screen one row (scan line) at a time.
Each screen point is referred to as a pixel or pel. At the end of each scan line, the electron beam
returns to the left side of the screen to begin display the next scan line.

VECTOR SCAN (RANDOM SCAN) :


In this technique, the electron beam is directed only to
the part of the screen where the picture is to be drawn rather
than scanning from left to right and top to bottom as in raster
scan. It is called Vector display, Stroke – writing display or
calligraphic display.
Picture definition is stored as a set of line drawing

[I.2]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

commands in an area of memory referred to as the refresh display file.


Random scan displays are designed to draw all the component lines of the picture 30 to 60 times
each second.

APPLICATION OF COMPUTER GRAPHICS:


 User Interface
 Plotting of Graphics and Chart
 Office automation and Desktop publishing
 Computer aided Drafting and Design
 Simulation and Animation
 Art and Commerce.

SCAN CONVERSION OF A PIXEL:


Pixel is the smallest element of a picture. A pixel or point is a geometric element that has a position
but no extension. A pixel is defined by its coordinates. Mathematically a point P in space has coordinates X
and Y represented by P(X,Y).

SCAN CONVERSION OF A LINE:


A line in computer graphics typically refers to a line segment, which is a portion of a straight line
that extends indefinitely in opposite directions. It is defined by its two end points and the line equation
where m is called Slope and b is y intercept of the line.
1. Direct use of the line Equation:

If , then for every integer value of x between and


excluding x1 and x2, calculate the corresponding value of the y
using the equation. If , then for every integer value of y
between y1 and y2, calculate the corresponding value of the x using
the equation.
 It is a simple and mathematically sound.
 It involves floating point computation (multiplication and addition) in every step.
2. DDA ALGORITHM (DIGITAL DIFFERENTIAL ANALYZER):
Line equation:
At a point
If slope
Let next point of p(x1, y1) is P(x2, y2)

[I.3]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

ALGORITHM:
Step 1: Input the coordinate of the two end points and for the line
respectively,
Step 2: [Calculate and ]

Step 3: [calculate the length L ]

Step 4: [calculate the increment factor]

Step 5: [Initialize the initial point on the line and plot]

Step 6: [obtain the new pixel on the line and plot the same]

i
}
Step 7: FINISH
Advantage of DDA:

[I.4]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

 Easy to Implement.
 It is avoided floating point multiplication.
Disadvantage of DDA:
 Poor accuracy at the terminal point.
 Still floating point addition is there.
Problem 01:
Consider a line AB with A(5,5) and B(10,9). 10
9
Apply a simple DDA algorithm and calculate
8
the pixel on the line. 7
6
Solution:
5
Step 1: 4

Step 2: 3
2
1

Step 3: 1 2 3 4 5 6 7 8 9 10

Step 4:
5.5 5.5 5 5
1 6.5 6.3 6 6
2 7.5 7.1 7 7
Step 5: 3 8.5 7.9 8 7
4 9.5 8.7 9 8
5 10.5 9.5 10 9
Step 1: [As shown in table]
3. BRESENHAM’S LINE DRAWING ALGORITHM: (MID POINT LINE DRAWING)
As in DDA, floating point addition is used, to avoid it, mid-point line drawing algorithm are
used.
Derivation (Slope <1)

Again equation of line is

Compare equation (2) and (3)

Let be a point so
[I.5]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

Similarly for the point

By Equation (4)

So (As d1 is a imaginary number, )

.
If d <0, select the E point,
Hence next mid-point to evaluate is M2 ) putting this in the
equation of the line

Hence
If d >0, select the SE point, S
Hence next mid-point will be putting this in equation of the line

Hence
Similarly for slope >1

If d<0, select N point, N

If d>0, select NE point, NE

For For
midPoint_line midPoint_line
{ {
int int
[I.6]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

d=2*dy-dx; d=2*dx-dy;
while while
{ {
Putpixel(X,Y,2); Putpixel(X,Y,3);
if if
{ } { }
else else
{ {
}} }}

Problem 02:
Draw a line between (5,5) and (13,9). 10
9
Solution: 8
7
6
5
4
Slope =
3
2
Initial
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14

0 5 5
1 (5,5) 6 6
2 (6,6) 7 6
3 (7,6) 0+2*(-4)=-8 8 7
4 (8,7) -8+2*4=0 9 7
5 (9,7) 0+2*(-4)=-8 10 8
6 (10,8) -8+2*4=0 11 8
7 (11,8) 0+2*(-4)=-8 12 9
8 (12,9) -8+2*4=0 13 9
9 (13,9) 0+2*(-4)=-8 14 10
SCAN CONVERSION OF CIRCLE
A circle is a symmetrical figure. Any circle
generating algorithm can take advantage of circle’s symmetry to
plot eight points for each value that the algorithm calculate. Eight
way symmetry is used by reflecting each calculated point around
each
 Defining a circle by second order polynomial equation

[I.7]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

If center is at Origin:

To calculate y we require square root and square function which is time taking.
 Trigonometric Function

Here and values are floating point and multiplication of floating point takes more time.
BRESENHAM’S METHOD FOR CIRCLE DRAWING
Method of bresenham’s uses scan conversion with only integer operation like addition,
substation and multiplication rather than trigonometric function. So the method is faster and
efficient for real time implementation. Bresenham’s consider 8-way symmetry of the circle and
generate the point of the circle between to , which increase in and in
direction respectively.
Let be a point on the circumference of the circle. As the direction of the circle
generate is from to , the next point on the circumference can be and
B( To select best of the two pixel. Find out the nearest to the true circle.
Let us assume that the distance of the point A and
B from the origin (0,0) be D(A) and D(B) respectively.
So D(A) =

D(B) =
Let the distance of the pixel from the true circle be

A pixel is always outside the circle. So


B pixel is always inside the circle. So .
So decision factor is defined as

By subtracting from both side


[I.8]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

Since

If then point A is selected so

If then point B is selected so

As we start finding the pixel from

MID POINT CIRCLE DRAWING ALGRITHM:


Mid-point circle drawing algorithm also utilizes he eight point symmetry about origin in the
respective octants.
In Bresenham’s circle algorithm, we found out whether pixel A or pixel B is closure to the true
circle. But in the mid-point circle algorithm, we find the decision factor at the
mid-point of A and B. The decision factor defines the mid-point is inside or outside the circle.

The mid-point M between and is . Therefore the decision


factor becomes

If
If
The decision factor for the next step is

But

By subtracting from both side

As we know is either or

[I.9]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

When
When
The decision factor for determining the next pixel becomes

Bresenham’s Circle Drawing Algorithm Mid-Point Circle Drawing Algorithm


Bresenham_Circle(r) Mid_Point_Circle(r)
{ {
d=1-r;
x=0;
y=r;
do while( )
{ {
putpixel(X,Y,5); putpixel(X,Y,6);
if( ) if( )
{ {

X=X++;
} }
else else
{ {

} }while( ); }
} }}
Problem 03:
Draw a circle where center is at Origin having a radius of 8.
Solution:
Bresenham’s Algorithm:
i d X Y (X,Y)
0 0 8 (0,8)
1 1 8 (1,8)
2 2 8 (2,8)
3 3 7 (3,7)
4 4 7 (4,7)
5 5 6 (5,6)
Mid-Point’s Algorithm:

i d X Y (X,Y) A (0,8) , (1,8), (2,8),(3,7),(4,7),(5,6)


0 0 8 (0,8) B (8,0) , (8,1), (8,2),(7,3),(7,4),(6,5)
1 1 8 (1,8) C (8,0) , (8,-1), (8,-2),(7,-3),(7,-4),(6,-5)
2 2 8 (2,8) D (0,-8) , (1,-8), (2,-8),(3,-7),(4,-7),(5,-6)
3 3 7 (3,7) E (0,-8) , (-1,-8), (-2,-8),(-3,-7),(-4,-7),(-5,-6)
4 4 7 (4,7) F (-8,0) , (-8,-1), (-8,-2),(-7,-3),(-7,-4),(-6,-5)
5 5 6 (5,6) G (-8,0) , (-8,1), (-8,2),(-7,3),(-7,4),(-6,5)
H (0,8) , (-1,8), (-2,8),(-3,7),(-4,7),(-5,6)

[I.10]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

2D GEOMETRIC TRANSFORMATION
Transformation means changing some graphics into something else by applying rules.
Transformation takes an important role in computer graphics to reposition the graphics on the screen and
change their size and orientation. When a transformation takes place on a 2D plane. It is called as 2D
transformation.
There are various types of transformation such as
 Translation
 Scaling Up and Down
 Rotation
 Shearing
 Reflection etc.
TRANSLATION:
A translation moves an object to a different position on the
screen. We can translate a point in 2D by adding translation coordinate
( ) to the original coordinate to get the new
coordinate .
From the figure,

The pair ( ) is called the translation vector or shift vector. The above equation can also be represented

[OR]

ROTATION:
In rotation, we rotate the object at particular angle from it’s origin. In the figure,
is located at angle from the horizontal X coordinate with distance r from the origin.
Let us rotate it at the angle is at a new location .
By using trigonometric:

Similarity

Substituting equation (1) and (2) in (3) and (4) respectively.

Representing the above equation in matrix form

[I.11]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

OR

The rotation angle can be positive and negative.


For negative angle:

SCALING
To change the size of an object, scaling transformation is used. In the scaling process, you either
expand (up) or compress (down) the dimension of the object. Scaling can be achieved by multiplying the
original coordinates of the object with the scaling factor to get the desired result.
Let us assume that the original coordinates:
The scaling factor )
The mathematically represented as

The above equation can be represented in matrix

REFLECTION
Reflection is the mirror image of original object. In reflection, the size of the object doesn’t change.
A reflection can also be represented as rotation operation with .

[I.12]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

SHEAR / SKEWING
A transformation that slants the shape of an object is called the shear transformation. Shearing is a
deformation of an object in which parallel planes remain parallel but are shifted in a direction parallel to
them.
Vertical shearing y a factor of

Horizontal Shearing by a factor of

Shearing with respect to Both Axis

Problem 04:
Rotate a triangle ABC by an angle about a point (-1,1) where the triangle has a coordinate A(5,0),
B(10,2) and C(7,4).
Solution:
The coordinate of triangle ABC are
Step 1: The matrix representation of ABC triangle is

Step 2: Find out the rotation matrix with origin (

Step 3: Bring the arbitrary point P(-1,1) to origin (By Translation)

Step 4: Rotation by

Step 5: Move the origin to P(-1,1) or translate the arbitrary point back to its own position.

[I.13]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

The result triangle after

HOMOGENOUS COORDINATES:
In a composite transformation, it involves scaling, rotation, reflection, translation but when
we represented the translation (Basic operation for any transformation) in 2x2 matrix. It require
addition and substation operation. But all other translation require matrix multiplication. To make
uniform we use homogenous coordinate. Homogenous coordinate is based on projective geometry.
Where coordinate representation of a point in the homogenous representation is

Where

IN HOMOGENEOUS COORDINATES:
1. Translation Matrix

2. Rotation Matrix:

R=

3. Scaling Matric

R=

4. Reflection
 Reflection about X-axis  Reflection about Y-axis

 Reflection about X-axis  Reflection about X=Y

5. Shear / Skewing

[I.14]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

 X Shear  Y Shear

Problem 05:
Rotate a triangle ABC by an angle about a point (-1,1) where the triangle has a coordinate A(5,0),
B(10,2) and C(7,4). [Same as problem 4]
Solution:
Let the transformation matric is T.
T= [Bring (-1, 1) to origin]. [Rotation matric ]. [Bring back (-1, 1) from
Origin]

Problem 05:
Consider a triangle ABC with coordinator A(0,0),B(1,1),(C(4,2) magnify the triangle ABC to its twice by
keeping the point C(4,2) fixed.
Solution:
Translate to bring the fixed point to origin.

Step 1: Scaling by 2.

[I.15]
COMPUTER GRAPHICS | UNIT: 01
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, GIET (AUTONOMOUS), GUNUPUR
COMPUTER GRAPHICS - BCSPC7010 - 3-0-1 4

Step 2: Translate back the fixed point from (0,0)

Step 3: Find out the transformation matrix

Step 4: Find the magnified triangle

[I.16]
COMPUTER GRAPHICS | UNIT: 01

You might also like