You are on page 1of 17

What is the Computer Graphics?

• Producing picture using a computer.


• Generating 2D images of 3D worlds
represented in a computer.
• Production, manipulation, and displaying
images using computer.
Tasks of Computer Graphics

Animation Rendering Modeling Imagine

Representing 2D
Simulating changes Constructing 2D Representing 3D image
of objects over time images from 3D objects
model
Computer Graphics Applications
,

03

04 02

05 01
Cathode Ray Tube(CRT) •
Video Liquid Crystal Display(LCD) •
Display
Devices Plasma Panels •
Light Emitting Diodes(LED) •

Hard .INK Jet Printer •


Copy Laser Printers •
Devices Film Recorder •
Pixel( picture element) : the smallest element
of an image.
Pixel Attributes:
- Coordinates (X,Y)
- Intensity
- Resolution: number of pixels in an image
eg 700p*800p
Types of Resolution:
Spatial Resolution: no. of pixels
Gray- level Resolution: no. of bits per pixel
Pixel consist of 8 bit

0 0 0 0 0 0 0 0 0 (black)

128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 255 (white)

N.of colours= 2𝑛.𝑜𝑓 𝑏𝑖𝑡𝑠

1) Given an image with 8bits/bixels the maximum number of intensity?

2) Given an image with 8bits/bixels the maximum intensity value of this image?
Graphics Models
Raster (Bit-map) Vectors(Random)
Images are represented by dots pixels Images are represented by sequence
of commands or mathematical
statements
Resolution dependent Resolution independent
Raster scan display (TV, monitors, Random scan display (plotters)
printer)
Software: Photoshop, paint, shop pro Software: illustrator
File structures: Bmp, Jpg, Png ,Gif File structures: pdf, SVG
More detailed image Less detailed image

• A vector file is smaller than a corresponding Bit- map Raster


• Vector images are ideal for text , logo images
Graphics Primitives
• Line Drawing
We should have two points ,starting point p1
and ending point p2 .
P1(x1,y1)
P2(x2,y2)
Slope m= Δy/ Δx= y2-y1/ x2-x1
Line equation= Y= mx+b
Line Drawing algorithms
• DDA (Digital Differential Analyzer)
• Bresenham’s
main steps for DDA
1- We determine the direction of the drawing
R L L R
2- calculate the slope (m)
L R R L
-If ꟾmꟾ≤ 1: -If ꟾmꟾ≤ 1:
Δx=1, Δy=m Δx=-1, Δy=-m
-If ꟾmꟾ <1 for -If ꟾmꟾ <1 for
positive m: positive m:
Δx=1/m, Δy=1 Δx=-1/m, Δy=-1
-If ꟾmꟾ <1 for -If ꟾmꟾ <1 for
negative m: negative m:
Δx=-1/m, Δy=-1 Δx=1/m, Δy=1
Question1: given the end points p1(0,0),p2(8,6) of
a line, find the line points that will be produced
using DDA?

Question2: given the end points p1(2,-5),p2(-2,4)


of a line, find the line points that will be produced
using DDA?
Bresenham’s Algorithm
• ꟾmꟾ>1
For given points ( (x1,y1),(x2,y2)), X=x1, Y=y1,
Δx=x2-x1, Δy=y2-y1)
P= 2Δy-Δx Δy, Δx ‫ثابتين دائما‬
While X > X2 ‫يتوقف عندما ال‬
‫يتحقق هذا الشرط‬

NO YES
IF p<0

X=x+1
Y=y+1 X=x+1
Plot(x,y) Plot(x,y)
P=p+2Δy- P=p+2Δy
2Δx
Question1: calculate the points between starting
point p1(9,18) and ending points p2(14,22) using
Bresenham’s algorithm?
1) GUI stands for -
(a) Graphics uniform interaction
(b)Graphical user interaction
(c) Graphical user interface
(d) None of the above
2) Graphics can be -
(a)Simulation
(b)Drawing
(c) Movies, photographs
(d) All of the above
3) CAD stands for -
(a)Computer art design
(b)Computer-aided design
( c) Car art design
(d)None of the above
4) A user can make any change in the image using -
(a)Interactive computer graphics
(b)Non-Interactive computer graphics
(c)Both (a) & (b)
(d)None of the above
5) What is a pixel mask?
(a)a string containing only 0's
(b)a string containing only 1's
(c)a string containing two 0's
(d)a string containing both 1's and 0's

You might also like