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

Lesson5

The document is a presentation on 2D Scan Raster Conversion from the ICS 2311 Computer Graphics course at Jomo Kenyatta University. It covers topics such as line and curve drawing, area drawing, text rendering methods, aliasing in 2D drawing, and line drawing algorithms. Additionally, it includes exercises and solutions related to the concepts discussed.

Uploaded by

kevinnjuguna811
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)
7 views

Lesson5

The document is a presentation on 2D Scan Raster Conversion from the ICS 2311 Computer Graphics course at Jomo Kenyatta University. It covers topics such as line and curve drawing, area drawing, text rendering methods, aliasing in 2D drawing, and line drawing algorithms. Additionally, it includes exercises and solutions related to the concepts discussed.

Uploaded by

kevinnjuguna811
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/ 14

JOMO KENYATTA UNIVERSITY

OF
AGRICULTURE & TECHNOLOGY
JKUAT SODeL

SCHOOL OF OPEN, DISTANCE AND eLEARNING


P.O. Box 62000, 00200
©2014

Nairobi, Kenya
E-mail: [email protected]

ICS 2311 Computer Graphics

JJ II LAST REVISION ON October 16, 2014


J I
J DocDoc I
Back Close
ICS 2311 Computer Graphics
This presentation is intended to covered within one week.
The notes, examples and exercises should be supple-
mented with a good textbook. Most of the exercises have
solutions/answers appearing elsewhere and accessible by
JKUAT SODeL

clicking the green Exercise tag. To move back to the same


page click the same tag appearing at the end of the solu-
tion/answer.
©2014

Errors and omissions in these notes are entirely the re-


sponsibility of the author who should only be contacted
through the Department of Curricula & Delivery
(SODeL) and suggested corrections may be e-mailed to
[email protected].
JJ II
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 0
ICS 2311 Computer Graphics
LESSON 5
2D Scan Raster Conversion

5.1. Introduction
JKUAT SODeL

5.1.1. 2D Raster Scan Conversion


’Scan conversion’ is a general term for drawing methods which
create (or ’digitise’) raster images according to given picture
©2014

’primitives’.
The term is mainly used for drawing methods for 2D picture
elements or primitives such as lines, polygons and text.
All three of these are used in Java programs we shall be
considering.
JJ II
In contrast, general 3D drawing methods are termed render-
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 1
ICS 2311 Computer Graphics
ing methods, though some of these may use 2D picture primi-
tives.

5.1.2. 2D Line and Curve Drawing


JKUAT SODeL

Most (straight) lines and curves drawn in computer graphics


satisfy equating a function of x and y with zero.
For example, we can re-express the line equation y=mx+c
©2014

as 0=mx+c−y.
Most line and curve drawing methods effectively hunt along
a pixel at a time, steering left or right as needed to find a trail
of pixels to be drawn, by calculating which next pixel will keep
the relevant function closest to zero.
JJ II Most line or curve drawing methods do their hunt for pixels
J I using only integer calculations.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 2
ICS 2311 Computer Graphics
The time taken to draw a line or curve increases mainly in
proportion to the number of pixels to be drawn.
Circular and elliptical arcs take longer to draw than straight
lines.
JKUAT SODeL

Some curves take longer than circles.

5.1.3. 2D Area Drawing


©2014

Filled area drawings are of two main types:


1. Areas defined by polygon boundaries: broadly sim-
ilar considerations apply to line drawing, with the added
complication of defining what counts as the inside of the
boundary.
JJ II 2. Flood fill, where the boundary to be filled is bounded
J I by a pixel colour criterion. This tends to be used only in
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 3
ICS 2311 Computer Graphics
systems for purely 2D graphics painting or photographic
image manipulation.
The time taken to draw a filled area increases mainly in propor-
tion to the number of pixels to be drawn but also in proportion
JKUAT SODeL

to the length of its boundary, which becomes more relevant as


the area becomes thinner .
Variants on area drawing which give variable colour or map
©2014

a texture into the area typically take longer.

5.1.4. Text:
2D scan conversion of Text uses either of the following methods:
1. raster fonts,
JJ II 2. line drawing, or
J I 3. area drawing.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 4
ICS 2311 Computer Graphics
Raster fonts are already scan-converted; each character is quickly
painted in place by a raster-op. This way of drawing text does
not cater for sloping text or text which gradually changes size.
Line-drawn fonts are mainly used in Computer Aided Design,
JKUAT SODeL

emulating prior manual practice.


Area-drawn fonts are more general but slower and are more
appropriate in typesetting, especially with large font sizes, in
©2014

artwork, and in 3D graphics where text may be mapped to arbi-


trary surfaces. Some typesetting systems such as LATEX may use
scalable fonts defined as area drawings, but at run-time create
raster fonts in the sizes required, for more efficiency with longer
documents.
JJ II
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 5
ICS 2311 Computer Graphics
5.1.5. Aliasing in 2D Drawing
Simply choosing some pixels to draw often results in the familiar
’jaggies’. This is a form of aliasing. Aliasing in computing gener-
ally is substitution of something (e.g. some pixels) for something
JKUAT SODeL

else (e.g. an ideal area to draw).In computer graphics, aliasing


denotes distortion or noise in images due to approximation.
Three main forms of aliasing:
©2014

1. Outline aliasing
2. Motion aliasing
3. Color aliasing

• Outline aliasing:
JJ II Outline aliasing refers to the unintended jagged appearance of
J I lines, curves or area boundaries.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 6
ICS 2311 Computer Graphics
This can be overcome using ’antialiasing’ methods
• These provide smoothness at the cost of slight blurring,
by altering pixel colours in proportion to how well they
match the ideal area to be drawn.
JKUAT SODeL

• Scan-conversion using such methods is relatively slow.

• Motion aliasing:
©2014

The use of integers in scan-conversion methods is usually taken


to the logical extreme of eliminating any use of floating point
numbers, thus using only integer pixel coordinates as parameters
of the method.
This often results in motion aliasing, This is most noticeable
JJ II when using 2D scan conversion in 3D rendering.
J I A different kind of motion aliasing can come from irregularity
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 7
ICS 2311 Computer Graphics
in the timing of repainting of successive frames.

• Colour aliasing:
Colour aliasing is due to colour approximation in pseudo-colour
displays.
JKUAT SODeL

This creates distinct colour bands where there should be


smoothly graduated colour.
©2014

Moreover these colour bands tend to look darker near lighter


bands and vice versa, giving a misleading impression of colour.

5.1.6. Line Drawing algorithms:


The screen of a computer is a rectangular grade of pixels.
The computer produces images on raster devices only by
JJ II
turning the approximate pixels ON or OFF.
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 8
ICS 2311 Computer Graphics
To draw a line on the screen, we first need to determine which
pixels are to be switched ON.
The process of determining which combination of pixels pro-
vide the best approximation to the desired line is called rasteri-
JKUAT SODeL

zation.
When rasterization is combined with rendering of a picture
in a scan-line order, then it is known as scan-conversion.
©2014

The choice of the pixels is determined by the orientation of


the line which is to be drawn:
There is little difficulty for straight line.
For other orientation of lines, selection of pixel is a difficult
process.
JJ II There are four general requirements for line drawing:
J I 1. Lines must appear to be straight
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 9
ICS 2311 Computer Graphics
2. Lines should start and end accurately
3. Lines should have constant brightness along their length
4. Lines should be drawn rapidly.
For straight lines, the equation of a straight line is used to de-
JKUAT SODeL

termine the pixels:


• y = mx + c
©2014

Where: M = (y2–y1)/(x2 − x1)


Several algorithms:
1. The DDA algorithm
2. The bresenham’s line drawing algorithm
3. The general breesenham’s algorithm
JJ II
4. The bresenham’s circle generation algorithm.
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 10
ICS 2311 Computer Graphics
Revision Questions

Example . Outline any four line drawing algorithms. Discuss


any of the two
Solution:
JKUAT SODeL

• The DDA algorithm


©2014

• The bresenham’s line drawing algorithm


• The general breesenham’s algorithm
• The bresenham’s circle generation algorithm


Exercise 1.  Briefly state the three 2D affine forms of trans-


JJ II formation
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 11
ICS 2311 Computer Graphics
Solutions to Exercises
Exercise 1.

• Scaling: Scaling involves multiplying the object coordinates


JKUAT SODeL

by a scalar. Scalar multiplies all coordinates. Objects grow and


move! Uniform scaling orNon-uniform scaling
• Rotation: Rotates all coordinates by a specified angle.
©2014

Points are always rotated about the origin.


• Translation: Simply moves an object from one position to
another.
Exercise 1

JJ II
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation

Back Close 12

You might also like