Unit - I Introduction To Computer Graphics and Scan Conversion Algorithm
Unit - I Introduction To Computer Graphics and Scan Conversion Algorithm
Semester-I
Second Year of Computer Engineering
(2019 Course)
210244: Computer Graphics
Prof. Priti Vaidya (Div – B)
(Course Teacher)
Department of Computer Engineering, 1
K K W I E E R, Nashik
Details of Course Delivery
• Course will be delivered online till the lock down period using Gotowebinar
• Students should preferably use laptop or desktop while attending the online
lectures
• Students will ensure that they have joined the Googlegroup as well as
WhatsApp group
The links for online lectures will be sent on this Google group use such links
to join the online class
2
Course Delivery and Assessment
• Quizzes of MCQs will be conducted during lecture using Learnico.
• Attendance will be recorded. However, if you do not participate in
quizzes/activities, you will be marked as absent
• For each unit as per syllabus
• 1 pre assignment and 1 post assignment will be provided.
• Each assignment will have due date and students should submit the same in soft copy
form on or before due date
3
Schemes & Schedule
• Teaching Scheme:
• 3 Hours/week
• Examination Scheme:
• Midsem Examination: 30 Marks
• End Semester Examination: 70 Marks
• Number of credits: 03
Day Time
• Lecture Schedule
Tuesday 11.30 AM to 12.30 PM
Wednesday 1.15 PM to 2.15 PM
Thursday 10.15 AM to 11.15 AM
4
Syllabus
• Unit 1 - Graphics Primitives & Scan Conversion Algorithms
• Unit 2 – Polygon, Windowing and Clipping
• Unit 3 - 2D, 3D Transformations & Projections
• Unit 4 - Light, Color, Shading & Hidden Surfaces
• Unit 5 - Curves and Fractals
• Unit 6 - Animation and Gaming
5
Books
• 1. S. Harrington, “Computer Graphics”, 2nd Edition, McGraw-Hill
Publications, 1987, ISBN 0 – 07 – 100472 – 6.
8
Computer Graphics
• Computer graphics deals with generating images with the aid of computers.
• Computer graphics is a core technology in digital photography, film, video
games, cell phone and computer displays, and many specialized applications.
• Computer graphics development has had a significant impact on many types
of media and has revolutionized animation, movies, advertising, video games,
and graphic design in general.
• The term computer graphics has been used in a broader sense to describe
"almost everything on computers that is not text or sound“.
9
Applications
TV 4:3
HDTV 16:9
Page 8.5:11 ~ 3/4
• The frequency at which content of frame buffer is sent to display monitor is called
Refreshing rate ( 60 Hz)
Frame Buffer
• A frame buffer is characterized by size, x, y,
and pixel depth.
• The resolution of a frame buffer is the
number of pixels in the display. e.g.
1024x1024 pixels.
Bilevel or monochrome displays have
• Bit Planes or Bit Depth is the number of 1 bit/pixel
bits corresponding to each pixel. This 8bits/pixel -> 256 simultaneous colors
determines the color resolution of the
24bits/pixel -> 16 million
buffer. simultaneous colors
Specifying Color
• Direct color : 8
bits(B)
Green
Blue
28
Display Devices
• The primary method of getting information out of a computer is to use a
computer video display unit (VDU)
• Display systems convert computer signals into text and pictures and display
them on a TV‐like screen.
• The purpose of display technology is to simplify information sharing.
29
Display Devices
1. Cathode-Ray Tube(CRT)
2. Color CRT Monitor
3. Liquid crystal display(LCD)
4. Light Emitting Diode(LED)
5. Direct View Storage Tubes(DVST)
6. Plasma Displays
30
1. Cathode-ray Tube (CRT)
• CRT stands for Cathode ray tube.
• It is a technology which is used in traditional computer monitor and
television.
• Cathode ray tube is a particular type of vacuum tube that displays images
when an electron beam collides on the radiant surface.
31
Components of CRT
32
Representing an object on the screen
• Two ways to represent an object on the screen are-
1. Raster Scan Displays
2. Random Scan Displays
33
Raster Scan Displays
• It is a scanning technique in which the electron beam moves along the
screen. It moves from top to bottom, covering one line at a time.
34
Raster Scan Displays
• Advantages:
• Real image
• Many colors to be produced
• Dark scenes can be pictured
• Disadvantages:
• Less resolution
• Display picture line by line
• More costly
35
Random Scan Displays
• It is also known as stroke-writing display or calligraphic display. In this, the
electron beam points only to the area in which the picture is to be drawn.
36
Random Scan Displays
• Advantages:
• High Resolution
• Draw smooth lines
• Disadvantages:
• It does only the wireframe.
• It creates complex scenes due to flicker.
37
2. Color CRT Monitor
• It is similar to a CRT monitor.
• The basic idea behind the color CRT monitor is to combine three basic
colors- Red, Green, and Blue. By using these three colors, we can produce
millions of different colors.
• The two basic color display producing techniques are:
• Beam–Penetration Method
• Shadow–Mask Method
38
Beam–Penetration Method
39
Beam–Penetration Method
• Advantages:
• Better Resolution
• Half cost
• Inexpensive
• Disadvantages:
• Only four possible colors
• Time Consuming
40
Shadow–Mask Method
41
Shadow–Mask Method
• Advantages:
• Display a wider range picture
• Display realistic images
• In-line arrangement of RGB color
• Disadvantages:
• Difficult to cover all three beams on the same hole
• Poor Resolution
42
3.Liquid crystal display (LCD)
• Liquid crystals are basically liquid chemicals whose molecules can be aligned
precisely when an electrical current is introduced.
43
Liquid Crystal Display (LCD)
• Advantages:
• Produce a bright image
• Energy efficient
• Completely flat screen
• Disadvantages:
• Fixed aspect ratio & Resolution
• Lower Contrast
• More Expensive
44
4. Light Emitting Diode (LED)
• LED is a device which emits when current passes through it. It is a
semiconductor device.
• The size of the LED is small, so we can easily make any display unit by
arranging a large number of LEDs.
• LED consumes more power compared to LCD. LED is used on TV,
Smartphone's, motor vehicles, traffic light, etc.
• LEDs are powerful in structure, so they are capable of withstanding
mechanical pressure. LED also works at high temperatures.
45
Light Emitting Diode (LED)
• Advantages:
• The Intensity of light can be controlled.
• Low operational Voltage.
• Capable of handling the high temperature.
• Disadvantages:
• More Power Consuming than LCD.
46
5. Direct View Storage Tube (DVST)
• It is used to store the picture information as a charge distribution behind the
phosphor-coated screen.
47
Direct View Storage Tube (DVST)
• Advantages:
• Less Time Consuming
• No Refreshing Required
• High-Resolution
• Less Cost
• Disadvantages:
• The specific part of the image cannot be erased.
• They do not display color.
48
6. Plasma Displays
• It is a type of flat panel display which uses tiny plasma cells. It is also known
as the Gas-Discharge display.
49
Plasma Displays
• Advantages:
• Wall Mounted
• Slim
• Wider angle
• Disadvantages:
• Phosphorus loses luminosity over time.
• It consumes more electricity than LCD.
• Large Size
50
Adjusting Display Settings
• Refresh rate
• Frame rate
• Resolution
• Multiple Displays
51
Refresh Rate
• How many times in one second the image on the screen can be completely
redrawn, if necessary.
• Measured in screen draws per second, or hertz (Hz),
• It indicates how much effort is being put into checking for updates to the
displayed image.
• Refresh rate is selected for the monitor but must be supported by the
graphics card
52
Refresh rate continued
• LCD TVs have a fixed refresh rate
• PC monitor refresh rates are adjustable
• As you increase the resolution higher refresh rates become unavailable
• Therefore to get the highest refresh rate you may have to settle for lower
resolution
53
Frame Rate
• Measure of how many unique screens of content were recorded per second.
• Video recordings can be done in different frames per second (fps)
• Most common – 30fps, 24fps
• Refresh rate chosen on playback device must be compatible with the
recorded video frame rate
• 30fps video plays well at 60Hz refresh rate but not 24fps
54
Resolution
• How many software picture elements (pixels) are used to draw the screen.
• Higher resolutions means more information can be displayed in the same
screen area.
• Higher resolution also means smaller and harder to see images
55
Resolution continued
• Resolution describes visible image’s dimensions, i.e how many rows and
columns of pixels are used to draw the screen.
• Resolution of 1024×768 means 1024 pixels across (columns) and 768 pixels
down (rows) were used to draw the pixel matrix.
• 1024 × 768 =786,432 pixels to draw the screen.
56
Multiple Displays
• Simultaneous use of 2 or more monitors (external displays)
• Dual view – Extended desktop option or desktop cloning
• Windows Vista’s Windows Display Driver Model (WDDM) version 1
requires same driver to be used for all adapters in multiple monitor setup
57
Scan Conversion Algorithms
Introduction
• Scan Conversion
The process in which the object is represented as
the collection of discrete pixels
b
9/14/2021 Scan Conversion(Computer Graphics ) 4
Line and Line Segment Continues
Line Segment
• Line can extend forever both forward and backward . Line segments are
generated by considering points on the line between two fixed points
P2
L
P1
• If P1(x1,y1) & P2(x2,y2) are two endpoint of line segment then, length of
line segment (L) can be calculated as
L ( x 2 x1) 2 ( y 2 y1) 2
Pi(Xi, yi)
Line 2
Dx
9/14/2021 Scan Conversion(Computer Graphics ) 7
Line drawing algorithm
0 1 2 3 4 5 6 7 8 9 10 11 12
9/14/2021 Scan Conversion(Computer Graphics ) 9
Increment Method
• Gentle slope lines in which there are more
columns than rows.
• These lines are closer to horizontal lines
45o
• Bresenham’s Algorithm
dy y2 y1
m
dx x2 x1
(x2,y2)
dy
(x1,y1)
dx
2. Case 2: m> 1
Steep/sharp slope lines in which there are more
rows than columns. Here length of y component
ie Dy(Y2-Y1) is longer than x component Dx(X1-X1))
|Dx|<|Dy|
9/14/2021 Scan Conversion(Computer Graphics ) 15
Case 1: -1 m < 1
m= Dy/Dx
ie Dy= m. Dx
(y1+ 1) – (y1) = m. [(x1+1)-(x1)]
Therefore, [(x1+1)-(x1)] = 1
(y1+ 1) – (y1) = m. (1)
(y1+ 1) = m +(y1)
ynew=m + yold
I X Y Plot
1 5 8 5,8
2 6 7.25=7 6,7
3 7 6.50=7 7,7
4 8 5.75=6 8,6
5 9 5 9,5
I X Y Plot
1 0 0 0,0
2 -1 -1 -1,-1
3 -2 -2 -2,-2
4 -3 -3 -3,-3
5 -4 -4 -4,-4
6 -5 -5 -5,-5
7 -6 -6 -6,-6
I X Y Plot
1 1 1 1,1
2 1.8 2 2,2
3 2.6 3 3,3
4 3.4 4 3,4
5 4.2 5 4,5
6 5 6 5,6
Bird
Sun
Hills
Tree
Display file
• A display file is a series of graphics commands
that define an output image.
• The image is created by executing the
commands to combine various primitives.
Segments
• The image information is stored in a display file
• The current display file structure does not satisfy
the requirement to view an image
• To achieve this, display file is divided into
segments
• Each segment corresponds to a component and is
associated with a set of attributes and image
transformation parameters like scaling, rotation
Segments Advantages
• Presence of Segment allows :
– Subdivision of picture
– Visualization of particular part of picture
– Scaling, rotation and translation of picture
Functions for Segmenting the display
• Segment Operations
– Segment Creation
– Closing a Segment
– Deleting a Segment
– Renaming a Segment
Segment Creation
• Segment must be created or opened
• Two segments can’t be opened at the same
time
• The segment created must be given a name
• Initialize items in segment table and attributes
of segments are initialized to default.
Algorithm
1. If any segment is open, give error message : “Segment is still
open” and go to step 8.
2. Read the name of the new segment.
3. If the segment name is not valid, give error message : “Segment
name not a valid name” and go to step 8.
4. If given segment name already exists, give error message
: “Segment name already exists in name list” and go to step 8.
5. Make next free storage area in display file as start of new
segment.
6. Initialize size of new segment to 0 and all its attributes to their
default values.
7. Inform that the new segment is now open.
8. Stop.
Closing a Segment
• After completing entry of all display file
instructions, the segment needs to be closed
Algorithm
1. If any segment is not open, give error message : “No
segment is open now” and go to step 6.
2. Change the name of currently opened segment to any
unnamed segment, lets say 0.
3. Delete any other unnamed segment instruction which
may have been saved and initialize above unnamed
segment with no instructions.
4. Make the next free storage area available in display
file as start of the unnamed segment.
5. Initialize size of unnamed segment to 0.
6. Stop.
Deleting a Segment
To delete a particular segment from display
file, we must just delete that one segment
Algorithm
1. Read the name of the segment to be deleted.
2. If segment name is not valid, give error message : “Segment name
is not a valid name” and go to step 8.
3. If the segment is open, give error message : “Can’t delete an open
segment” and go to step 8.
4. If size of segment is less than 0, no processing is required and go
to step 8.
5. The segments which follow the deleted segment are shifted by its
size.
6. Recover deleted space by resetting index of next free instruction.
7. The starting position of shifted segments is adjusted by
subtracting the size of deleted segment from it.
8. Stop.
Renaming a Segment
• This is done to achieve Double Buffering i.e.
the idea of storing two images, one to show
and other to create, alter and for animation.
Algorithm
1. If both old and new segment names are not valid, give
error message : “Segment names are not valid
names” and go to step 6.
2. If any of two segments is open, give error message
: “Segments are still open” and go to step 6.
3. If new segment name given already exists in the
display list, give error message : “Segment name
already exists” and go to step 6.
4. The old segment table entry are copied into new
position.
5. Delete the old segment.
6. Stop.
Advantages of using segmented
display
• Segmentation allows to organize display files
in sub-picture structure.
• It allows to apply different set of attributes to
different portions of image.
• It makes it easier to the picture by
changing/replacing segments.
• It allows application of transformation on
selective portions of image.