0% found this document useful (0 votes)
5 views37 pages

Understanding Computer Graphics Basics

Computer graphics is a sub-field of computer science focused on digitally synthesizing and manipulating visual content, with applications in UI design, animation, and education. It includes types such as raster and vector graphics, and can be interactive or passive. Various tools and technologies, including CRT and DVST, are used for implementation, alongside input and output devices for creating and displaying graphics.

Uploaded by

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

Understanding Computer Graphics Basics

Computer graphics is a sub-field of computer science focused on digitally synthesizing and manipulating visual content, with applications in UI design, animation, and education. It includes types such as raster and vector graphics, and can be interactive or passive. Various tools and technologies, including CRT and DVST, are used for implementation, alongside input and output devices for creating and displaying graphics.

Uploaded by

davidagarwal2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Graphics

The term ‘Computer Graphics’ was coined by Verne Hudson and William Fetter from
Boeing who were pioneers in the field.

Computer graphics is a sub- field of computer science which studies methods for
digitally synthesizing and manipulating visual content.
Computer Graphics can be used in UI design, rendering, geometric objects, animation,
and many more. There are several tools used for the implementation of Computer
Graphics. The basic is the <graphics.h> header file in Turbo- C, Unity for advanced and
even OpenGL can be used for its Implementation.
Types of Computer Graphics
Raster Graphics: In raster, graphics pixels are used for an image to be drawn.
It is also known as a bitmap image in which a sequence of images is into
smaller pixels. Basically, a bitmap indicates a large number of pixels together.
Vector Graphics: In vector graphics, mathematical formulae are used to draw
different types of shapes, lines, objects, and so on.

Interactive and Passive Graphics


(a) Non- Interactive or Passive Computer Graphics:
In non- interactive computer graphics, the picture is produced on the monitor, and the
user does not have any controlled over the image, i.e., the user cannot make any
change in the rendered image. One example of its Titles shown on T.V.
Non- interactive Graphics involves only one- way communication between the
computer and the user, User can see the produced image, and he cannot make any
change in the image.

(b) Interactive Computer Graphics:


In interactive Computer Graphics user have some controls over the picture, i.e., the
user can make any change in the produced image. One example of it is the ping- pong
game.
Interactive Computer Graphics require two- way communication between the
computer and the user. A User can see the image and make any change by sending
his command with an input device.

Application of Computer Graphics


1. Education and Training: Computer- generated model of the physical, financial and
economic system is often used as educational aids. Model of physical systems,
physiological system, population trends or equipment can help trainees to
understand the operation of the system.
Flight Simulator: It helps in giving training to the pilots of airplanes. These pilots
spend much of their training not in a real aircraft but on the ground at the controls of
a Flight Simulator.
Advantages:
1. Fuel Saving
2. Safety
3. Ability to familiarize the training with a large number of the world's airports.
2. Use in Biology: Molecular biologist can display a picture of molecules and gain
insight into their structure with the help of computer graphics.
3. Computer- Generated Maps: Town planners and transportation engineers can use
computer- generated maps which display data useful to them in their planning work.
4. Architect: Architect can explore an alternative solution to design problems at an
interactive graphics terminal. In this way, they can test many more solutions that
would not be possible without the computer.
5. Presentation Graphics: Example of presentation Graphics are bar charts, line
graphs, pie charts and other displays showing relationships between multiple
parameters. Presentation Graphics is commonly used to summarize
o Financial Reports
o Statistical Reports
o Mathematical Reports
o Scientific Reports
o Economic Data for research reports
o Managerial Reports
o Consumer Information Bulletins
o And other types of reports
6. Computer Art: Computer Graphics are also used in the field of commercial arts. It is
used to generate television and advertising commercial.
7. Entertainment: Computer Graphics are now commonly used in making motion
pictures, music videos and television shows.
8. Visualization: It is used for visualization of scientists, engineers, medical
personnel, business analysts for the study of a large amount of information.
9. Educational Software: Computer Graphics is used in the development of
educational software for making computer- aided instruction.
10. Printing Technology: Computer Graphics is used for printing technology and textile
design.

Example of Computer Graphics Packages:


1. LOGO
2. COREL DRAW
3. AUTO CAD
4. 3D STUDIO
5. CORE
6. GKS (Graphics Kernel System)
7. PHIGS
8. CAM (Computer Graphics Metafile)
9. CGI (Computer Graphics Interface)

Cathode Ray Tube (CRT)


CRT stands for Cathode Ray Tube. CRT is a technology used in traditional computer
monitors and televisions. The image on CRT display is created by firing electrons
from the back of the tube of phosphorus located towards the front of the screen.

Once the electron heats the phosphorus, they light up, and they are projected on a
screen. The color you view on the screen is produced by a blend of red, blue and
green light.

Components of CRT:
1. Electron Gun: Electron gun consisting of a series of elements, primarily a heating
filament (heater) and a cathode. The electron gun creates a source of electrons
which are focused into a narrow beam directed at the face of the CRT.

2. Control Electrode: It is used to turn the electron beam on and off.

3. Focusing system: It is used to create a clear picture by focusing the electrons into
a narrow beam.

4. Defl ection Yoke: It is used to control the direction of the electron beam. It creates
an electric or magnetic field which will bend the electron beam as it passes through
the area. In a conventional CRT, the yoke is linked to a sweep or scan generator. The
defl ection yoke which is connected to the sweep generator creates a fl uctuating
electric or magnetic potential.

5. Phosphorus- coated screen: The inside front surface of every CRT is coated with
phosphors. Phosphors glow when a high- energy electron beam hits them.
Phosphorescence is the term used to characterize the light given off by a phosphor
after it has been exposed to an electron beam.

Random Scan and Raster Scan Display

Random Scan Display:

Random Scan System uses an electron beam which operates like a pencil to create a
line image on the CRT screen. The picture is constructed out of a sequence of
straight- line segments. Each line segment is drawn on the screen by directing the
beam to move from one point on the screen to the next, where its x & y coordinates
define each point. After drawing the picture. The system cycles back to the first line
and design all the lines of the image 30 to 60 time each second. The process is
shown in fig:
Random- scan monitors are also known as vector displays or stroke- writing displays
or calligraphic displays.

Advantages:

1. A CRT has the electron beam directed only to the parts of the screen where
an image is to be drawn.

2. Produce smooth line drawings.

3. High Resolution

Disadvantages:

1. Random- Scan monitors cannot display realistic shades scenes.

Raster Scan Display:

A Raster Scan Display is based on intensity control of pixels in the form of a


rectangular box called Raster on the screen. Information of on and off pixels is
stored in refresh buffer or Frame buffer. Televisions in our house are based on Raster
Scan Method. The raster scan system can store information of each pixel position, so
it is suitable for realistic display of objects. Raster Scan provides a refresh rate of 60
to 80 frames per second.

Frame Buffer is also known as Raster or bit map. In Frame Buffer the positions are
called picture elements or pixels. Beam refreshing is of two types. First is horizontal
retracing and second is vertical retracing. When the beam starts from the top left
corner and reaches the bottom right scale, it will again return to the top left side
called at vertical retrace. Then it will again more horizontally from top to bottom call
as horizontal retracing shown in fig:

Types of Scanning or travelling of beam in Raster Scan

1. Interlaced Scanning

2. Non- Interlaced Scanning

In Interlaced scanning, each horizontal line of the screen is traced from top to
bottom. Due to which fading of display of object may occur. This problem can be
solved by Non- Interlaced scanning. In this first of all odd numbered lines are traced
or visited by an electron beam, then in the next circle, even number of lines are
located.

For non- interlaced display refresh rate of 30 frames per second used. But it gives
fl ickers. For interlaced display refresh rate of 60 frames per second is used.

Advantages:

1. Realistic image

2. Million Different colors to be generated

3. Shadow Scenes are possible.

Disadvantages:

1. Low Resolution
2. Expensive

Differentiate between Random and Raster Scan Display:


Random Scan Raster Scan

1. It has high Resolution 1. Its resolution is low.

2. It is more expensive 2. It is less expensive

3. Any modification if needed is easy [Link]fication is tough

4. Solid pattern is tough to fill [Link] pattern is easy to fill

5. Refresh rate depends or resolution 5. Refresh rate does not depend on the
picture.

6. Only screen with view on an area is 6. Whole screen is scanned.


displayed.

7. Beam Penetration technology come under 7. Shadow mark technology came under
it. this.

8. It does not use interlacing method. 8. It uses interlacing

9. It is restricted to line drawing applications 9. It is suitable for realistic display.

Direct View Storage Tubes (DVST)


DVST terminals also use the random scan approach to generate the image on the
CRT screen. The term "storage tube" refers to the ability of the screen to retain the
image which has been projected against it, thus avoiding the need to rewrite the
image constantly.

Direct View Storage Tube (DVST) resembles CRT as it uses electron gun to draw
picture and phosphor coated screen to display it. The phosphor used in this is of high
persistence. DVST does not use refresh buffer or frame buffer to store picture
definition. Picture definition is stored in inside CRT in form positive charged
distribution. Because of this reason DVST is knows as Storage Type CRT. In DVST no
refreshing is required as result picture drawn on DVST will be seen for several
minutes before fading.

Various components of DVST :


1. Electron guns –
Two electron guns are used in DVST :
Primary guns: It is used to store the picture pattern.
Flood gun or Secondary gun: It is used to maintain picture display.

1. Phosphor Coated Screen –


In DVST the inner surface of CRT is coated with phosphor crystals is of high
persistence that emit light when beam of electrons strike them.
2. Storage Mesh –
It is thin and high quality wire that is coated with dielectric and is located just
behind phosphor coated screen. Primary gun deposits pattern of positive
charge on this grid and it is transferred to phosphor coated screen by
continuous fl ood of electrons produced by fl ood gun. Thus Storage Mesh
stores picture to be displayed in form of positive charge distribution.
3. Collector –
This grid is located just behind storage mesh and purpose of this negatively
charged grid is to smooth out fl ow of fl ood electrons.
Working principle of DVST:
In DVST similar with CRT electron gun and phosphor coated method is used. But in
this no electron beam is used to directly writing pictures on screen, but instead of
this we can used Storage mesh wire grid is used it is just located behind phosphor
coated screen. There is also another grid located just behind storage mesh is called
Collector and this purpose is to smooth out fl ow of fl ood electrons. The fl ood gun
produce large number of electrons, this negatively charged grid reduces speed of
these electrons. Then electrons pass through collector at low velocity and attracted
by positive charged portions of storage mesh and strike at portions of phosphor
coated screen to display picture. Some electrons get repelled by other portions of
mesh that are negatively charged.
Since the collector has slowly down electrons, in this way they not able to produce
sharpened images. So to reduce this problem, screen itself is maintained at a high
positive potential by means of voltage applied to thin aluminium coating between
tube face and phosphor.

Advantage:

1. No refreshing is needed.

2. High Resolution

3. Cost is very less

Disadvantage:

1. It is not possible to erase the selected part of a picture.

2. It is not suitable for dynamic graphics applications.

3. If a part of picture is to modify, then time is consumed.

Input Devices
The Input Devices are the hardware that is used to transfer transfers input to the
computer. The data can be in the form of text, graphics, sound, and text. Output
device display data from the memory of the computer. Output can be text, numeric
data, line, polygon, and other objects.

These Devices include:


1. Keyboard
2. Mouse
3. Trackball
4. Spaceball
5. Joystick
6. Light Pen
7. Digitizer
8. Touch Panels
9. Voice Recognition
10. Image Scanner
Output Devices

It is an electromechanical device, which accepts data from a computer and


translates them into form understand by users.
Following are Output Devices:
1. Printers
2. Plotters
Interactive Graphical Techniques

To construct various images and graphics in interactive manner, there are different
methods which are built into various graphics packages. These packages contains
various options which help user to enter information of coordinate by using stroke
devices or various locators. These coordinates helps in creating boundaries for
various objects which user is going to drawn.

Positioning Techniques :
It very basic technique of graphical input. It is also known as locating.
With the help of input device, user indicates position on the screen. To display
object this position marks location. Example: input position can be used to insert
symbol to specify endpoint of line.
The process of positioning involves two steps, in first step user have to move
cursor to desired spot on screen and in second step user inform computer by
pressing key or button.
The positioning is very often used in geometric modeling applications, where
if user wants to define new element of model or to change position of already
existing model.

Graphical User Interface (GUI)


A graphical user interface (GUI) is a digital interface in which a user interacts with
graphical components such as icons, buttons, and menus. In a GUI, the visuals
displayed in the user interface convey information relevant to the user, as well as
actions that they can take.

Popular examples of GUIs are Microsoft Windows, macOS, Android and Apple's iOS.
GUIs are also how we interact with the internet through web browsers like Google
Chrome, Microsoft Edge and Firefox.

Image representation
Image representation is a vast and fundamental concept in computer science
that enables the interpretation and manipulation of images in computing systems.
The way an image is represented can impact the result of tasks in fields such as
computer vision, machine learning, and digital graphics.

An image can be represented in various forms. Most of the time, it refers to the way
that brings information, such as color is coded digitally, and how the image is stored,
i.e., how an image file is structured.
Several open standards were recommended to create, manipulate, store, and
exchange digital images. The rules described the format of image files, the
algorithms of image encoding, the form of additional information often named as
metadata.
A digital image is the composition of individual pixels or picture elements. The pixels
are arranged in the form of row and column to form a picture area. The number of
pixels in an image is a function of the size of the image and number of pixels per unit
length (e.g., inch) in horizontal as well as vertical direction.
Image Processing
It is a method to implement some operations on an image. It is also used to get an
enhanced image or to access some useful information from an image. It is a type of
processing in which the input is an image, and output may be the image or
characteristics/features correlated with that image.
For example- photographs, frames of video.
Most image processing techniques consider the image as a two- dimensional and
applying standard signal- processing technique on it.
Pixel: “Pixel is the smallest unit of a picture displayed on the computer screen.”
A pixel includes its own:-

Intensity

Name or Address

The size of the image is defined as the total number of pixels in the horizontal
direction times the total number of pixels in the vertical direction (512 x 512,640 x
480, or 1024 x 768).
The ratio of an image’s width to its height, we can measure it in unit length or
number of pixels, is known as the aspect ratio of the image.
For example- A 2 x 2inch image and a 512 x 512 image have an aspect ratio of 1/1,
whereas a 6 x 4inch image and a 1024 x 768 image have an aspect ratio of 4/3.
Resolution: It is the number of separate pixels display on a screen expressed in
terms of pixels on the horizontal axis and vertical axis.
The sharpness of the picture on display depends on the resolution and the size of the
monitor.
“The number of pixels per unit is called the resolution of the image.”
It also includes-
Image Resolution: “The distance between two pixels.”
Screen Resolution: “The number of horizontal and vertical pixels displayed on
the screen is called Screen Resolution.”
For Example- 640 x 480, 1024 x 768 (Horizontal x Vertical)

Aspect Ratio: “The ratio of image’s width to its height is known as the aspect ratio of
an image.” The height and width of an image are measured in length or number of
pixels.
For Example: If a graphics has an aspect ratio of 2:1, it means the width is twice large
to height.
It includes-
Frame aspect ratio: Horizontal /Vertical Size
Pixel aspect ratio: Width of Pixel/Height of Pixel
Applications of Image Processing
Some application areas of Image Processing are as follow:

1. Computerized Photography

2. Space Image Processing (e.g., Hubble space telescope image, Interplanetary


probe images)

3. Medical/ Biological Image Processing

4. Automatic Character Recognition

5. Fingerprint/ Face/ Iris Recognition

6. Remote sensing

7. Industrial application

Format of Image Files


There are some different type of images which are mentioned as:
JPEG (Joint Photographic Experts Group): It is used for digital images,
especially for those images which are composed of digital photography. The
‘.jpeg’ filename extension is used to save the file.
PNG (Portable Network Graphics): These files are commonly used to store
graphics for web images. PNG was developed to enhance the non- registered
replacement for Graphics Interchange Format. The ‘.png’ filename extension is
used to save the file.
GIF (Graphics Interchange Format): It is a file format for storing graphical
images up to 256 colors. PNG is based on a lossless compression method,
which makes higher quality output. PNG was created as a more powerful
option to the GIF file format. The ‘.gif’ filename extension is used to save the
file.
TIFF/ TIF (Tagged Image File): These files can be saved in a collection of
color formats and many forms of compression. TIFF file is used to maintain
image integrity and clarity. It is often used for professional photography. The
‘.tif’ filename extension is used to save the file.
PSD (Photoshop Document): It is a layered image file used in Adobe
PhotoShop. It is a default format that is used by PhotoShop for saving data.
PSD is a custody file that allows the user to work with the images' separate
layers even after the file has been saved. The ‘.psd’ filename extension is used
to save the file.
PDF (Portable Document Format): It is used to share the documents between
computers and across operating system platforms when the user needs to
save files that cannot be altered. The ‘.pdf’ filename extension is used to save the
file.
EPS (Encapsulated Postscript): It is a graphics file format, which is used in
vector- based images. In Windows, the user needs graphics software to open
the EPS file (i.e., Adobe Illustrator, Coral Draw). The ‘.eps’ filename extension is
used to save the file.
AI (Adobe Illustrator Document): It is a file format developed by Adobe
system. It is used to represent single- page vector- based drawings in EPS or
PDF formats. The ‘.ai’ filename extension is used to save the file.
Line Generation Algorithms
A line connects two points. It is a basic element in graphics. To draw a line, you need
two points between which you can draw a line. In the following three algorithms, we
refer the one point of line as X0,Y0 and the second point of line as X1,Y1.

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.
Step1: Start
Step2: Declare x1,y1,x2 ,y2 ,dx,dy,x,y as integer variables.
Step3: Enter value of x1,y1,x2 ,y2 .
Step4: Calculate dx = x2 - x1
Step5: Calculate dy = y2 - y1
Step6: If ABS (dx) > ABS (dy)
Then step = abs (dx)
Else
Step7: xinc=dx/step
yinc=dy/step
assign x = x1
assign y = y1
Step8: Set pixel (x, y)
Step9: x = x + xinc
y = y + yinc
Set pixels (Round (x), Round (y))
Step10: Repeat step 9 until x = x2
Step11: End
Advantage:
1. It is a faster method than method of using direct use of line equation.
2. This method does not use multiplication theorem.
3. It allows us to detect the change in the value of x and y ,so plotting of same
point twice is not possible.
4. This method gives overfl ow indication when a point is repositioned.
5. It is an easy method because each step involves just two additions.
Disadvantage:
1. It involves fl oating point additions rounding off is done. Accumulations of
round off error cause accumulation of error.
2. Rounding off operations and fl oating point operations consumes a lot of time.
3. It is more suitable for generating line using the software. But it is less suited
for hardware implementation.

Example: If a line is drawn from (2, 3) to (6, 15) with use of DDA. How many points
will needed to generate such line?
Solution: P1 (2,3) P11 (6,15)
x1=2
y1=3
x2 = 6
y2 =15
dx = 6 - 2 = 4
dy = 15 - 3 = 12

m=

For calculating next value of x takes x = x +


Bresenham's Line Algorithm
This algorithm is used for scan converting a line. It was developed by Bresenham. It
is an efficient method because it involves only integer addition, subtractions, and
multiplication operations. These operations can be performed very rapidly so lines
can be generated quickly.
Step1: Start Algorithm
Step2: Declare variable x1,x2 ,y1,y2 ,d,i1,i2 ,dx,dy
Step3: Enter value of x1,y1,x2 ,y2
Where x1,y1are coordinates of starting point
And x2 ,y2 are coordinates of Ending point
Step4: Calculate dx = x2 - x1
Calculate dy = y2 - y1
Calculate i1=2*dy
Calculate i2 =2*(dy- dx)
Calculate d=i1- dx
Step5: Consider (x, y) as starting point and xend as maximum possible value of x.
If dx < 0
Then x = x2
y = y2
xend =x1
If dx > 0
Then x = x1
y = y1
xend =x2
Step6: Generate point at (x,y)coordinates.
Step7: Check if whole line is generated.
If x > = xend
Stop.
Step8: Calculate co- ordinates of the next pixel
If d < 0
Then d = d + i1
If d ≥ 0
Then d = d + i2
Increment y = y + 1
Step9: Increment x = x + 1
Step10: Draw a point of latest (x, y) coordinates
Step11: Go to step 7
Step12: End of Algorithm
Advantage:
1. It involves only integer arithmetic, so it is simple.
2. It avoids the generation of duplicate points.
3. It can be implemented using hardware because it does not use multiplication and
division.
4. It is faster as compared to DDA (Digital Differential Analyzer) because it does not
involve fl oating point calculations like DDA Algorithm.
Disadvantage:
1. This algorithm is meant for basic line drawing only Initializing is not a part of
Bresenham's line algorithm. So to draw smooth lines, you should want to look into a
different algorithm.

Example: Starting and Ending position of the line are (1, 1) and (8, 5). Find
intermediate points.
Solution: x1=1
y1=1
x2 =8
y2 =5
dx= x2 - x1=8- 1=7
dy=y2 - y1=5- 1=4
I1=2* ∆y=2*4=8
I2 =2*(∆y- ∆x)=2*(4- 7)=- 6
d = I1- ∆x=8- 7=1
x Y d=d+I1 or I2
1 1 d+I2 =1+(- 6)=- 5
2 2 d+I1=- 5+8=3
3 2 d+I2 =3+(- 6)=- 3
4 3 d+I1=- 3+8=5
5 3 d+I2 =5+(- 6)=- 1
6 4 d+I1=- 1+8=7
7 4 d+I2 =7+(- 6)=1
8 5
Mid- Point Line Drawing Algorithm
The Mid- point Subdivision algorithm is the extension of the Cyrus- Beck algorithm.
The Mid- Point line plotting algorithm was introduced by “Pitway and Van Aken.” It is
an incremental line drawing algorithm. In this algorithm, we perform incremental
calculations. The calculations are based on the previous step to find the value of the
next point. We perform the same process for each step. By using the mid- point
subdivision algorithm, we can draw a line with close approximation between two
points. The mid- point subdivision line drawing algorithm subdivides the line at its
midpoints continuously.
The Mid- point Subdivision algorithm helps to compute or calculate the visible areas
of lines that appear in the window. This line plotting algorithm follows the bisection
method to divide the line into equal partitions.
Algorithm:

Given-

Starting coordinates = (X0 , Y0 )


Ending coordinates = (Xn , Yn )
The points generation using Mid Point Line Drawing Algorithm involves the following
steps-

Step- 01:

Calculate ∆X and ∆Y from the given input.

These parameters are calculated as-

∆X = Xn – X0
∆Y =Yn – Y0

Step- 02:

Calculate the value of initial decision parameter and ∆D.

These parameters are calculated as-

D initial = 2∆Y – ∆X
∆D = 2(∆Y – ∆X)

Step- 03:

The decision whether to increment X or Y coordinate depends upon the fl owing


values of D initial.

Follow the below two cases-


Step- 04:

Keep repeating Step- 03 until the end point is reached.

For each D new value, follow the above cases to find the next coordinates.

Problem- 01:

Calculate the points between the starting coordinates (20, 10) and ending
coordinates (30, 18).

Solution-

Given-

Starting coordinates = (X0 , Y0 ) = (20, 10)


Ending coordinates = (Xn , Yn ) = (30, 18)

Step- 01:

Calculate ∆X and ∆Y from the given input.

∆X = Xn – X0 = 30 – 20 = 10
∆Y =Yn – Y0 = 18 – 10 = 8

Step- 02:

Calculate D initial and ∆D as-

D initial = 2∆Y – ∆X = 2 x 8 – 10 = 6
∆D = 2(∆Y – ∆X) = 2 x (8 – 10) = - 4

Step- 03:
As D initial >= 0, so case- 02 is satisfied.

Thus,

Xk+1 = Xk + 1= 20 + 1= 21
Yk+1 = Yk + 1= 10 + 1= 11
D new = D initial + ∆D = 6 + (- 4) = 2

Similarly, Step- 03 is executed until the end point is reached.

D initial D new Xk+1 Yk+1

20 10

6 2 21 11

2 -2 22 12

-2 14 23 12

14 10 24 13

10 6 25 14

6 2 26 15

2 -2 27 16

-2 14 28 16

14 10 29 17

10 30 18

Now we draw the line in below graph using above set of points:
Advantages of Mid- point Subdivision Line Drawing Algorithm
It is very easy to implement.
It is a less time- consuming algorithm.
This algorithm uses basic arithmetic operations.
It only requires integer data.
The drawn line is smooth than other line drawing algorithms.
Disadvantages of Mid- point Subdivision Algorithm
Sometimes this algorithm is not suitable due to critical images and graphics.
The points have less accuracy. There are improvements needed.

Mid - Point Circle Drawing Algorithm

Procedure-
Given-
Centre point of Circle = (X0 , Y0 )
Radius of Circle = R
The points generation using Mid Point Circle Drawing Algorithm involves the
following steps-

Step- 01:
Assign the starting point coordinates (X0 , Y0 ) as-

X0 = 0
Y0 = R
Step- 02:
Calculate the value of initial decision parameter P0 as-
P0 = 1– R

Step- 03:

Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).

Find the next point of the first octant depending on the value of decision parameter
Pk.

Follow the below two cases-

Step- 04:
If the given centre point (X0 , Y0 ) is not (0, 0), then do the following and plot the point-

Xplot = Xc + X0
Yplot = Yc + Y0
Here, (Xc, Yc) denotes the current value of X and Y coordinates.

Step- 05:
Keep repeating Step- 03 and Step- 04 until Xplot >= Yplot.

Step- 06:

Step- 05 generates all the points for one octant.

To find the points for other seven octants, follow the eight symmetry property of
circle.

This is depicted by the following figure-

Problem:

Given the centre point coordinates (0, 0) and radius as 10, generate all the points to
form a circle.

Solution-

Given-

Centre Coordinates of Circle (X0 , Y0 ) = (0, 0)


Radius of Circle = 10
Step- 01:

Assign the starting point coordinates (X0 , Y0 ) as-

X0 = 0
Y0 = R = 10

Step- 02:

Calculate the value of initial decision parameter P0 as-


P0 = 1– R

P0 = 1– 10

P0 = - 9

Step- 03:

As Pinitial < 0, so case- 01is satisfied.

Thus,

Xk+1 = Xk + 1= 0 + 1= 1
Yk+1 = Yk = 10
Pk+1 = Pk + 2 x Xk+1 + 1= - 9 + (2 x 1) + 1= - 6

Step- 04:

This step is not applicable here as the given centre point coordinates is (0, 0).

Step- 05:

Step- 03 is executed similarly until Xk+1 >= Yk+1 as follows-

Pk Pk+1 (Xk+1, Yk+1)


(0, 10)

-9 -6 (1, 10)

-6 -1 (2, 10)

-1 6 (3, 10)

6 -3 (4, 9)

-3 8 (5, 9)

8 5 (6, 8)

Algorithm Terminates
These are all points for Octant- 1.

Algorithm calculates all the points of octant- 1and terminates.

Now, the points of octant- 2 are obtained using the mirror effect by swapping X and Y
coordinates.

Octant- 1Points Octant- 2 Points

(0, 10) (8, 6)

(1, 10) (9, 5)

(2, 10) (9, 4)

(3, 10) (10, 3)

(4, 9) (10, 2)

(5, 9) (10, 1)

(6, 8) (10, 0)

These are all points for Quadrant- 1.


Now, the points for rest of the part are generated by following the signs of other
quadrants.
The other points can also be generated by calculating each octant separately.

Here, all the points have been generated with respect to quadrant- 1-

Quadrant- 1(X,Y) Quadrant- 2 (- X,Y) Quadrant- 3 (- X,- Y) Quadrant- 4 (X,- Y)

(0, 10) (0, 10) (0, - 10) (0, - 10)

(1, 10) (- 1, 10) (- 1, - 10) (1, - 10)

(2, 10) (- 2, 10) (- 2, - 10) (2, - 10)

(3, 10) (- 3, 10) (- 3, - 10) (3, - 10)

(4, 9) (- 4, 9) (- 4, - 9) (4, - 9)

(5, 9) (- 5, 9) (- 5, - 9) (5, - 9)

(6, 8) (- 6, 8) (- 6, - 8) (6, - 8)

(8, 6) (- 8, 6) (- 8, - 6) (8, - 6)

(9, 5) (- 9, 5) (- 9, - 5) (9, - 5)

(9, 4) (- 9, 4) (- 9, - 4) (9, - 4)

(10, 3) (- 10, 3) (- 10, - 3) (10, - 3)

(10, 2) (- 10, 2) (- 10, - 2) (10, - 2)

(10, 1) (- 10, 1) (- 10, - 1) (10, - 1)

(10, 0) (- 10, 0) (- 10, 0) (10, 0)

These are all points of the Circle.


Problem:

Given the centre point coordinates (4, - 4) and radius as 10, generate all the points to
form a circle.

Solution-
Points of octane 1of first quadrant:

(Xk+1, Yk+1) (Xplot, Yplot)

(0, 10) (4, 14)

(1, 10) (5, 14)

(2, 10) (6, 14)

(3, 10) (7, 14)

(4, 9) (8, 13)

(5, 9) (9, 13)

(6, 8) (10, 12)

(8, 6) (12, 10)

(9, 5) (13, 9)

(9, 4) (13, 8)

(10, 3) (14, 7)

(10, 2) (14, 6)

(10, 1) (14, 5)

(10, 0) (14, 4)

These are all points for Quadrant- 1.


The following table shows the points for all the quadrants-

Quadrant- 1(X,Y) Quadrant- 2 (- X,Y) Quadrant- 3 (- X,- Y) Quadrant- 4 (X,- Y)

(4, 14) (4, 14) (4, - 6) (4, - 6)

(5, 14) (3, 14) (3, - 6) (5, - 6)

(6, 14) (2, 14) (2, - 6) (6, - 6)

(7, 14) (1, 14) (1, - 6) (7, - 6)

(8, 13) (0, 13) (0, - 5) (8, - 5)

(9, 13) (- 1, 13) (- 1, - 5) (9, - 5)

(10, 12) (- 2, 12) (- 2, - 4) (10, - 4)

(12, 10) (- 4, 10) (- 4, - 2) (12, - 2)

(13, 9) (- 5, 9) (- 5, - 1) (13, - 1)

(13, 8) (- 5, 8) (- 5, 0) (13, 0)

(14, 7) (- 6, 7) (- 6, 1) (14, 1)

(14, 6) (- 6, 6) (- 6, 2) (14, 2)

(14, 5) (- 6, 5) (- 6, 3) (14, 3)

(14, 4) (- 6, 4) (- 6, 4) (14, 4)

These are all points of the Circle.

Advantages of Mid Point Circle Drawing Algorithm-

The advantages of Mid Point Circle Drawing Algorithm are-

It is a powerful and efficient algorithm.


2 2 2
The entire algorithm is based on the simple equation of circle X + Y = R .
It is easy to implement from the programmer’s perspective.

This algorithm is used to generate curves on raster displays.

Disadvantages of Mid Point Circle Drawing Algorithm-

The disadvantages of Mid Point Circle Drawing Algorithm are-

Accuracy of the generating points is an issue in this algorithm.

The circle generated by this algorithm is not smooth.

This algorithm is time consuming.

Bresenham Circle Drawing Algorithm

Procedure-

Given-

Centre point of Circle = (X0 , Y0 )


Radius of Circle = R
The points generation using Bresenham Circle Drawing Algorithm involves the
following steps-

Step- 01:
Assign the starting point coordinates (X0 , Y0 ) as-

X0 = 0
Y0 = R
Step- 02:
Calculate the value of initial decision parameter P0 as-

P0 = 3 – 2 x R

Step- 03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).

Find the next point of the first octant depending on the value of decision parameter
Pk.

Follow the below two cases-


Step- 04:

If the given centre point (X0 , Y0 ) is not (0, 0), then do the following and plot the point-

Xplot = Xc + X0
Yplot = Yc + Y0

Here, (Xc, Yc) denotes the current value of X and Y coordinates.

Step- 05:

Keep repeating Step- 03 and Step- 04 until Xplot => Yplot.

Step- 06:

Step- 05 generates all the points for one octant.


To find the points for other seven octants, follow the eight symmetry property of
circle.
This is depicted by the following figure-
Problem- 01:

Given the centre point coordinates (0, 0) and radius as 8, generate all the points to
form a circle.

Solution-
Given-

Centre Coordinates of Circle (X0 , Y0 ) = (0, 0)


Radius of Circle = 8
Step- 01:
Assign the starting point coordinates (X0 , Y0 ) as-

X0 = 0
Y0 = R = 8
Step- 02:
Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R

P0 = 3 – 2 x 8
P0 = - 13
Step- 03:
As Pinitial < 0, so case- 01is satisfied.
Thus,
Xk+1 = Xk + 1= 0 + 1= 1
Yk+1 = Yk = 8
Pk+1 = Pk + 4 x Xk+1 + 6 = - 13 + (4 x 1) + 6 = - 3
Step- 04:

This step is not applicable here as the given centre point coordinates is (0, 0).

Step- 05:

Step- 03 is executed similarly until Xk+1 >= Yk+1 as follows-

Pk Pk+1 (Xk+1, Yk+1)

(0, 8)

- 13 -3 (1, 8)

-3 11 (2, 8)

11 5 (3, 7)

5 7 (4, 6)

7 (5, 5)

Algorithm Terminates
These are all points for Octant- 1.

Algorithm calculates all the points of octant- 1and terminates.

Now, the points of octant- 2 are obtained using the mirror effect by swapping X and Y
coordinates.

Octant- 1Points Octant- 2 Points

(0, 8) (5, 5)
(1, 8) (6, 4)

(2, 8) (7, 3)

(3, 7) (8, 2)

(4, 6) (8, 1)

(5, 5) (8, 0)

These are all points for Quadrant- 1.

Now, the points for rest of the part are generated by following the signs of other
quadrants.

The other points can also be generated by calculating each octant separately.

Here, all the points have been generated with respect to quadrant- 1-

Quadrant- 1(X,Y) Quadrant- 2 (- X,Y) Quadrant- 3 (- X,- Y) Quadrant- 4 (X,- Y)

(0, 8) (0, 8) (0, - 8) (0, - 8)

(1, 8) (- 1, 8) (- 1, - 8) (1, - 8)

(2, 8) (- 2, 8) (- 2, - 8) (2, - 8)

(3, 7) (- 3, 7) (- 3, - 7) (3, - 7)

(4, 6) (- 4, 6) (- 4, - 6) (4, - 6)

(5, 5) (- 5, 5) (- 5, - 5) (5, - 5)

(6, 4) (- 6, 4) (- 6, - 4) (6, - 4)

(7, 3) (- 7, 3) (- 7, - 3) (7, - 3)

(8, 2) (- 8, 2) (- 8, - 2) (8, - 2)

(8, 1) (- 8, 1) (- 8, - 1) (8, - 1)

(8, 0) (- 8, 0) (- 8, 0) (8, 0)
These are all points of the Circle.

You might also like