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

CG UNIT 1 - Unit 1 Notes

The document provides an introduction to computer graphics, including definitions, types, applications, and basic terminology. It discusses the basics of computer graphics, including how it involves creating and manipulating visual images using computers. It also describes different types of computer graphics as non-interactive and interactive. Finally, it discusses video display devices used in computer graphics such as cathode ray tubes and flat panel displays.

Uploaded by

jjkk
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)
67 views

CG UNIT 1 - Unit 1 Notes

The document provides an introduction to computer graphics, including definitions, types, applications, and basic terminology. It discusses the basics of computer graphics, including how it involves creating and manipulating visual images using computers. It also describes different types of computer graphics as non-interactive and interactive. Finally, it discusses video display devices used in computer graphics such as cathode ray tubes and flat panel displays.

Uploaded by

jjkk
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
You are on page 1/ 38

lOMoARcPSD|23231139

CG UNIT 1 - Unit 1 notes

B.sc(Computer Science (Thiruvalluvar University)

Studocu is not sponsored or endorsed by any college or university


Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

UNIT 1- BASICS OF COMPUTER GRAPHICS

1.1 Introduction of Computer Graphics

 Computer Graphics involves technology to access. The process transforms and


presents information in a visual form. The role of computer graphics insensible.

 In today life, computer graphics has now become a common element in user
interfaces, T.V. commercial motion pictures.

 Computer Graphics is the creation of pictures with the help of a computer. The
end product of the computer graphics is a picture it may be a business graph,
drawing, and engineering.

 In computer graphics, two or three-dimensional pictures can be created that


are used for research.

 Many hardware devices algorithm has been developing for improving the speed of
picture generation with the passes of time.

 It includes the creation storage of models and image of objects. These models
for various fields like engineering, mathematical and so on.

 Today computer graphics is entirely different from the earlier one. It is not
possible. It is an interactive user can control the structure of an object of
various input devices.

1.1.1 Definition of Computer Graphics

It is the use of computers to create and manipulate pictures on a display device. It


comprises of software techniques to create, store, modify, represents pictures.

1.1.2 Why Computer Graphics used?

 Interactive computer graphics work using the concept of two-way communication


between computer users.
 The computer will receive signals from the input device, and the picture is
modified accordingly. Picture will be changed quickly when we apply command.

1 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.1.3 Application of Computer Graphics

 Education and Training: Computer-generated model of the physical, financial


and economic system is often used as educational aids.

 Use in Biology: Molecular biologist can display a picture of molecules and gain
insight into their structure with the help of computer graphics.

 Computer-Generated Maps: Town planners and transportation engineers can


use computer-generated maps which display data useful to them in their planning
work.

 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.

 Presentation Graphics: Example of presentation Graphics are bar charts, line


graphs, pie charts and other displays showing relationships between multiple
parameters.

 Computer Art: Computer Graphics are also used in the field of commercial arts.
It is used to generate television and advertising commercial.

 Entertainment: Computer Graphics are now commonly used in making motion


pictures, music videos and television shows.

 Visualization: It is used for visualization of scientists, engineers, medical


personnel, business analysts for the study of a large amount of information.

 Educational Software: Computer Graphics is used in the development of


educational software for making computer-aided instruction.

 Printing Technology: Computer Graphics is used for printing technology and


textile design.

Example of Computer Graphics Packages

 LOGO
 COREL DRAW
 AUTO CAD
 3D STUDIO
 CORE
 GKS (Graphics Kernel System)
 PHIGS
 CAM (Computer Graphics Metafile)
 CGI (Computer Graphics Interface)

2 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.1.4 Types of Computer Graphics

It can be classified into two types

 Non-Interactive Computer Graphics


 Interactive Computer Graphics

Non-Interactive 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.

 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.

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.

 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.

Advantages:

 Higher Quality
 More precise results or products
 Greater Productivity
 Lower analysis and design cost
 Significantly enhances our ability to understand data and to perceive trends.

1.1.5 Basic Terminologies

 Frame Buffer: A digital frame buffer is large, contiguous piece of computer


memory used to hold or map the image displayed on the screen.

 Persistence: Persistence is the duration of phosphorescence. Different kinds of


phosphors are available for use in CRT. Besides color, a major difference between
phosphor in their persistence how they continue to emit light after the electron
beam is removed.

 Resolution: Use to describe the number of pixels that are used on display image.

3 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 Aspect Ratio: It is the ratio of width to its height. Its mesuré is unit in length or
number of pixels.

o Aspect Ratio = width unit / height unit

 Display Processor: It is interpreter or piece of hardware that converts display


processor code into pictures. It is one of the four main parts of the display
processor

 Display File Memory: It is used for generation of the picture. It is used for
identification of graphic entities.

 Display Controller:

o It handles interrupt
o It maintains timings
o It is used for interpretation of instruction.

 Display Generator:

o It is used for the generation of character.


o It is used for the generation of curves.

 Display Console: It contains CRT, Light Pen, and Keyboard and deflection
system.

1.2 Video Display Devices

The most commonly used display device is a video monitor. The operation of most
video monitors based on CRT (Cathode Ray Tube). The following display devices are used:

 Refresh Cathode Ray Tube


 Random Scan and Raster Scan
 Color CRT Monitors
 Direct View Storage Tubes
 Flat Panel Display
 Lookup Table

1.2.1 Cathode Ray Tube (CRT)

 CRT stands for Cathode Ray Tube. CRT is a technology used in traditional
computer monitors and televisions.

4 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 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

Main Components of CRT are:

 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.

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

 Focusing system: It is used to create a clear picture by focusing the electrons


into a narrow beam.

 Deflection 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 deflection yoke which is connected to the sweep generator creates
a fluctuating electric or magnetic potential.

 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.

5 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.2.2 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

 A CRT has the electron beam directed only to the parts of the screen where an
image is to be drawn.
 Produce smooth line drawings.
 High Resolution

Disadvantage

 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.

6 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 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:

Advantages

 Realistic image
 Million Different colors to be generated
 Shadow Scenes are possible.

Disadvantages

 Low Resolution
 Expensive

Differentiate between Random and Raster Scan Display:

Random Scan Raster Scan

It has high Resolution Its resolution is low.

It is more expensive It is less expensive

Any modification if needed is easy Modification is tough

Solid pattern is tough to fill Solid pattern is easy to fill

7 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

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

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

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

It does not use interlacing method. It uses interlacing

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

1.2.3 Color CRT Monitors

The CRT Monitor display by using a combination of phosphors. The phosphors are
different colors. There are two popular approaches for producing color displays with a CRT
are:

 Beam Penetration Method

 Shadow-Mask Method

Beam Penetration Method

 The Beam-Penetration method has been used with random-scan monitors.


 In this method, the CRT screen is coated with two layers of phosphor, red and
green and the displayed color depends on how far the electron beam penetrates the
phosphor layers.
 This method produces four colors only, red, green, orange and yellow.
 A beam of slow electrons excites the outer red layer only; hence screen shows red
color only.
 A beam of high-speed electrons excites the inner green layer. Thus screen shows a
green color.

Advantages:
 Inexpensive

Disadvantages:
 Only four colors are possible
 Quality of pictures is not as good as with another method.

8 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Shadow-Mask Method:
Shadow Mask Method is commonly used in Raster-Scan System because they
produce a much wider range of colors than the beam-penetration method. It is used in the
majority of color TV sets and monitors.

Construction:

 A shadow mask CRT has 3 phosphor color dots at each pixel position.

o One phosphor dot emits: red light

o Another emits: green light

o Third emits: blue light

 This type of CRT has 3 electron guns, one for each color dot and a shadow mask
grid just behind the phosphor coated screen.

 Shadow mask grid is pierced with small round holes in a triangular pattern.

Figure shows the delta-delta shadow mask method commonly used in color CRT system.

9 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Working:

 Triad arrangement of red, green, and blue guns.

 The deflection system of the CRT operates on all 3 electron beams


simultaneously;

 The 3 electron beams are deflected and focused as a group onto the shadow mask,
which contains a sequence of holes aligned with the phosphor- dot patterns.

 When the three beams pass through a hole in the shadow mask, they activate a
dotted triangle, which occurs as a small color spot on the screen.

 The phosphor dots in the triangles are organized so that each electron beam can
activate only its corresponding color dot when it passes through the shadow mask.

Inline arrangement:

Another configuration for the 3 electron guns is an Inline arrangement in which the 3
electron guns and the corresponding red-green-blue color dots on the screen, are aligned
along one scan line rather of in a triangular pattern.

This inline arrangement of electron guns in easier to keep in alignment and is commonly used
in high-resolution color CRT's.

Advantage:

 Realistic image
 Million different colors to be generated
 Shadow scenes are possible

Disadvantage:
 Relatively expensive compared with the monochrome CRT.
 Relatively poor resolution
 Convergence Problem

10 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.2.4 Direct View Storage Tubes

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.

 Function of guns: Two 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.

Advantage:

 No refreshing is needed.
 High Resolution
 Cost is very less

Disadvantage:

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


 It is not suitable for dynamic graphics applications.
 If a part of picture is to modify, then time is consumed.

1.2.5 Look-Up Table:

 Image representation is essentially the description of pixel colors.


 There are three primary colors: R (red), G (green) and B (blue).
 Each primary color can take on intensity levels produces a variety of colors.
 Using direct coding, we may allocate 3 bits for each pixel, with one bit for each
primary color.

11 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 The 3-bit representation allows each primary to vary independently between two
intensity levels: 0 (off) or 1 (on). Hence each pixel can take on one of the eight
colors.

Bit 1:r Bit 2:g Bit 3:b Color name

0 0 0 Black

0 0 1 Blue

0 1 0 Green

0 1 1 Cyan

1 0 0 Red

1 0 1 Magenta

1 1 0 Yellow

1 1 1 White

1.2.6 Flat Panel Display:

The Flat-Panel display refers to a class of video devices that have reduced volume,
weight and power requirement compare to CRT. Example: Small T.V. monitor, calculator,
pocket video games, laptop computers, an advertisement board in elevator.

1. Emissive Display: The emissive displays are devices that convert electrical energy into
light. Examples are Plasma Panel, thin film electroluminescent display and LED (Light
Emitting Diodes).

2. Non-Emissive Display: The Non-Emissive displays use optical effects to convert sunlight
or light from some other source into graphics patterns. Examples are LCD (Liquid Crystal
Device).

12 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Plasma Panel Display:

Plasma-Panels are also called as Gas-Discharge Display. It consists of an array of


small lights. Lights are fluorescent in nature. The essential components of the plasma-panel
display are:

 Cathode: It consists of fine wires. It delivers negative voltage to gas cells. The
voltage is released along with the negative axis.

 Anode: It also consists of line wires. It delivers positive voltage. The voltage is
supplied along positive axis.

 Fluorescent cells: It consists of small pockets of gas liquids when the voltage is
applied to this liquid (neon gas) it emits light.

 Glass Plates: These plates act as capacitors. The voltage will be applied, the cell
will glow continuously.

Figure shows the state of cell in plasma panel display:

Advantage:

 High Resolution
 Large screen size is also possible.
 Less Volume
 Less weight
 Flicker Free Display

13 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Disadvantage:

 Poor Resolution
 Wiring requirement anode and the cathode is complex.
 Its addressing is also complex.

LED (Light Emitting Diode):

 In an LED, a matrix of diodes is organized to form the pixel positions in the


display and picture definition is stored in a refresh buffer.
 Data is read from the refresh buffer and converted to voltage levels that are
applied to the diodes to produce the light pattern in the display.

LCD (Liquid Crystal Display):


 Liquid Crystal Displays are the devices that produce a picture by passing
polarized light from the surroundings or from an internal light source through a
liquid-crystal material that transmits the light.
 LCD uses the liquid-crystal material between two glass plates; each plate is the
right angle to each other between plates liquid is filled.
 One glass plate consists of rows of conductors arranged in vertical direction.
 Another glass plate is consisting of a row of conductors arranged in horizontal
direction.
 The pixel position is determined by the intersection of the vertical & horizontal
conductor.
 Liquid crystal display is temperature dependent. It is between zero to seventy
degree Celsius. It is flat and requires very little power to operate.

14 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Advantage:

 Low power consumption.


 Small Size
 Low Cost

Disadvantage:

 LCDs are temperature-dependent (0-70°C)


 LCDs do not emit light; as a result, the image has very little contrast.
 LCDs have no color capability.
 The resolution is not as good as that of a CRT.

1.3 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:

 Keyboard
 Mouse
 Trackball
 Spaceball
 Joystick
 Light Pen
 Digitizer
 Touch Panels
 Voice Recognition
 Image Scanner

1.4 Hard Copy Devices

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


them into form understand by users.

Following are Output Devices:

 Printers

 Plotters

15 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Printers:

 Printer is the most important output device, which is used to print data on paper.

 Types of Printers: There are many types of printers which are classified on various
criteria as shown in fig:

Impact Printers: The printers that print the characters by striking against the ribbon and onto
the papers are known as Impact Printers.

These Printers are of two types:

 Character Printers

 Line Printers

Page Printers are of two types:

 Laser Printers

 Inkjet Printers

Dot Matrix Printers:

Dot matrix has printed in the form of dots. A printer has a head which contains nine
pins. The nine pins are arranged one below other. Each pin can be activated independently.

16 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

All or only the same needles are activated at a time. When needless is not activated, and then
the tip of needle stay in the head. When pin work, it comes out of the print head. In nine pin
printer, pins are arranged in 5 * 7 matrixes.

Daisy Wheel Printers:

Head is lying on a wheel and Pins corresponding to characters are like petals of Daisy,
that's why called Daisy wheel printer.

Drum Printers:

These are line printers, which prints one line at a time. It consists of a drum. The
shape of the drum is cylindrical.

The drum is solid and has characters embossed on it in the form of vertical bands. The
characters are in circular form.

Each band consists of some characters. Each line on drum consists of 132 characters.
Because there are 96 lines so total characters are (132 * 95) = 12, 672.

Chain Printers:

These are called as line printers. These are used to print one line at a line. Basically,
chain consists of links. Each link contains one character.

Printers can follow any character set style, i.e., 48, 64 or 96 characters. Printer
consists of a number of hammers also.

17 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Non-Impact Printers:

The printers that print the characters without striking against the ribbon and onto the
papers are called Non-Impact Printers. These printers print a complete page at a time,
therefore, also known as Page Printers.

Inkjet Printers:

These printers use a special link called electrostatic ink. The printer head has a special
nozzle. Nozzle drops ink on paper. Head contains up to 64 nozzles. The ink dropped is
deflected by the electrostatic plate. The plate is fixed outside the nozzle.

Laser Printers:

These are non-impact page printers. They use laser lights to produces the dots needed
to form the characters to be printed on a page & hence the name laser printers.

The output is generated in the following steps:

 Step1: The bits of data sent by processing unit act as triggers to turn the laser
beam on & off.

 Step2: The output device has a drum which is cleared & is given a positive
electric charge. To print a page the modulated laser beam passing from the laser
scans back & forth the surface of the drum

18 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Step3: The laser exposed parts of the drum attract an ink powder known as toner.

Step4: The attracted ink powder is transferred to paper.

Step5: The ink particles are permanently fixed to the paper by using either heat or pressure
technique.

Step6: The drum rotates back to the cleaner where a rubber blade cleans off the excess ink &
prepares the drum to print the next page.

1.5 Graphics Software:

There are two types of Graphics Software.

1. General Purpose Packages: Basic Functions in a general package include those


for generating picture components (straight lines, polygons, circles and other figures),
setting color and intensity values, selecting views, and applying transformations.

Example of general purpose package is the GL (Graphics Library), GKS, PHIGS,


PHIGS+ etc.

2. Special Purpose Packages: These packages are designed for non programmers, so
that these users can use the graphics packages, without knowing the inner details.

Example of special purpose package is

 Painting programs

 Package used for business purpose

 Package used for medical systems.

 CAD packages

1.6 Scan Conversion Definition

 It is a process of representing graphics objects a collection of pixels.

 The graphics objects are continuous. The pixels used are discrete. Each pixel can
have either on or off state.

 The circuitry of the video display device of the computer is capable of converting
binary values (0, 1) into a pixel on and pixel off information. 0 is represented by
pixel off. 1 is represented using pixel on. Using this ability graphics computer
represent picture having discrete dots.

 Any model of graphics can be reproduced with a dense matrix of dots or points.
Most human beings think graphics objects as points, lines, circles, ellipses.

19 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 For generating graphical object, many algorithms have been developed.

 Advantage of developing algorithms for scan conversion

 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.

Examples of objects which can be scan converted

 Point
 Line
 Sector
 Arc
 Ellipse
 Rectangle
 Polygon
 Characters
 Filled Regions

The process of converting is also called as rasterization. The algorithms


implementation varies from one computer system to another computer system. Some
algorithms are implemented using the software. Some are performed using hardware or
firmware. Some are performed using various combinations of hardware, firmware, and
software.

Pixel or Pel:

 The term pixel is a short form of the picture element. It is also called a point or
dot.

 It is the smallest picture unit accepted by display devices.

 A picture is constructed from hundreds of such pixels.

 Pixels are generated using commands. Lines, circle, arcs, characters; curves are
drawn with closely spaced pixels.

 To display the digit or letter matrix of pixels is used.

 The closer the dots or pixels are, the better will be the quality of picture.

 Closer the dots are, crisper will be the picture. Picture will not appear jagged and
unclear if pixels are closely spaced.

20 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 So the quality of the picture is directly proportional to the density of pixels on the
screen.

 Pixels are also defined as the smallest addressable unit or element of the screen.
Each pixel can be assigned an address as shown in fig:

1.6.1 Scan Converting 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.

Example: Display coordinates points as shown in fig would both be represented by


pixel (2, 1). In general, a point p (x, y) is represented by the integer part of x & the integer
part of y that is pixels [(INT (x), INT (y).

21 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.6.2 Scan Converting a Straight Line

A straight line may be defined by two endpoints & an equation. In fig the two
endpoints are described by (x1,y1) and (x2,y2). The equation of the line is used to determine
the x, y coordinates of all the points that lie between these two endpoints.

Properties of Good Line Drawing Algorithm:

1. Line should appear Straight: We must appropriate the line by choosing addressable
points close to it. If we choose well, the line will appear straight, if not, we shall produce
crossed lines.

2. Lines should terminate accurately: Unless lines are plotted accurately, they may
terminate at the wrong place.

22 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

3. Lines should have constant density: 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.

4. Line density should be independent of line length and angle: This can be done by
computing an approximating line-length estimate and to use a line-generation algorithm that
keeps line density constant to within the accuracy of this estimate.

5. Line should be drawn rapidly: This computation should be performed by special-purpose


hardware.

1.6.3 Algorithm for line Drawing:

 DDA (Digital Differential Analyzer)

 Bresenham's Algorithm

1.6.3.1 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.

DDA Algorithm:

Step1: Start Algorithm

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)

23 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Step9: x = x + xinc
y = y + yinc
Set pixels (Round (x), Round (y))

Step10: Repeat step 9 until x = x2

Step11: End Algorithm

Advantage:

 It is a faster method than method of using direct use of line equation.

 This method does not use multiplication theorem.

 It allows us to detect the change in the value of x and y ,so plotting of same point
twice is not possible.

 This method gives overflow indication when a point is repositioned.

 It is an easy method because each step involves just two additions.

Disadvantage:

 It involves floating point additions rounding off is done. Accumulations of round off
error cause accumulation of error.

 Rounding off operations and floating point operations consumes a lot of time.

 It is more suitable for generating line using the software. But it is less suited for
hardware implementation.

1.6.3.2 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.

 In this method, next pixel selected is that one who has the least distance from true
line.

The method works as follows:

 Assume a pixel P1'(x1',y1'),then select subsequent pixels as we work our may to


the night, one pixel position at a time in the horizontal direction toward P2'(x2',y2').

24 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

 Once a pixel in choose at any step

 The next pixel is

 Either the one to its right (lower-bound for the line)

 One top its right and up (upper-bound for the line)

 The line is best approximated by those pixels that fall the least distance from the
path between P1',P2'.

Advantage:

 It involves only integer arithmetic, so it is simple.


 It avoids the generation of duplicate points.
 It can be implemented using hardware because it does not use multiplication and
division.
 It is faster as compared to DDA (Digital Differential Analyzer) because it does not
involve floating point calculations like DDA Algorithm.

Disadvantage:

 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.

Bresenham's Line Algorithm:

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 xendas maximum possible value of x.
If dx < 0
Then x = x2
y = y2

25 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

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

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

26 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

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

Differentiate between DDA Algorithm and Bresenham's Line Algorithm:

DDA Algorithm Bresenham's Line Algorithm

1. DDA Algorithm use floating point, i.e., 1. Bresenham's Line Algorithm use fixed point,
Real Arithmetic. i.e., Integer Arithmetic

2. DDA Algorithms uses multiplication & 2.Bresenham's Line Algorithm uses only
division its operation subtraction and addition its operation

3. DDA Algorithm is slowly than 3. Bresenham's Algorithm is faster than DDA


Bresenham's Line Algorithm in line Algorithm in line because it involves only
drawing because it uses real arithmetic addition & subtraction in its calculation and uses
(Floating Point operation) only integer arithmetic.

4. DDA Algorithm is not accurate and 4. Bresenham's Line Algorithm is more accurate
efficient as Bresenham's Line Algorithm. and efficient at DDA Algorithm.

5.DDA Algorithm can draw circle and 5. Bresenham's Line Algorithm can draw circle
curves but are not accurate as and curves with more accurate than DDA
Bresenham's Line Algorithm Algorithm.

27 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

1.6.4 Defining 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.

For drawing, circle considers it at the origin. If a point is P1(x, y), then the other seven points
will be

So we will calculate only 45°arc. From which the whole circle can be determined easily.

If we want to display circle on screen then the putpixel function is used for eight points as
shown below:

putpixel (x, y, color)


putpixel (x, -y, color)
putpixel (-x, y, color)
putpixel (-x, -y, color)

28 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

putpixel (y, x, color)


putpixel (y, -x, color)
putpixel (-y, x, color)
putpixel (-y, -x, color)

Example: Let we determine a point (2, 7) of the circle then other points will be (2, -7), (-2, -
7), (-2, 7), (7, 2), (-7, 2), (-7, -2), (7, -2)

These seven points are calculated by using the property of reflection. The reflection is
accomplished in the following way:

The reflection is accomplished by reversing x, y co-ordinates.

There are two standards methods of mathematically defining a circle centered at the origin.

 Defining a circle using Polynomial Method

 Defining a circle using Polar Co-ordinates

Defining a circle using Polynomial Method:

The first method defines a circle with the second-order polynomial equation as shown in fig:

y2=r2-x2
Where x = the x coordinate

29 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

y = the y coordinate
r = the circle radius

With the method, each x coordinate in the sector, from 90° to 45°, is found by stepping x

from 0 to & each y coordinate is found by evaluating for each step of x.

Algorithm:

Step1: Set the initial variables


r = circle radius
(h, k) = coordinates of circle center
x=o
I = step size

xend=

Step2: Test to determine whether the entire circle has been scan-converted.

If x > xend then stop.

Step3: Compute y =

Step4: Plot the eight points found by symmetry concerning the center (h, k) at the
current (x, y) coordinates.

Plot (x + h, y +k) Plot (-x + h, -y + k)


Plot (y + h, x + k) Plot (-y + h, -x + k)
Plot (-y + h, x + k) Plot (y + h, -x + k)
Plot (-x + h, y + k) Plot (x + h, -y + k)

30 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Step5: Increment x = x + i

Step6: Go to step (ii).

Defining a circle using Polar Co-ordinates :

The second method of defining a circle makes use of polar coordinates as shown in
fig:

x=r cos θ y = r sin θ


Where θ=current angle
r = circle radius
x = x coordinate
y = y coordinate

By this method, θ is stepped from 0 to & each value of x & y is calculated.

Algorithm:

Step1: Set the initial variables:

r = circle radius
(h, k) = coordinates of the circle center
i = step size

θ_end=
θ=0

31 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Step2: If θ>θendthen stop.

Step3: Compute

x = r * cos θ y=r*sin?θ

Step4: Plot the eight points, found by symmetry i.e., the center (h, k), at the current
(x, y) coordinates.

Plot (x + h, y +k) Plot (-x + h, -y + k)


Plot (y + h, x + k) Plot (-y + h, -x + k)
Plot (-y + h, x + k) Plot (y + h, -x + k)
Plot (-x + h, y + k) Plot (x + h, -y + k)

Step5: Increment θ=θ+i

Step6: Go to step (ii).

1.6.4.1 Bresenham's Circle Algorithm:

Scan-Converting a circle using Bresenham's algorithm works as follows: Points are


generated from 90° to 45°, moves will be made only in the +x & -y directions as shown in
fig:

The best approximation of the true circle will be described by those pixels in the raster that
falls the least distance from the true circle. We want to generate the points from

32 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

90° to 45°. Assume that the last scan-converted pixel is P1 as shown in fig. Each new point
closest to the true circle can be found by taking either of two actions.

Bresenham's Circle Algorithm:

Step1: Start Algorithm

Step2: Declare p, q, x, y, r, d variables


p, q are coordinates of the center of the circle
r is the radius of the circle

Step3: Enter the value of r

Step4: Calculate d = 3 - 2r

Step5: Initialize x=0


&nbsy= r

Step6: Check if the whole circle is scan converted


If x > = y
Stop

Step7: Plot eight points by using concepts of eight-way symmetry. The center is at (p,
q). Current active pixel is (x, y).
putpixel (x+p, y+q)
putpixel (y+p, x+q)
putpixel (-y+p, x+q)
putpixel (-x+p, y+q)
putpixel (-x+p, -y+q)

33 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

putpixel (-y+p, -x+q)


putpixel (y+p, -x+q)
putpixel (x+p, -y-q)

Step8: Find location of next pixels to be scanned


If d < 0
then d = d + 4x + 6
increment x = x + 1
If d ≥ 0
then d = d + 4 (x - y) + 10
increment x = x + 1
decrement y = y - 1

Step9: Go to step 6

Step10: Stop Algorithm

Example: Plot 6 points of circle using Bresenham Algorithm. When radius of circle is 10
units. The circle has centre (50, 50).

Solution: Let r = 10 (Given)

Step1: Take initial point (0, 10)


d = 3 - 2r
d = 3 - 2 * 10 = -17
d < 0 ∴ d = d + 4x + 6
= -17 + 4 (0) + 6
= -11

Step2: Plot (1, 10)


d = d + 4x + 6 (∵ d < 0)
= -11 + 4 (1) + 6
= -1

Step3: Plot (2, 10)


d = d + 4x + 6 (∵ d < 0)
= -1 + 4 x 2 + 6
= 13

Step4: Plot (3, 9) d is > 0 so x = x + 1, y = y - 1


d = d + 4 (x-y) + 10 (∵ d > 0)
= 13 + 4 (3-9) + 10
= 13 + 4 (-6) + 10
= 23-24=-1

34 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

Step5: Plot (4, 9)


d = -1 + 4x + 6
= -1 + 4 (4) + 6
= 21

Step6: Plot (5, 8)


d = d + 4 (x-y) + 10 (∵ d > 0)
= 21 + 4 (5-8) + 10
= 21-12 + 10 = 19

So P1 (0,0)⟹(50,50)
P2 (1,10)⟹(51,60)
P3 (2,10)⟹(52,60)
P4 (3,9)⟹(53,59)
P5 (4,9)⟹(54,59)
P6 (5,8)⟹(55,58)

16.4.2 MidPoint Circle Algorithm

It is based on the following function for testing the spatial relationship between the
arbitrary point (x, y) and a circle of radius r centered at the origin:

Algorithm:
Step1: Put x =0, y =r in equation 2
We have p=1-r

Step2: Repeat steps while x ≤ y


Plot (x, y)
If (p<0)
Then set p = p + 2x + 3
Else
p = p + 2(x-y)+5

35 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

y =y - 1 (end if)
x =x+1 (end loop)

Step3: End

Program to draw a circle using Midpoint Algorithm:

#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>

class bresen
{
float x, y,a, b, r, p;
public:
void get ();
void cal ();
};
void main ()
{
bresen b;
b.get ();
b.cal ();
getch ();
}
Void bresen :: get ()
{
cout<<"ENTER CENTER AND RADIUS";
cout<< "ENTER (a, b)";
cin>>a>>b;
cout<<"ENTER r";
cin>>r;
}
void bresen ::cal ()
{
/* request auto detection */
int gdriver = DETECT,gmode, errorcode;
int midx, midy, i;
/* initialize graphics and local variables */
initgraph (&gdriver, &gmode, " ");
/* read result of initialization */
errorcode = graphresult ();
if (errorcode ! = grOK) /*an error occurred */
{
printf("Graphics error: %s \n", grapherrormsg (errorcode);
printf ("Press any key to halt:");
getch ();

36 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])
lOMoARcPSD|23231139

BECS 54B & BECA 54B – COMPUTER GRAPHICS UNIT 1

exit (1); /* terminate with an error code */


}
x=0;
y=r;
putpixel (a, b+r, RED);
putpixel (a, b-r, RED);
putpixel (a-r, b, RED);
putpixel (a+r, b, RED);
p=5/4)-r;
while (x<=y)
{
If (p<0)
p+= (4*x)+6;
else
{
p+=(2*(x-y))+5;
y--;
}
x++;
putpixel (a+x, b+y, RED);
putpixel (a-x, b+y, RED);
putpixel (a+x, b-y, RED);
putpixel (a+x, b-y, RED);
putpixel (a+x, b+y, RED);
putpixel (a+x, b-y, RED);
putpixel (a-x, b+y, RED);
putpixel (a-x, b-y, RED);
}
}

Output:

37 RAJESWARI COLLEGE OF ARTS & SCIENCE FOR WOMEN, DEPT. OF CS

Downloaded by Ho go ([email protected])

You might also like