Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
Solution

Solution

Ratings:

5.0

(1)
|Views: 554|Likes:
Published by api-3754855
Homework 1 Solution
Homework 1 Solution

More info:

Published by: api-3754855 on Oct 17, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/07/2014

pdf

text

original

C ourse:
H om ew ork #:
A ssigned on:
D ue on:
C o m p u te r
G ra p h ic s
(tv f G C ,;
)
1 (S O L U T IO N )
8 th M a y 2 0 0 6
2 5 th M a y 2 0 0 6
(Q uiz in class)
Q u e s tio n
# 1 : S o lv e th e s e
q u e s tio n s
fro m
th e
e x e rc is e
g iv e n a t th e e n d
o f c h a p te r
2 : 2 -4 , 2 -5 , 2 -
6 ,2 -8 ,2 -9 ,2 -1 0 ,2 -1 1 ,2 -1 2 ,2 -1 3 .
2 -4
F o r 1 2 b its /D ix e l
1 .
640X 480
~
X 1 2 b its/~
=3 6 8 6 4 0 0
b its= 4 6 0 8 0 0
b y te s
=O .4 6 M B .
2 .
1280X 1024
p ix e l X 1 2 b its l~
=1 5 7 2 8 6 4 0 b its =1 9 6 6 0 8 0 b y te s =1 .9 6 M B .
3 .
2560X 2048
p ix e l X 1 2 b its l~
=6 2 9 1 4 5 6 0 b its= 7 8 6 4 3 2 0 b y te s=7 .8 6 M B .
F o r 2 4 b its /D ix e l
1 .
640X 480
~X 24
b its /~ =
7 3 7 2 8 0 0
b its = 9 2 1 6 0 0
b y te s = 0 .9 2 M B .
2 .
1280X 1024
p ix e l X 2 4 b its /p ix e l=3 1 4 5 7 2 8 0 b its= 3 9 3 2 1 6 0 b y te s=3 .9 3 M B
3 .
2560X 2048
~
X 24 bitsJfH*e'= 125829120
b its= 1 5 7 2 8 6 4 0
b y te s=1 5 .7 2 M B
2 -5
8 " X 1 0 "c o n v e rte d in to p ix e ls=8X 100X 10X 100 =800 X 1000
8 O O X 1 0 O Op ix e l X 6 b its /p i} (e l=4 80 0 0 0 0
b its=60 0 0 0 0 b y te s= 0 .6 M B
2 ~
.
T ransfer of bits per second
=1 0 5 b its
For a fram e buffer sized
640X 480
w ith 1 2 b its /p ix e l
640X 480~X
1 2 b its 1 ~
=
3 6 .8 6 s e c
1 0
b its ls e c
F o r a fra m e b u ffe r s iz e d 1 2 8 0 X 1 0 2 4 w ith 2 4 b its /p ix e l
1 2 8 0 X 1 0 2 4 ~ X 2 4 b it6 1 ~
=
3 1 4 .5 7 s e c
=
5 .2 4 m in
1 0
b its ls e c
2 -8
R e s o lu tio n :
6 4 0 X 4 8 0 ,
re fre s h
ra te :60H z
P ix e ls /s e c o n d=640X 48O X 60 =1 8 4 3 2 0 0 0
T im e to a c c e s s o n e p ix e l=1 /1 8 4 3 2 0 0 0
=5 .4 X 1 0 .8 s e c
R e s o lu tio n : 1 2 8 0 X 1 0 2 4 ,re fre s h ra te : 6 0 H z
P ix e ls /s e c o n d=1280X 1024X 60 =7 8 6 4 3 2 0 0
T im e to a c c e s s o n e p ix e l=1 /7 8 6 4 3 2 0 0
=1 .2 7 X 1 o -Bs e e
2 .9
.
R a d iu s
o f a p ix e l= R & A re a o f th e
p ix e l = 1 T ~
A s th e a s p e c t
ratio is 1 , so
1280X 1024X 1T ~
=1 2 X 9 .6
R 2=2 .7 9 X 1 0 '5 "
R=5 .2 8 X 1 0 -3 .,
D iam eter= R X 2=1 0 .5 6 X 1 0 -3 ..
2 -1 0
R efresh
rate= 60 fram es/sec
& to ta l n u m b e r o f p ix e ls in o n e
s e c
=1280X 1024X 60
=7 8 6 4 3 2 0 0
Tim e to refresh
o n e
p ix e l=1 /7 8 6 4 3 2 0 0
=1.27X 10-8sec
Tim e to refresh
o n e
ro w=1 2 8 0 X 1 .2 7 X 1 0 -8
=1 .6 2 7 X 1 0 .5 s e c
2 -1 1
}
~ :~ ~
O N
PfrG r~
~
Q u e s tio n
# 2 : If th e
im a g e
has ah e ig h t o f 2 in c h e s
a n d
a s p e c t. ra tio n o f 1 .5 ,w hat is itsw id th ?
A spect ratio=w id th /h e ig h t?
1 .5= w id th l2 ?
w id th= 1 .5 X 2 = 3
1
Q u e s tio n
# 3 : If w e w a n t to r e s iz e a 1 0 2 4 X 7 6 8 im a g e to o n e th a t is 6 4 0 p ix e ls w id e w ith th e
s a m e a s p e c t r a tio , w h a t w o u ld b e th e h e ig h t o f th e r e s iz e d im a g e ?
C o n s id e r in g
1 0 2 4 [W id th (W 1 )]
a n d
7 6 8 {H e ig h t(H 1 )].
A s th e
a s p e c t
ra tio
is th e
sam e
s o :
W 11H 1=W 2IH 2
-7 1 0 2 4 /7 6 8=6 4 0 /H 2
-7 H 2 = (6 4 0 X 7 6 8 )/1 0 2 4
- 7
H2 = 480
Q u e s tio n

# 4 : S o m e tim e s th e p ix e l a t th e u p p e r le ft c o m e r o f a nim a g e is c o n s id e r e d to b e a t th e o rig in o f th e p ix e l c o o rd in a te s y s te m (a le ft-h a n d e d s y s te m ). H o w to c o n v e rt th e c o o rd in a te s o f a p ix e l a t (X , y )in

th is c o o rd in a te s y s te min to its c o o rd in a te s (x ',y ') in th e Io w e r-te ft-c o rn e r-a s -o rig in
c o o rd in a te s y s te m (a rig h t h a n d e d s y s te m )?
W h e re m is th e n u m b e ro f p ix e ls in th e y -d ire c tio n , (x ', y ')= (x , y -m -1 ).
Q u e s tio n
#
5: A
ru n -le n g th e n c o d e d
m essage
is
8 (9 )4 {1 )5 (3 ). W h a t w ill b e
th e
d e -c o d e d
m essage?
8 (9 )4 (1 )5 (3 ) =8 8 8 8 8 8 8 8 8 4 5 5 5
Q u e s tio n
# 6 : In th e c la s s ,w e c o n s tru c te d th e lin e D D A a lg o rith m in w h ic h th e tin ew a s d ra w n
fr o m le ft to r ig h t. W r ite a s im ila r lin e D D A a lg o r ith m in w h ic hlin ep r o c e s s in g a n d d r a w in g is d o n e
fro mr ig h tto le ft.
Q u e s tio n
# 7 : W e s tu d ie dth e b re s e n h a m 'stin e d ra w in g a lg o rith m fo r a
<
m
<
1 . M o d ify th e
a lg o rith m ,s o th a t th e a lg o rith m a ls o d ra w s lin e s w ith a rb itra ry s lo p e s . A ls o w rite th e p s e u d o c o d e
fo r th e w h o le
a lg o r ith m
{ ta k e a lo o k a t [H e a rn
& Baker, pg 92D .
Q u e s tio n
# 8 : In c la s s w e d is c u s s e d th e d e r iv a tio n o f a c ir c le in th e 9 0 \u00b0- 4 5 \u00b0o c ta n t. D e riv e a n d
c o rn e u p w ith th e a lg o rith m fo r a c irc le in th e 0 \u00b0 -4 5 \u00b0 o c ta n t
S h o w a ll s te p s
o f th ed e riv a tio n a n d
th e a lg o rith m .
Q u e s tio n
# 9: Consider
th e
e n d -p o in ts
o f th e fo llo w in g lin e s : (2 5 , 1 4 ) & (3 0 , 2 0 ), (1 , 6 ) & (6 , 1 ),
(2 ,1 ) & (2 ,G ), (2 0 , 1 0 ) & (2 5 , 1 5 ). D ra w
th e s e
lin e s , u s in g
th e
fo llo w in g a lg o rith m s :
y=m .x
+ b,
lin e D D A , G e n e ra liz e d
b r e s e n h a m 'slin e d ra w in g a lg o rith m d e v e lo p e d in q u e s tio n 7 .
Q u e s tio n
#
10: W hen
8-w ay sym m etryis u s e d to o b ta in a fu ll c ir c le fr o m
p ix e l c o o r d in a te s
g e n e ra te d fro m 0 \u00b0 to 4 5 \u00b0 , o r fro mg o o to 4 5 \u00b0 o c ta n t, c e rta in p ix e ls a re s e t tw ic e o r p lo tte d tw ic e .
T h i s p h e n o m e n o n i s c a n e d a s a v e r s t r i J c e .I d e n t i f yw h e re o v e rs trik e o c c u rs ? Is o v e rs trik e h a rm fu l
b e s id e s w a s tin g tim e ?
N o , o v e rs trik e
is n o t h a r m fu l b e s id e s
w a s tin g
tim e .
S e e F ig u re o n th e rig h t. O v e rs trik e o c c u rs a t th e 8 p o in ts s h o w n o n th e
fig u re a t rig h t i.e .(O ,r) a n d (r, 0 ) a n d a ll th e p o in tsp lo tte d w .r.t th e s e b y
s y m m e try .
Q u e s tio n
# 1 1 : W h e n 4 - w a y s y m m e tr y is u s e d to o b ta in a fu ll e llip s e fr o m
p ix e l c o o r d in a te s
g e n e ra te d fo r th e firs t q u a d ra n t, d o e s o v e rs trik e o c c u r? W h e re ?
J u s t lik e th e c irc le b u t a t th e 4 lo c a tio n s w ith c o o rd in a te s (O ,rx ) a n d (a , ry ) a n d th e ir s y m m e tric a l
p o s itio n s .
Q u e s tio n
# 1 2 : H o w c a n w e e lim in a te
o v e rs trik e ?
2
C an
b e e lim in a te d
b y c h e c k in g
e a c h
p ix e l b e fo re
w ritin g to it. If th e p ix e l h a s
a lre a d y
b e e n
w ritte n
to , n o p ix e l is w ritte n .
Q u e s tio n
# 1 3 : T h e c o o rd in a te s o f th e v e rtic e s o f a p o ly g o n a re s h o w n in th e fo llo w in gfig u re . (a )
W rite th e in itia l e d g e
list o f th e
p o ly g o n a n d
(b ) fill th e s h a p e
u s in g th e
s c a n -lin e p o ly g o n fill
a lg o rith m .
S c a n lin e5 : F ills th e lin e fr o mu p d a te d p o in t
(2 , 5 ) to (9 , 5 ), a g a in
u p d a te s
th e ta b le a s
fo llo w s:
S c a n lin e6 : F ills th elin e fro mu p d a te d p o in t
(2, 6) to (9, 6), again
u p d a te s
th e ta b le a s
fo llo w s:
S c a n lin e7 : F ills th e lin e fr o mu p d a te d p o in t
(2, 7) to (9, 7). A s ym in=ym ax for E 2 and
E 8 , th e y n o w
becom e
d e -a c tiv e
a n d
a re
rem oved
fro m
th e e d g e
list. The table
is n o w
u
d a te d
a s :
E d
e
m in
m ax
x
1 1 m
E 4
8
9
8
0
E 6
8
9
4
0
S c a n lin e8 : F ills th e lin e fr o m u p d a te d p o in t
(4, 8) to (8, 8), again
u p d a te s
th eta b le a s
fo llo w s :
E d
e
m in
m ax
x
1 1 m
E 4
9
9
8
0
E 6
9
9
4
0
S c a n lin e9 : F ills th e lin e fr o m u p d a te d p o in t
(4 , 9 ) to (8 , 9 ). A s y m in = y m a x fo r E 4 a n d
E 6 , th e y n o w b e c o m e d e -a c tiv e a n d a re
re m o v e d fro m th e e d g e lis t.The Edgelis t is
n o w e m p ty a n d th e a lg o rith m te rm io n a te s fo r
th is p o ly g o n .
Q u e s tio n
# 1 4 : W rite a re c u rs iv e p s e u d o c o d e p ro c e d u re to im p le m e n t th e b o u n d a ry -fill a lg o rith m
in its
b a s ic fo r m , u s in g th e 8 - c o n n e c te d d e fin itio n fo r r e g io n p ix e ls .
v o i d
b o u n d a r y F i l 1 8 ( i n t
x ,
i n t
y ,
i n t
f i l l ,
i n t
b o u n d a r y )
I n t
c u r r e n t
=
g e t P i x e l ( x ,
y ) ;
I f
( ( c u r r e n t
! =
b o ~ n d a r y )
& &
( c u r r e n t
! =
f i l l \u00bb
{
s e t C o l o r
( f i l l )
;
s e t P i x e l ( x ,
y ) ;
B o u n d a r y F i l 1 8
( x
+
1 ,
y ,
f i l l ,
b o u n d a r y ) ;
B o u n d a r y F i l 1 8
( x
-
1 ,
y ,
f i l l ,
b o u n d a r y ) ;
B o u n d a r y F i l 1 8
( x ,
y
+
1 ,
f i l l ,
b o u n d a r y ) ;
3
E d g e
ym in
ym ax
x
1 1 m
E 2
5
7
9
0
E 8
5
7
2
0
E 4
7
9
8
0
E 6
7
9
4
0
E d g e
ym in
ym ax
x
1 1 m
E 2
6
7
9
0
E 8
6
7
2
0
E 4
7
9
8
0
E 6
7
9
4
0
E d g e
ym in
ym ax
x
1 1 m
E 2
7
7
9
0
E 8
7
7
2
0
E 4
7
9
8
0
E 6
7
9
4
0
1 0
E 6
9
V
1 I5
I -
-
-
S
E 61 4
.
4
-
V f
-
V 4
. . ..
1 v 3
V 7
6
E 7
E 3
.
E 8
.
E 2
o J
- - - - - -
3
V 1
E 1
V
11
1
1
3
o J
5
6
-
S
9
1 0

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Naveen Diwakar liked this
Rohit Khare liked this
maraquero liked this
Peter Thoudam liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->