Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

computer graphics unit 1, Study notes of Computer Graphics

overview of graphics system Raster scan Displays - Random Scan Displays - Graphics software - Output primitives: Line drawing algorithms- Circle Generating algorithms- Filled Area Primitives- Character Generating Algorithm.

Typology: Study notes

2020/2021

Uploaded on 01/14/2021

sudhagar-murugesan
sudhagar-murugesan 🇮🇳

5

(1)

1 document

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Application
model
Application
program
Graphics
Library (GL) Graphics
System
COMPUTER GRAPHICS
UNIT-I
OVERVIEW OF GRAPHICS SYSTEM
Raster scan Displays - Random Scan Displays - Graphics software -
Output primitives: Line drawing algorithms- Circle Generating algorithms-
Filled Area Primitives- Character Generating Algorithm.
Computer Graphics:
Creation, Manipulation and Storage of geometric objects & their images
Display those images on screens or hardcopy devices
Computer graphics is a sub-field of computer science which studies methods
for digitally synthesizing and manipulating visual content.
Although the term often refers to the study of three-dimensional computer
graphics,it also encompasses two-dimensional graphics and image
processing.
Applications of Computer Graphics:
Computer Aided Design (CAD)
Presentation Graphics
Computer Art
Entertainment (animation, games, …)
Education & Training
Visualization (scientific & business)
Image Processing
Graphical User Interfaces
What is an output primitive?
Graphics programming packages provide function to describe a scene in terms of
These basic geometric structures, referred to as output primitives
Polyclone
Filled polygons
Ellipse
Text
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download computer graphics unit 1 and more Study notes Computer Graphics in PDF only on Docsity!

Application model Application program Graphics Library (GL) Graphics System

COMPUTER GRAPHICS

UNIT-I

OVERVIEW OF GRAPHICS SYSTEM

Raster scan Displays - Random Scan Displays - Graphics software -

Output primitives: Line drawing algorithms- Circle Generating algorithms-

Filled Area Primitives- Character Generating Algorithm.

Computer Graphics:

 Creation, Manipulation and Storage of geometric objects & their images  Display those images on screens or hardcopy devices  Computer graphics is a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content.  Although the term often refers to the study of three-dimensional computer graphics,it also encompasses two-dimensional graphics and image processing.

Applications of Computer Graphics:

  • Computer Aided Design (CAD)
  • Presentation Graphics
  • Computer Art
  • Entertainment (animation, games, …)
  • Education & Training
  • Visualization (scientific & business)
  • Image Processing
  • Graphical User Interfaces

What is an output primitive?

Graphics programming packages provide function to describe a scene in terms of These basic geometric structures, referred to as output primitives  Polyclone  Filled polygons  Ellipse  Text

 Raster images

Resolution

 The maximum number of points that can be displayed without overlap on a CRT is referred to as the resolution.  Resolution is the number of pixels contained on a display monitor, expressed in terms of the number of pixels on the horizontal axis and vertical axis. It can be also referred as maximum number of points that can be displayed without overlap on a CRT.

Aspect ratio

 Another property of video monitors is aspect ratio. This number gives the ratio of vertical points to horizontal points necessary to produce equal-length lines in both directions on the screen. (Sometimes aspect ratio is stated in terms of the ratio of horizontal to vertical points.)  An aspect ratio of 3/4 means that a vertical line plotted with three points has the same length as a horizontal line plotted with four points.

Define pixel:

 Pixel is shortened form of picture element. It is the smallest discrete component of an image or picture on a CRT screen.  Each screen point is referred to as pixel or pel.

Define bitmap:

A raster graphics image or bitmap is a data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium.

What is persistence?

The time it takes the emitted light from the screen to decay one tenth of its original intensity is called as persistence.

What is video controller?

 It is a special purpose controller, which is used to control the operation of the display device.

 A fixed area of the system is reserved for the frame buffer, and the video

controller is given direct access to the frame buffer memory.

 Screen is refreshed 60 times/sec –Interlacing (Odd numbered and Even

numbered lines)  Most common method. Random Scan Also called Vector/Stroke/Calligraphic Displays  Electron is deflected from end point to end point  Character is also made of sequence of stroke (short lines)  Random scan display is the use of geometrical primitives such as points, lines, curves, and polygons, which are all based upon mathematical equation.  Phosphor has a short persistence-decays in10-100ms  To display a picture, the system cycle through the set of commands in the display file, drawing each component line in turn.  The CRT's electron beam is directed only to the parts of the screen where a picture is to be drawn. The picture definition is stored as a set of line-drawing commands in a refresh display file or a refresh buffer in memory.  Random-scan generally have higher resolution than raster systems and can produce smooth line drawings, however it cannot display realistic shaded scenes.

RASTER DISPLAY VS RANDOM DISPLAY

It has Poor or Less Resolution, Zig Zag line is produced. It has High Resolution, Smooth line is produced. Electron beam is directed from top to bottom at a time on screen, but electron beam is directed to whole screen. Electron beam is directed only to that part of screen is required to be drawn.

It is less expensive. It is expensive. Refresh Rate is 60 to 80 frames per second. Refresh Rate depends on number of lines to be displayed ,30 to 60 times per second. Stores Picture Definition in Frame Buffer. Stores Picture Definition in Display files. Screen points/pixels are used to draw an image. Mathematical functions are used to draw an image.

Graphics Software: Classifications

I. Special purpose package

  • Designed for non-programmers
  • No graphics procedures involved
  • Communicate with a set of menus. Eg : CAD II. General programming package
  • Designed for programmers
  • Provide library of graphics functions used in programming language. Eg : Graphics Library Line drawing algorithms  A straight line is specified by two endpoint positions. Line drawing is done by:  Calculating intermediate positions between the endpoints.  Directing the output device to fill in the calculated positions as in the case of plotting single points.  The Cartesian intercept equation for a straight line: y= m. x +b  Where m is the line slop and b is y intercept.  For line segment starting in (x1,y1) and ending in (x2,y2), the slop is: m= (y1- y2)/(x1-x2) DDA algorithm(digital differential analyser)  Algorithm is an incremental scan conversion method.

yk+1- yk= m K takes integer values starting from 1,at the first point, and increasing by 1 on each step until reaching the final endpoint. The calculated y must be rounded to the nearest integer. Case 2: Negative slope slope (m) of line is > 1 (i.e., line 2) if m > 1 i.e., case of line 2, then the most appropriate strategy would be to move towards the y direction by 1 unit every time and determine the pixel in x direction which best suits the line and get that pixel lightened to plot the line. So, in Case 2, i.e., (infinity) > m > 1 where y is to be increased by 1 unit every time and proper x is approximated. slope of the line is m= Δ y / Δ x Δ y = m. Δ x Δ x= Δ y/m (the slope is negative and greater than 1) if |m|>1,(Δ y =1) Δ x= 1 /m xk+1- xk= 1/m K takes integer values starting from 1,at the first point, and increasing by 1 on each step until reaching the final endpoint. The calculated x must be rounded to the nearest integer. Advantages  Faster method for calculating pixel positions  Eliminates the multiplication operations Disadvantages  Accumulation of round off error  Rounding operations and floating point arithmetic are time consuming yk+1= m +yk xk+1= xk+ (1/m)

Bresenham’s Line Algorithm

 An accurate and

efficient raster line- generating algorithm, developed by Bresenham, scan converts lines using only incrementa1 integer calculations that can be adapted to display circles and other curves.  The vertical axes show-scan-line positions, and the horizontal axes identify pixel columns.  we need to determine at the next sample position whether to plot the pixel at position (11, 11) or the one at (11, 12).  Similarly, Fig. shows-a negative slope-line path starting from the left endpoint at pixel position (50, 50) In this one, do we select the next pixel position as (51,501or as (51,49)?  These questions are answered with Bresenham's line algorithm by testing the sign of an integer parameter, whose value is proportional to the difference between the separations of the two pixel positions from the actual line path.  Pixel positions along a line path are then determined by sampling at unit x intervals Starting from the left endpoint(x, yo) of a given line, we step to each successive column (x position) and plot the pixel whose scan-line y value is closest to the line path. They coordinate on the mathematical line at pixel column position xk+l is calculated as

y = m (xk + 1) + b

This m r s i v e calculation of decision parameters is performed at each integer x position, starting at the left coordinate endpoint of the line. The first parameter, p,, is evaluated P0=2ΔY –ΔX

Midpoint Circle Algorithm

Similarly to the case with lines, there is an incremental algorithm for drawing circles – the mid-point circle algorithm In the mid-point circle algorithm we use eight-way symmetry so only ever calculate the points for the top right eighth of a circle, and then use symmetry to get the rest of the points Circle function is, f (^) ¿˚¿(x,y)= x^2 + y^2 - r^2 Any point ( x , y) on the boundary of the circle with radius r satisfies the equation f^ ¿˚¿(x,y)= By evaluating this function at the midpoint between the candidate pixels we can make our decision

if ( x , y ) is inside the circle boundary

f (^) circ ( x , y )

¿ 0, ¿ 0, ¿ 0 ,

if ( x , y ) is on the circle boundary

if ( x , y ) is outside the circle boundary

Assuming we have just plotted the pixel at ( xk,yk ) so we need to choose between ( xk+ 1 ,yk ) and ( xk+ 1 ,yk- 1) Our decision variable can be defined as:

If pk < 0 the midpoint is inside the circle and and the pixel at yk is closer to the circle Otherwise the midpoint is outside and yk- 1 is closer To ensure things are as efficient as possible we can do all of our calculations incrementally First consider:

where yk+1 is either yk or yk- 1 depending on the sign of pk increments for obtaining pk + 1 , are either pk + 1 + 1 (if pk is negative) or 2 xk + 1 + 1. Evaluation of the terms 2 xk + 1 and 2 yk + 1 also be done incrementally as

2 xk + 1 = 2 xk +

2 yk + 1 = 2 yk +

The initial decision parameter is obtained by evaluating the circle function at the start position ( x 0 , y 0 )=(0,r) Or

p 0 =

5 4 − r If the radius r is specified as an integer, we can simply round p 0 to

p 0

1-r Mid- point

pk = f circ ( xk + 1 , yk −

¿( xk + 1 )

2

+( yk −

2

− r

2 pk + 1 = f (^) circ (^) ( xk + 1 + 1 , yk + 1 −

2 )

¿[( xk + 1 )+ 1 ]^2 +

(

yk + 1 −

2 ) 2

− r^2

p 0 = f (^) circ ( 1 , r − 1 2 ) ¿ 1 +( r − 1 2 )^2 − r^2 ¿ 5 4 − r

( xi + 1 , yi −

Scan-Line Polygon Fill Algorithm

The basic scan-line algorithm is as follows:

 Find the intersections of the scan line

With all edges of the polygon.

 Sort the intersections by increasing

x coordinate.

 Fill in all pixels between pairs of intersections that lie interior to the

polygon.

Filled- Area Primitives

 A standard output primitive in general graphics packages is a

solid-color or patterned polygon area.

 There are two basic approaches to area filling on raster systems:

I. The scan-line approach

 Determine the overlap intervals for scan lines that cross the

area.

 It is typically used in general graphics packages to fill

polygons, circles, ellipses.

Inside-Outside Tests

 Area-filling algorithms and other graphics processes often need to

identify interior regions of objects.

2 4 6 8 1 0

 To identify interior regions of an object graphics packages normally

use either:

1. Odd-Even rule

2. Nonzero winding number rule

3. Polygon no self-intersection – Vertices

Odd-Even rule (Odd Parity Rule, Even-Odd Rule):

1. draw a line from any position P to a distant point outside the

coordinate extents of the object and counting the number of edge

crossings along the line.

2. If the number of polygon edges crossed by this line is odd then

P is an interior point. Else, P is an exterior point

Nonzero Winding Number Rule :

 Counts the number of times the polygon edges wind around

a particular point in the counterclockwise direction.

 This count is called the winding number

1. The 4-connected method. 2. The 8-connected method.

Four connected approaches is more suitable than the eight

connected approaches.

Flood-Fill Algorithm

 Sometimes we want to fill in (or recolor) an area that is not

defined within a single color boundary.

 We can paint such areas by replacing a specified interior color

instead of searching for a boundary color value.

 This approach is called a flood-fill algorithm.

 We start from a specified interior point ( x, y ) and reassign all

pixel values that are currently set to a given interior color with

the desired fill color.

 If the area we want to paint has more than one interior color, we

can first reassign pixel values so that all interior points have the

same color.

 Using either a 4-connected or 8-connected approach, we then

step through pixel positions until all interior points have been

repainted.

Character Generation Algorithm

 Typeface: The overall design style for a set of characters is call

typeface: Zar, nazanin, Titr.

 Font: Referred to a set of cast metal character forms in a

particular size and forma: 10 point Zar.

Two different representation are used for storing computer fonts:

1. Bitmap font (or bitmapped font)

2. Outline font

I. Bitmap font (or bitmapped font):

 We can produce boldface, italic, or different size by

manipulating the curve definition for the character

outlines.

 It does take more time to process the outline fonts,

because they must be scan converted into frame

buffer.