I n s tr u c to r ’s M a n u a l NOTICE This manual is intended for your personal use only. Copying, printing, posting, or any form of printed or electronic distribution of any part of this manual constitutes a violation of copyright law. A s a security measure, this manual was encrypted during download with the serial number of your book, and with your personal information. A ny printed or electronic copies of this file will bear that encryption, which will tie the copy to you. Please help us defeat piracy of intellectual property, one of the principal reasons for the increase in the cost of books. ------------------------------- Digital Image Processing Third Edition Instructor's Manual Version 3.0 Rafael C. Gonzalez Richard E. Woods Prentice Hall Upper Saddle River, NJ 07458 www.imageprocessingplace.com Copyright ©1992-2008 R. C. Gonzalez and R. E. Woods NOTICE This manual is intended for your personal use only. Copying, printing, posting, or any form of printed or electronic distribution of any part of this manual constitutes a violation of copyright law. A s a security measure, this manual was encrypted during download with the serial number of your book, and with your personal information. A ny printed or electronic copies of this file will bear that encryption, which will tie the copy to you. Please help us defeat piracy of intellectual property, one of the principal reasons for the increase in the cost of books. ------------------------------- Chapter 1 Introduction T h e p u r p o s e o f th is c h r ia l fr o m D ig ita l Im a g a ls o d is c u s s u s e o f th e th e w e b s ite o ffe r s , a c o m p u te r p r o je c ts th D e ta ile d s o lu tio n s to in g c h a p te r s o f th is m 1.1 a p te r is to p re s e n t s e P ro c e ssin g a t th e s b o o k w e b s ite . A lth m o n g o th e r th in g s a t c a n b e a s s ig n e d a ll p r o b le m s in th e a n u a l. u g g e s e n io r o u g h , c o m in c o b o o k te d g u id e lin e s fo r te a c h a n d fi rs t-y e a r g ra d u a te th e b o o k is to ta lly s e lf- c p le m e n ta r y r e v ie w m a n ju n c tio n w ith c la s s r o a ls o a r e in c lu d e d in th in g m a le v e ls . o n ta in te r ia l a o m w o e re m a te W e e d , n d rk . in - Teaching Features of the Book U n d e r g r a d u a te p r o g r a m s th a t o ffe r d ig ita l im a g e p r o c e s s in g ty p ic a lly lim it c o v e r a g e to o n e s e m e s te r. G r a d u a te p r o g r a m s v a r y , a n d c a n in c lu d e o n e o r tw o s e m e s te r s o f th e m a te r ia l. In th e fo llo w in g d is c u s s io n w e g iv e g e n e r a l g u id e lin e s fo r a o n e - s e m e s te r s e n io r c o u r s e , a o n e - s e m e s te r g r a d u a te c o u r s e , a n d a fu lly e a r c o u r s e o f s tu d y c o v e r in g tw o s e m e s te r s . W e a s s u m e a 1 5 - w e e k p r o g r a m p e r s e m e s te r w ith th r e e le c tu r e s p e r w e e k . In o r d e r to p r o v id e fl e x ib ility fo r e x a m s a n d r e v ie w s e s s io n s , th e g u id e lin e s d is c u s s e d in th e fo llo w in g s e c tio n s a r e b a s e d o n fo r ty , 5 0 - m in u te le c tu r e s p e r s e m e s te r. T h e b a c k g r o u n d a s s u m e d o n th e p a r t o f th e s tu d e n t is s e n io r - le v e l p r e p a r a tio n in m a th e m a tic a l a n a ly s is , m a tr ix th e o r y , p r o b a b ility , a n d c o m p u te r p r o g r a m m in g . T h e T u to r ia ls s e c tio n in th e b o o k w e b s ite c o n ta in s r e v ie w m a te r ia ls o n m a tr ix th e o r y a n d p r o b a b ility , a n d h a s a b r ie f in tr o d u c tio n to lin e a r s y s te m s . P o w e r P o in t c la s s r o o m p r e s e n ta tio n m a te r ia l o n th e r e v ie w to p ic s is a v a ila b le in th e F a c u lty s e c tio n o f th e w e b s ite . T h e s u g g e s te d te a c h in g g u id e lin e s a r e p r e s e n te d in te r m s o f g e n e r a l o b je c tiv e s , a n d n o t a s tim e s c h e d u le s . T h e r e is s o m u c h v a r ie ty in th e w a y im a g e p r o c e s s in g m a te r ia l is ta u g h t th a t it m a k e s little s e n s e to a tte m p t a b r e a k d o w n o f th e m a te r ia l b y c la s s p e r io d . In p a r tic u la r, th e o r g a n iz a tio n o f th e p r e s e n t e d itio n o f 1 C H A P T E R 1 . IN T R O D U C T IO N 2 th e b o o k is s u c h th a t it m a k e s it m u c h e a s ie r th a n b e fo r e to a d o p t s ig n ifi c a n tly d iffe r e n t te a c h in g s tr a te g ie s , d e p e n d in g o n c o u r s e o b je c tiv e s a n d s tu d e n t b a c k g r o u n d . F o r e x a m p le , it is p o s s ib le w ith th e n e w o r g a n iz a tio n to o ffe r a c o u r s e th a t e m p h a s iz e s s p a tia l te c h n iq u e s a n d c o v e r s little o r n o tr a n s fo r m m a te r ia l. T h is is n o t s o m e th in g w e re c o m m e n d , b u t it is a n o p tio n th a t o fte n is a ttr a c tiv e in p r o g r a m s th a t p la c e little e m p h a s is o n th e s ig n a l p r o c e s s in g a s p e c ts o f th e fi e ld a n d p r e fe r to fo c u s m o r e o n th e im p le m e n ta tio n o f s p a tia l te c h n iq u e s . 1.2 One Semester Senior Course A b a s ic s tr a te g y in te a c h in g a s e n io r c o u r s e is to fo c u s o n a s p e c ts o f im a g e p r o c e s s in g in w h ic h b o th th e in p u ts a n d o u tp u ts o f th o s e p r o c e s s e s a re im a g e s . In th e s c o p e o f a s e n io r c o u r s e , th is u s u a lly m e a n s th e m a te r ia l c o n ta in e d in C h a p te r s 1 th r o u g h 6 . D e p e n d in g o n in s tr u c to r p r e fe r e n c e s , w a v e le ts (C h a p te r 7 ) u s u a lly a r e b e y o n d th e s c o p e o f c o v e r a g e in a ty p ic a l s e n io r c u r r ic u lu m . H o w e v e r, w e r e c o m m e n d c o v e r in g a t le a s t s o m e m a te r ia l o n im a g e c o m p r e s s io n (C h a p te r 8 ) a s o u tlin e d b e lo w . W e h a v e fo u n d in m o re th a n th re e d e c a d e s o f te a c h in g th is m a te r ia l to s e n io r s in e le c tr ic a l e n g in e e r in g , c o m p u te r s c ie n c e , a n d o th e r te c h n ic a l d is c ip lin e s , th a t o n e o f th e k e y s to s u c c e s s is to s p e n d a t le a s t o n e le c tu r e o n m o tiv a tio n a n d th e e q u iv a le n t o f o n e le c tu r e o n r e v ie w o f b a c k g r o u n d m a te r ia l, a s th e n e e d a r is e s . T h e m o tiv a tio n a l m a te r ia l is p r o v id e d in th e n u m e r o u s a p p lic a tio n a r e a s d is 1 .2 O n e S e m e s te r S e n io r C o u r s e c u s s e d in C h a p t e r 1 . T h is c h a p t e r w a s p r e p a r e d w ith th is o b je c tiv e in m in d . S o m e o f th is m a te r ia l c a n b e c o v e r e d in c la s s in th e fi r s t p e r io d a n d th e re s t a s s ig n e d a s in d e p e n d e n t re a d in g . B a c k g r o u n d re v ie w s h o u ld c o v e r p r o b a b ility th e o r y (o f o n e r a n d o m v a r ia b le ) b e fo r e h is to g r a m p r o c e s s in g ( S e c t io n 3 .3 ) . A b r ie f r e v ie w o f v e c t o r s a n d m a tr ic e s m a y b e r e q u ir e d la te r, d e p e n d in g o n th e m a te r ia l c o v e r e d . T h e r e v ie w m a te r ia l in th e b o o k w e b s ite w a s d e s ig n e d fo r ju s t th is p u r p o s e . C h a p te r 2 s h o u ld b e c o v e r e d in its e n tir e ty . S o m e o f th e m a te r ia l (S e c tio n s 2 .1 t h r o u g h 2 .3 .3 ) c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g , b u t m o r e d e t a ile d e x p la n a tio n (c o m b in e d w ith s o m e a d d itio n a l in d e p e n d e n t r e a d in g ) o f S e c tio n s 2 .3 .4 a n d 2 .4 t h r o u g h 2 .6 is t im e w e ll s p e n t . T h e m a t e r ia l in S e c t io n 2 .6 c o v e r s c o n c e p ts th a t a re u s e d th r o u g h o u t th e b o o k a n d p r o v id e s a n u m b e r o f im a g e p r o c e s s in g a p p lic a tio n s th a t a r e u s e fu l a s m o tiv a tio n a l b a c k g r o u n d fo r th e r e s t o f th e b o o k C h a p te r 3 c o v e r s s p a tia l in te n s ity tr a n s fo r m a tio n s a n d s p a tia l c o r r e la tio n a n d c o n v o lu tio n a s th e fo u n d a tio n o f s p a tia l fi lte r in g . T h e c h a p te r a ls o c o v e r s a n u m b e r o f d iffe r e n t u s e s o f s p a tia l tr a n s fo r m a tio n s a n d s p a tia l fi lte r in g fo r im a g e e n h a n c e m e n t. T h e s e te c h n iq u e s a r e illu s tr a te d in th e c o n te x t e n h a n c e m e n t 1 .2 . O N E S E M E S T E R S E N I O R C O U R S E (a s th e n io 3 .4 o n 3 m o tiv a tio n a l a id s ), b u t it is p o in te d o u t s e v e r a l tim e s in th e c h a p te r th a t m e th o d s d e v e lo p e d h a v e a m u c h b r o a d e r r a n g e o f a p p lic a tio n . F o r a s e r c o u r s e , w e r e c o m m e n d c o v e r in g S e c t io n s 3 .1 t h r o u g h 3 .3 .1 , a n d S e c t io n s t h r o u g h 3 .6 . S e c t io n 3 .7 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g , d e p e n d in g tim e . T h e k e y o b je c tiv e s o f C h a p te r 4 a r e (1 ) to s ta r t fr o m b a s ic p r in c ip le s o f s ig n a l s a m p lin g a n d fr o m th e s e d e r iv e th e d is c r e te F o u r ie r tr a n s fo r m ; a n d (2 ) to illu s tr a te th e u s e o f fi lte r in g in th e fr e q u e n c y d o m a in . A s in C h a p te r 3 , w e u s e m o s tly e x a m p le s fr o m im a g e e n h a n c e m e n t, b u t m a k e it c le a r th a t th e F o u r ie r tr a n s fo r m h a s a m u c h b r o a d e r s c o p e o f a p p lic a tio n . T h e e a r ly p a r t o f th e c h a p te r th r o u g h S e c t io n 4 .2 .2 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g . W e r e c o m m e n d c a r e fu l c o v e r a g e o f S e c t io n s 4 .2 .3 t h r o u g h 4 .3 .4 . S e c t io n 4 .3 .5 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g . S e c tio n 4 .4 s h o u ld b e c o v e r e d in d e t a il. T h e e a r ly p a r t o f S e c tio n 4 .5 d e a ls w ith e x te n d in g to 2 - D th e m a te r ia l d e r iv e d in th e e a r lie r s e c t io n s o f th is c h a p te r. T h u s , S e c tio n s 4 .5 .1 th r o u g h 4 .5 .3 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g a n d th e n d e v o te p a r t o f th e p e r io d fo llo w in g th e a s s ig n m e n t to s u m m a r iz in g th a t m a te r ia l. W e r e c o m m e n d c la s s c o v e r a g e o f th e r e s t o f t h e s e c t io n . In S e c t io n 4 .6 , w e r e c o m m e n d t h a t S e c t io n s 4 .6 .1 - 4 .6 .6 b e c o v e r e d in c la s s . S e c t io n 4 .6 .7 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g . S e c tio n s 4 .7 .1 - 4 .7 .3 s h o u ld b e c o v e r e d a n d S e c t io n 4 .7 .4 c a n b e a s s ig n e d a s in d e p e n d e n t r e a d in g . In S e c t io n s 4 .8 t h r o u g h 4 .9 w e r e c o m m e n d c o v e r in g o n e fi lt e r ( lik e t h e id e a l lo w p a s s a n d h ig h p a s s fi lte r s ) a n d a s s ig n in g th e r e s t o f th o s e tw o s e c tio n s a s in d e p e n d e n t r e a d in g . In a s e n io r c o u r s e , w e r e c o m m e n d c o v e r in g S e c t io n 4 .9 t h r o u g h S e c t io n 4 .9 .3 o n ly . In S e c t io n 4 .1 0 , w e a ls o r e c o m m e n d c o v e r in g o n e fi lt e r a n d a s s ig n in g t h e r e s t a s in d e p e n d e n t r e a d in g . In S e c t io n 4 .1 1 , w e r e c o m m e n d c o v e r in g S e c t io n s 4 .1 1 .1 a n d 4 .1 1 .2 a n d m e n t io n in g t h e e x is t e n c e o f F F T a lg o r ith m s . T h e lo g 2 c o m p u ta tio n a l a d v a n ta g e o f th e F F T d is c u s s e d in th e e a r ly p a r t o f S e c t io n 4 .1 1 .3 s h o u ld b e m e n t io n e d , b u t in a s e n io r c o u r s e t h e r e t y p ic a lly is n o tim e to c o v e r d e v e lo p m e n t o f th e F F T in d e ta il. C h a p te r 5 c a n b e c o v e r e d a s a c o n tin u a tio n o f C h a p te r 4 . S e c tio n 5 .1 m a k e s th is a n e a s y a p p r o a c h . T h e n , it is p o s s ib le to g iv e th e s tu d e n t a “ fl a v o r ” o f w h a t r e s to r a tio n is (a n d s till k e e p th e d is c u s s io n b r ie f ) b y c o v e r in g o n ly G a u s s ia n a n d im p u ls e n o is e in S e c t io n 5 .2 .1 , a n d t w o o f t h e s p a t ia l fi lt e r s in S e c t io n 5 .3 . T h is la tte r s e c tio n is a fr e q u e n t s o u r c e o f c o n fu s io n to th e s tu d e n t w h o , b a s e d o n d is c u s s io n s e a r lie r in th e c h a p te r, is e x p e c tin g to s e e a m o r e o b je c tiv e a p p r o a c h . It is w o r th w h ile to e m p h a s iz e a t th is p o in t th a t s p a tia l e n h a n c e m e n t a n d r e s to r a tio n a r e th e s a m e th in g w h e n it c o m e s to n o is e r e d u c tio n b y s p a tia l fi lte r in g . A g o o d w a y to k e e p it b r ie f a n d c o n c lu d e c o v e r a g e o f r e s to r a tio n is to ju m p a t th is p o in t to in v e r s e fi lte r in g (w h ic h fo llo w s d ir e c tly fr o m th e m o d e l in S e c tio n 5 .1 ) a n d s h o w t h e p r o b le m s w it h t h is a p p r o a c h . T h e n , w it h a b r ie f e x p la n a t io n C H A P T E R 1 . IN T R O D U C T IO N 4 re g a rd in g th e fa c t th a t m u c h o f re s to r a tio n c e n te r s a h e r e n t in in v e r s e fi lte r in g , it is p o s s ib le to in tr o d u c e th W ie n e r fi lte r in E q . ( 5 .8 - 3 ) a n d d is c u s s E x a m p le s 5 .1 2 w e re c o m m e n d a b r ie f d is c u s s io n o n im a g e re c o n s tr u 5 .1 1 .1 - 5 .1 1 - 2 a n d m e n t io n in g t h a t t h e r e s t o f S e c t io g e n e r a te d p r o je c tio n s in w h ic h b lu r is m in im iz e d . ro u n e “ in a n d c tio n n 5 .1 d th e in s ta b te r a c tiv e ” fo 5 .1 3 . A t a m b y c o v e r in g 1 d e a ls w ith ilitie s in r m o f th e in im u m , S e c tio n s w a y s to C o v e r a g e o f C h a p te r 6 a ls o c a n b e b r ie f a t th e s e n io r le v e l b y fo c u s in g o n e n o u g h m a te r ia l to g iv e th e s tu d e n t a fo u n d a tio n o n th e p h y s ic s o f c o lo r (S e c t io n 6 .1 ) , t w o b a s ic c o lo r m o d e ls ( R G B a n d C M Y / C M Y K ) , a n d t h e n c o n c lu d in g w it h a b r ie f c o v e r a g e o f p s e u d o c o lo r p r o c e s s in g ( S e c t io n 6 .3 ) . W e t y p ic a lly c o n c lu d e a s e n io r c o u r s e b y c o v e r in g s o m e o f th e b a s ic a s p e c ts o f im a g e c o m p r e s s io n (C h a p te r 8 ). In te r e s t in th is to p ic h a s in c r e a s e d s ig n ifi c a n tly a s a r e s u lt o f th e h e a v y u s e o f im a g e s a n d g r a p h ic s o v e r th e In te r n e t, a n d s tu d e n ts u s u a lly a r e e a s ily m o tiv a te d b y th e to p ic . T h e a m o u n t o f m a te r ia l c o v e r e d d e p e n d s o n th e tim e le ft in th e s e m e s te r. 1.3 One Semester Graduate Course (No Background in DIP) T h e m n e ith e o f th e a n d fe a d d th a in d iffe re n c e b e tw e e n a s e n io r a n d a fi r s t- y e a r g r o u p h a s fo r m a l b a c k g r o u n d in im a g e p r o c e m a te r ia l c o v e r e d , in th e s e n s e th a t w e s im p ly g o e l m u c h fre e r in a s s ig n in g in d e p e n d e n t re a d in e fo llo w in g m a te r ia l to th e m a te r ia l s u g g e s te d r g ra d s s in g fa s te g . In in th e u is r a a t m in g r p re e c o u rs o s tly in a g ra d u a d u a te v io u s s e in w h ic th e s c o p a te c o u rs c o u rs e w e c tio n . h e e e S e c t io n s 3 .3 .2 - 3 .3 .4 a r e a d d e d a s is S e c t io n 3 .3 .8 o n fu z z y im a g e p r o c e s s in g . W e c o v e r C h a p te r 4 in its e n tire ty (w ith a p p r o p r ia te s e c tio n s a s s ig n e d a s in d e p e n d e n t r e a d y in g , d e p e n d in g o n th e le v e l o f th e c la s s ). T o C h a p te r 5 w e a d d S e c t io n s 5 .6 - 5 .8 a n d c o v e r S e c t io n 5 .1 1 in d e t a il. In C h a p t e r 6 w e a d d t h e H S I m o d e l ( S e c t io n 6 .3 .2 ) , S e c t io n 6 .4 , a n d S e c t io n 6 .6 . A n ic e in t r o d u c t io n t o w a v e le t s (C h a p te r 7 ) c a n b e a c h ie v e d b y a c o m b in a tio n o f c la s s r o o m d is c u s s io n s a n d in d e p e n d e n t r e a d in g . T h e m in im u m n u m b e r o f s e c tio n s in th a t c h a p te r a r e 7 .1 , 7 .2 , 7 .3 , a n d 7 .5 , w it h a p p r o p r ia t e ( b u t b r ie f ) m e n t io n o f t h e e x is t e n c e o f fa s t w a v e le t t r a n s fo r m s . S e c t io n s 8 .1 a n d 8 .2 t h r o u g h S e c t io n 8 .2 .8 p r o v id e a n ic e in tr o d u c tio n to im a g e c o m p re s s io n . im fro p u d e If a g m ts fi n a d d itio n a l tim e is a e p r o c e s s in g (C h a p m e th o d s w h o s e in p a re im a g e s , b u t th e e d in S e c t io n 1 .1 . W v a ila b te r 9 ). u ts a n o u tp u e re c o le , a n a tu r a T h e m a te r d o u tp u ts a ts a re a ttr ib m m e n d c o v l to p ic to ia l in th is re im a g e s u te s a b o u e ra g e o f S c o v e r n e x t is m o r p h o lo g ic a l c h a p te r b e g in s a tr a n s itio n to m e th o d s in w h ic h th e in t th o s e im a g e s , in th e s e n s e e c t io n s 9 .1 t h r o u g h 9 .4 , a n d 1 .4 . O N E S E M E S T E R G R A D U A T E C O U R S E ( W I T H S T U D E N T H A V I N G B A C K G R O U N D I N D I P ) 5 s o m e o f t h e a lg o r it h m s in S e c t io n 9 .5 . 1.4 One Semester Graduate Course (with Student Having Background in DIP) S o m e p r o g r a m s h a v e a n u n d e r g r a d u a te c o u r s e in im a g e p r o c e s s in g a s a p re re q u is ite to a g r a d u a te c o u r s e o n th e s u b je c t, in w h ic h c a s e th e c o u r s e c a n b e b ia s e d to w a r d th e la tte r c h a p te r s . In th is c a s e , a g o o d d e a l o f C h a p te r s 2 a n d 3 is r e v ie w , w it h t h e e x c e p t io n o f S e c t io n 3 .8 , w h ic h d e a ls w it h fu z z y im a g e p r o c e s s in g . D e p e n d in g o n w h a t is c o v e re d in th e u n d e r g r a d u a te c o u r s e , m a n y o f th e s e c tio n s in C h a p te r 4 w ill b e r e v ie w a s w e ll. F o r C h a p te r 5 w e r e c o m m e n d th e s a m e le v e l o f c o v e r a g e a s o u tlin e d in th e p r e v io u s s e c tio n . In C h a p te r 6 w e a d d fu ll- c o lo r im a g e p r o c e s s in g ( S e c t io n s 6 .4 t h r o u g h 6 .7 ) . C h a p te r s 7 a n d 8 a r e c o v e r e d a s o u tlin e d in th e p r e v io u s s e c tio n . A s n o te d in th e p re v io u s s e c tio n , C h a p te r 9 b e g in s a tr a n s itio n fr o m m e th o d s w h o s e in p u ts a n d o u tp u ts a re im a g e s to m e th o d s in w h ic h th e in p u ts a re im a g e s , b u t th e o u tp u ts a re a ttr ib u te s a b o u t th o s e im a g e s . A s a m in im u m , w e re c o m m e n d c o v e r a g e o f b in a r y m o r p h o lo g y : S e c t io n s 9 .1 t h r o u g h 9 .4 , a n d s o m e o f th e a lg o r it h m s in S e c t io n 9 .5 . M e n t io n s h o u ld b e m a d e a b o u t p o s s ib le e x t e n s io n s t o g r a y - s c a le im a g e s , b u t c o v e r a g e o f th is m a te r ia l m a y n o t b e p o s s ib le , d e p e n d in g o n th e s c h e d u le . In C h a p t e r 1 0 , w e r e c o m m e n d S e c t io n s 1 0 .1 t h r o u g h 1 0 .4 . In C h a p t e r 1 1 w e t y p ic a lly c o v e r S e c t io n s 1 1 .1 t h r o u g h 1 1 .4 . 1.5 Two Semester Graduate Course (No Background in DIP) In a tw o - s e m e s te r c o u r s e it is p o s s ib le to c o v e r m a te r ia l in a ll tw e lv e c h a p te r s o f th e b o o k . T h e k e y in o r g a n iz in g th e s y lla b u s is th e b a c k g r o u n d th e s tu d e n ts b r in g to th e c la s s . F o r e x a m p le , in a n e le c tr ic a l a n d c o m p u te r e n g in e e r in g c u r r ic u lu m g r a d u a te s tu d e n ts h a v e s tr o n g b a c k g r o u n d in fr e q u e n c y d o m a in p r o c e s s in g , s o C h a p te r 4 c a n b e c o v e r e d m u c h q u ic k e r th a n w o u ld b e th e c a s e in w h ic h th e s tu d e n ts a re fr o m , s a y , a c o m p u te r s c ie n c e p r o g r a m . T h e im p o r ta n t a s p e c t o f a fu ll y e a r c o u r s e is e x p o s u r e to th e m a te r ia l in a ll c h a p te r s , e v e n w h e n s o m e to p ic s in e a c h c h a p te r a re n o t c o v e re d . 1.6 Projects O n e o f th e m o s t in te re s tin g a s p e c ts o f a c o u r s e in d ig ita l im a g e p r o c e s s in g is th e p ic to r ia l n a tu r e o f th e s u b je c t. It h a s b e e n o u r e x p e r ie n c e th a t s tu d e n ts tr u ly e n jo y a n d b e n e fi t fr o m ju d ic io u s u s e o f c o m p u te r p r o je c ts to c o m p le m e n t th e C H A P T E R 1 . IN T R O D U C T IO N 6 m a te w o rk b r ie f th e w r ia a n a s a y l c o v e r d h o m p o s s ib p r o je c e d in e w o rk le . In t re p o c la a s o r r ts s s . B e c a u s ig n m e n t d e r to fa c a re p re p a s e c s , w ilita re d o m p e tr y te g r . A u u te r p r o je to k e e p th a d in g , w e s e fu l re p o c ts e fo tr y r t fo a re r m to r m in a l a c a t a d d itio n to p r o je c t r e p o h ie v e u n ifo r is a s fo llo w s c o u rs e r tin g a s m ity in : P a g e 1 : C o v e r p a g e . • P r o je c t title • P r o je c t n u m b e r • C o u rs e n u m b e r • S t u d e n t ’s n a m e • D a te d u e • D a te h a n d e d in • A b s tra c t (n o t to e x c e e d 1 / 2 p a g e ) P a g e 2 : O n e to tw o p a g e s (m a x ) o f te c h n ic a l d is c u s s io n . P a g e 3 (o r 4 ): D is c u s s io n o f r e s u lts . O n e to tw o p a g e s (m a x ). R e s u lts : Im a g e r e s u lts (p r in te d ty p ic a lly o n a la s e r o r in k je t p r in te r ). A ll im a g e s m u s t c o n ta in a n u m b e r a n d title r e fe r r e d to in th e d is c u s s io n o f r e s u lts . A p p e n d ix : P r o g r a m lis tin g s , fo c u s e d o n a n y o r ig in a l c o d e p r e p a r e d b y th e s tu d e n t. F o r b re v ity , fu n c tio n s a n d r o u tin e s p r o v id e d to th e s tu d e n t a re re fe r re d to b y n a m e , b u t th e c o d e is n o t in c lu d e d . L a y o u t: T h U .S . o r A 4 fo r m a b o o S e m e s te r S lis t im a w ill w e b P r o je o f s u g e s , fi n d s ite . c t g g a n a d e e n tire in E u r o k le t, o r e n io r C re p e b o o u re s o u rc e s e s te d p ro d M A T L A d itio n a l s p o r t m u s t b e o n a s ta n d a r d s h e e t s iz e ( e .g ., le t te r s iz e in t h e ), s ta p le d w ith th r e e o r m o r e s ta p le s o n th e le ft m a r g in to u n d u s in g c le a r p la s t ic s t a n d a r d b in d in g p r o d u c t s .1 .2 O n e rs e a v a ila b le je c ts fr o m B fu n c tio n o ftw a re s u in w s . g g th e b o o h ic h th e In s tr u c e s tio n s k w e in s t to rs in th b r u w e s ite c to h o S u p in r c d o p o c lu a n n o r t/ d e a s a m p s e le c t, b o o t w is h to u S o ftw a re s e le p r o je k a n d o s e M A T c tio n o c t, a th e r L A B f th e 1 .7 . T H E B O O K W E B S I T E 7 1.7 The Book Web Site T h e c o m p a n io n w e b s ite w w w .p r e n h a ll.c o m / g o n z a le z w o o d s (o r its m ir r o r s ite ) w w w .im a g e p r o c e s s in g p la c e .c o m is a v a lu a b le te a c h in g a id , in th e s e n s e th a t it in c lu d e s m a te r ia l th a t p r e v io u s ly w a s c o v e r e d in c la s s . In p a r tic u la r, th e r e v ie w m a te r ia l o n p r o b a b ility , m a tr ic e s , v e c to r s , a n d lin e a r s y s te m s , w a s p r e p a r e d u s in g th e s a m e n o ta tio n a s in th e b o o k , a n d is fo c u s e d o n a r e a s th a t a r e d ir e c tly r e le v a n t to d is c u s s io n s in th e te x t. T h is a llo w s th e in s tr u c to r to a s s ig n th e m a te r ia l a s in d e p e n d e n t r e a d in g , a n d s p e n d n o m o r e th a n o n e to ta l le c tu r e p e r io d r e v ie w in g th o s e s u b je c ts . A n o th e r m a jo r fe a tu r e is th e s e t o f s o lu tio n s to p r o b le m s m a r k e d w ith a s ta r in th e b o o k . T h e s e s o lu tio n s a r e q u ite d e ta ile d , a n d w e r e p r e p a r e d w ith th e id e a o f u s in g th e m a s te a c h in g s u p p o r t. T h e o n - lin e a v a ila b ility o f p r o je c ts a n d d ig ita l im a g e s fre e s th e in s tr u c to r fr o m h a v in g to p re p a re e x p e r im e n ts , d a ta , a n d h a n d o u ts fo r s tu d e n ts . T h e fa c t th a t m o s t o f th e im a g e s in th e b o o k a r e a v a ila b le fo r d o w n lo a d in g fu r th e r e n h a n c e s th e v a lu e o f th e w e b s ite a s a te a c h in g r e s o u r c e . NOTICE This manual is intended for your personal use only. Copying, printing, posting, or any form of printed or electronic distribution of any part of this manual constitutes a violation of copyright law. A s a security measure, this manual was encrypted during download with the serial number of your book, and with your personal information. A ny printed or electronic copies of this file will bear that encryption, which will tie the copy to you. Please help us defeat piracy of intellectual property, one of the principal reasons for the increase in the cost of books. ------------------------------- Chapter 2 Problem Solutions Problem 2.1 T h e d ia m e te r, x , o f th e re tin a l im a g e c o r re s p o n d in g to th e d o t is o b ta in e d fr o m s im ila r t r ia n g le s , a s s h o w n in F ig . P 2 .1 . T h a t is , (d / 2 ) = 0 .2 (x / 2 ) 0 .0 1 7 w h ic h g iv e s x = 0 .0 8 5 d . F r o m t h e d is c u s s io n in S e c t io n 2 .1 .1 , a n d t a k in g s o m e lib e r tie s o f in te r p r e ta tio n , w e c a n th in k o f th e fo v e a a s a s q u a r e s e n s o r a r r a y h a v in g o n t h e o r d e r o f 3 3 7 ,0 0 0 e le m e n t s , w h ic h t r a n s la t e s in t o a n a r r a y o f s iz e 5 8 0 × 5 8 0 e le m e n ts . A s s u m in g e q u a l s p a c in g b e tw e e n e le m e n ts , th is g iv e s 5 8 0 e le m e n ts a n d 5 7 9 s p a c e s o n a lin e 1 .5 m m lo n g . T h e s iz e o f e a c h e le m e n t a n d e a c h s p a c e is t h e n s = [(1 .5 m m )/ 1 , 1 5 9 ] = 1 .3 × 1 0 − 6 m . If t h e s iz e ( o n t h e fo v e a ) o f th e im a g e d d o t is le s s th a n th e s iz e o f a s in g le r e s o lu tio n e le m e n t, w e a s s u m e th a t th e d o t w ill b e in v is ib le to th e e y e . In o th e r w o r d s , th e e y e w ill n o t d e te c t a d o t if it s d ia m e t e r, d , is s u c h t h a t 0 .0 8 5 (d ) < 1 .3 × 1 0 − 6 m , o r d < 1 5 .3 × 1 0 − 6 m . Ed g e v iew o f d o t Imag e o f th e d o t o n th e fo v ea d /2 d 0 .2 m 0 .0 1 7 m F ig u r e P 2 .1 9 x x/2 C H A P T E R 2 . P R O B L E M S O L U T IO N S 1 0 Problem 2.2 B r ig h tn e s s a d a p ta tio n . Problem 2.3 T h e s o lu tio n is λ c / v = 2 .9 9 8 × 1 0 8 (m / s )/ 6 0 (1 / s ) = = 4 .9 9 7 × 1 0 6 m = 4 9 9 7 K m . Problem 2.4 (a ) F ro m th e s o u rc e o f th e s a m e s iz e o r s s h a p e a n d n o m in a tio n s o u b e a b le to d e t im a g e th e s p e d is c u s s io n o n th e e le c tr o m a g n e tic s p e c tr u m in S e illu m in a tio n r e q u ir e d to s e e a n o b je c t m u s t h a v e w m a lle r th a n th e o b je c t. B e c a u s e in te r e s t lie s o n ly o n t o n o th e r s p e c tr a l c h a r a c te r is tic s o f th e s p e c im e n s r c e in th e fa r u ltr a v io le t (w a v e le n g th o f .0 0 1 m ic r o n e c t a ll o b je c ts . A fa r - u ltr a v io le t c a m e r a s e n s o r w o u ld c im e n s . c t io n 2 .2 , t h e a v e le n g th th e th e b o u n d a r y , a s in g le illu s o r le s s ) w ill b e n e e d e d to (b ) N o a n s w e r is re q u ire d b e c a u s e th e a n s w e r to (a ) is a ffi r m a tiv e . Problem 2.5 F ro m t S o th e lin e , s o d iv id e h e ta r th b y g e o m e tr y g e t s iz e is e r e s o lu tio 2 , g iv in g a o f F ig . 1 0 0 m n o f 1 n a n s w 2 .3 , (7 m o n lin e is e r o f 5 m m )/ (3 5 m m ) = (z )/ (5 0 0 m m ), o r z = 1 0 0 m m . th e s id e . W e h a v e a to ta l o f 1 0 2 4 e le m e n ts p e r 1 0 2 4 / 1 0 0 = 1 0 e le m e n ts / m m . F o r lin e p a ir s w e lp / m m . Problem 2.6 O n e p o s s ib le s o lu tio n is to e q u ip a m o n o c h r o m e c a m e r a w ith a m e c h a n ic a l d e v ic e th a t s e q u e n tia lly p la c e s a r e d , a g r e e n a n d a b lu e p a s s fi lte r in fr o n t o f th e le n s . T h e s tr o n g e s t c a m e r a r e s p o n s e d e te r m in e s th e c o lo r. If a ll th r e e r e s p o n s e s a r e a p p r o x im a te ly e q u a l, th e o b je c t is w h ite . A fa s te r s y s te m w o u ld u tiliz e th r e e d iffe r e n t c a m e r a s , e a c h e q u ip p e d w ith a n in d iv id u a l fi lte r. T h e a n a ly s is th e n w o u ld b e b a s e d o n p o llin g th e r e s p o n s e o f e a c h c a m e r a . T h is s y s te m w o u ld b e a little m o r e e x p e n s iv e , b u t it w o u ld b e fa s te r a n d m o r e r e lia b le . N o te th a t b o th s o lu tio n s a s s u m e th a t th e fi e ld o f v ie w o f th e c a m e r a (s ) is s u c h th a t it is c o m - 1 1 In ten sity 2 5 5 0 ( x 0, y 0) (a) In ten sity DG 2 5 5 Eq u ally sp aced su b d iv isio n s 0 (b ) F ig u r e P 2 .7 p le te ly th e v e h q u ire d s o lv in g fi lle d ic le w to is o th is p b y a u n h e re o n la te th e r o b le m ifo r m c o lo r [i.e ., t h e c a m e r a ( s ) is ( a r e ) fo c u s e d o n a p a r t o f ly its c o lo r is s e e n . O th e r w is e fu r th e r a n a ly s is w o u ld b e r e r e g io n o f u n ifo r m c o lo r, w h ic h is a ll th a t is o f in te r e s t in ]. Problem 2.7 T h e im a g e in q u e s tio n is g iv e n b y f (x ,y ) = i (x ,y )r (x ,y ) = 2 5 5 e = 2 5 5 e A c ro tiz e d 4 G = b e d e w o rd )2 + (y − y 0 )2 ] − [(x − x − [(x − x 0 0 2 2 ) + (y − y 0 ) ] s s s e c tio n o f th e im a g e is s h o w n in F ig . u s in g m b its , th e n w e h a v e th e s itu a tio (2 5 5 + 1 )/ 2 m . S in c e a n a b r u p t c h a n g e o te c ta b le b y th e e y e , it fo llo w s th a t 4 G = s , 3 2 , o r fe w e r, in te n s ity le v e ls w ill p r o d u c P 2 n f 8 8 × 1 .0 .7 (a ). If t s h o w n in in te n s ity = 2 5 6 / 2 m e v is ib le fa ls h e in te n s ity is q u a F ig . P 2 .7 ( b ) , w h e le v e ls is a s s u m e d , o r m = 5 . In o th e c o n to u r in g . n re to e r C H A P T E R 2 . P R O B L E M S O L U T IO N S 1 2 In ten sity 2 5 5 1 9 1 1 2 7 6 3 0 2 5 5 1 9 1 1 2 7 6 3 Imag e q u an tized in to fo u r lev els F ig u r e P 2 .8 Problem 2.8 T h e u in th e 0 a n d o n . T c o u rs s e o f tw ra n g e 0 6 3 b e c h e im a g e , th e re o b its (m to 2 5 5 . O o d e d a s 6 e r e s u ltin a re o th e r = 2 ) o f in te n s ity re s o n e w a y to s u b d iv id e 3 , a ll le v e ls b e tw e e n g fr o m th is ty p e o f s w a y s to s u b d iv id e th lu tio n p r th is r a n g 6 4 a n d 1 u b d iv is io e ra n g e [ o d u c e s fo e is to le t 2 7 b e c o d n is s h o w 0 ,2 5 5 ] in t u r in a ll le e d a n in o fo u te n s ity le v e ls b e tw s 1 2 7 , a n F ig . P 2 .8 r b a n d s . v e ls e e n d s o . O f Problem 2.9 ( a ) T h e to ta l a m o u n t o f d a ta (in c lu d in g th e s ta r t a n d s to p b it) in a n 8 - b it, 1 0 2 4 × 1 0 2 4 im a g e , is (1 0 2 4 )2 × [8 + 2 ] b its . T h e to ta l tim e re q u ire d to tr a n s m it th is im a g e o v e r a 5 6 K b a u d lin k is (1 0 2 4 )2 × [8 + 2 ]/ 5 6 0 0 0 = 1 8 7 .2 5 s e c o r a b o u t 3 .1 m in . ( b ) A t 3 0 0 0 K t h is t im e g o e s d o w n t o a b o u t 3 .5 s e c . Problem 2.10 T h e w id th - to 1 1 2 5 lin e s (o r, g iv e n th a t th e th e r e s o lu tio n T h e s y s te m “ p h e ig h t r a t w h a t is th r e s o lu tio n in th e h o r a in ts ” a fu io is e s a in t iz o n ll 1 1 1 6 / 9 a n m e th in h e h o r iz ta l d ire c 2 5 × 2 0 0 d th g , 1 1 o n ta tio n 0 , 8 - e r e s o lu tio n in 2 5 p ix e ls in th e l d ire c tio n is in is (1 1 2 5 ) × (1 6 / 9 b it im a g e e v e r y th e v e r th e ) = 1 / 3 v e tic 1 6 2 0 0 s r tic a l a l d ire / 9 p ro 0 0 p ix e c fo r d ire c tio n is c tio n ). It is p o r tio n , s o e ls p e r lin e . e a c h o f th e 1 3 F ig u r e P 2 .1 1 re d , g to ta l 1 .1 6 6 s h o w re e n , a n d b d ig ita l d a ta × 1 0 1 3 b its w h y im a g e lu e g e n , o r d a t c o m p o e ra te d 1 .4 5 8 × a c o m p n e n t im a g in th is tim 1 0 12 b y te re s s io n (C e s . T h e re a r e in te r v a l is s ( i.e ., a b o u h a p te r 8 ) is e 7 (1 t 1 s o 2 0 0 1 2 5 ) .5 t e im p s e c in tw o h o u r s , s o th e (2 0 0 0 )(8 )(3 0 )(3 )(7 2 0 0 ) = ra b y te s ). T h e s e fi g u re s o r ta n t. Problem 2.11 L e b e th th t p a c a u s e s e t e s e t n d e q N 8 N 4 q b e is n (p ); (p ) \ a s s h o o t in th (c ) S 1 a N 4 (q ) w n in F ig . P 2 .1 1 . T h e n , ( a ) S 1 a n d S 2 a r e n o t 4 - c o n n e c t e d e s e t N 4 (p ); (b ) S 1 a n d S 2 a re 8 - c o n n e c te d b e c a u s e q is in n d S 2 a re m - c o n n e c te d b e c a u s e (i) q is in N D (p ), a n d (ii) is e m p ty . Problem 2.12 T h e s o lu tio n o f th is to g o fr o m a d ia g o n P 2 .1 2 illu s t r a t e s . T h e r y tim e a d ia g o n a l p ro a l s e a s e g b le m c e g m e n lg o r ith m e n ts o n s is ts t to a c o m th e n is e n c o o f d e fi n in g a ll p o s s r re s p o n d in g 4 - c o n s im p ly lo o k s fo r th u n te re d in th e b o u ib le n e c e a p n d a n e ig h b o r h o o d s h a p e s te d s e g m e n ts a s F ig . p r o p r ia te m a tc h e v r y . Problem 2.13 T h e s o lu t io n t o t h is p r o b le m is th e s a m e a s fo r P r o b le m 2 .1 2 b e c a u s e c o n v e r t in g fr o m a n m - c o n n e c te d p a th to a 4 - c o n n e c te d p a th s im p ly in v o lv e s d e te c tin g d ia g o n a l s e g m e n ts a n d c o n v e r tin g th e m to th e a p p r o p r ia te 4 - c o n n e c te d s e g m e n t. Problem 2.14 T h e d iffe r e n c e b e tw e e n th e p ix e ls in th e b a c k g r o u n d th a t a r e h o le s a n d p ix e ls th a t a r e n o t h o le s is th a n n o p a th s e x is t b e tw e e n h o le p ix e ls a n d th e b o u n d a r y o f th e im a g e . S o , th e d e fi n itio n c o u ld b e r e s ta te d a s fo llo w s : T h e s u b s e t o f p ix e ls C H A P T E R 2 . P R O B L E M S O L U T IO N S 1 4 Þ or Þ or Þ or Þ or F ig u r e P 2 .1 2 o f (R U )c th a t a r e c o n n e c te d to th e b o r d e r o f th e im a g e is c a lle d th e b a c k g r o u n d . A ll o th e r p ix e ls o f (R U )c a r e c a lle d h o le p ix e ls . Problem 2.15 (a ) s ib a ls to le n a re W h e n le to g o h a v e g e t to g th o f u n iq u (b its b e s h d a ) O le tw o w s h V = f 0 ,1 g e t fro m p v a lu e s fr o q . T h e s h th e s h o r te e in th is c n e p o s s ib n g th is 6 . e e n p a n n in F ig . e d ) is 6 . T , 4 to m o r s t a s -p q V te m e . a th b y . F s t 8 - p d o e s tra v e ig u re -p a th a th (s n o t lin g P 2 .1 is s h o w ility fo r th e s h o r te s t It is e a s ily v e r ifi e d d q . O n e p o s s ib ilit P 2 .1 5 ( d ) ; it s le n g t h h is p a th is n o t u n iq e x is t b a lo n g 5 (a ) s h h o w n n d a s h 4 -p a th a t y fo r is 4 . u e . e tw e e n p a n d q b e c a u s e p o in ts th a t a re b o th 4 - a o w s th is c o n d itio n ; it is in F ig . P 2 .1 5 ( b ) ; it s le n g e d ) is 5 . B o th o f th e s e s h th w h e a n o th e th e s h T h e le n V = r 4 -p o r te s n g th f 1 a th t 8 o f ,2 g is o f th -p a th a s h o s h o w n e s a m e (it is n r te s t m it is im p o s d ja c e n t a n d n o t p o s s ib le th is 4 . T h e o r te s t p a th s in F ig . P le n g th o t u n iq -p a th (s 2 .1 5 e x is u e ) h o w (c ); ts is n 1 5 F ig u r e P.2 .1 5 Problem 2.16 (a ) A s h o r te s t 4 - p a th b e tw e e n a p o in t p w ith c o o rd in a te s (x ,y ) a n d a p o in t q w it h c o o r d in a t e s (s , t ) is s h o w n in F ig . P 2 .1 6 , w h e r e t h e a s s u m p t io n is t h a t a ll p o in ts a lo n g th e p a th a r e fr o m V . T h e le n g th o f th e s e g m e n ts o f th e p a th a r e jx − s j a n d y − t , r e s p e c t iv e ly . T h e t o t a l p a t h le n g t h is jx − s j + y − t , w h ic h w e r e c o g n iz e a s t h e d e fi n it io n o f t h e D 4 d is t a n c e , a s g iv e n in E q . ( 2 .5 - 2 ) . ( R e c a ll t h a t t h is d is t a n c e is in d e p e n d e n t o f a n y p a t h s t h a t m a y e x is t b e t w e e n th e p o in t s .) T h e D 4 d is ta n c e o b v io u s ly is e q u a l to th e le n g th o f th e s h o r te s t 4 - p a th w h e n th e le n g t h o f t h e p a t h is jx − s j + y − t . T h is o c c u r s w h e n e v e r w e c a n g e t f r o m p to q b y fo llo w in g a p a th w h o s e e le m e n ts (1 ) a r e fr o m V , a n d (2 ) a r e a r r a n g e d in s u c h a w a y th a t w e c a n tr a v e r s e th e p a th fr o m p to q b y m a k in g tu r n s in a t m o s t t w o d ir e c t io n s ( e .g ., r ig h t a n d u p ) . ( b ) T h e p a th m a y o r m a y n o t b e u n iq u e , d e p e n d in g o n V a n d th e v a lu e s o f th e p o in ts a lo n g th e w a y . Problem 2.17 (a ) T h e D 8 d is t a n c e b e t w e e n p a n d q [s e e E q . ( 2 .5 - 3 ) a n d F ig . P 2 .1 6 ] is D R e c a m e n D 4 d in th th e p ll ts is e a th a t th th e s a ta n c e , p re v io th le n g e D 8 d m e a s is in d e u s p ro th is m 8 p ,q is ta n c e (u n h o r iz o n ta l p e n d e n t o f b le m , th e s a x jx − s j , = m a x lik e th e E u a n d v e r tic w h e th e r o h o r te s t 8 y − t . T jx − s j , y − t . c lid e a n d is ta n c e ) c o u n a l s e g m e n ts , a n d , a s in r n o t a p a th e x is ts b e tw p a th is e q u a l to th e D 8 h is o c c u r s w h e n w e c a n ts d ia g o n a l s e g th e c a s e o f th e e e n p a n d q . A s d is ta n c e w h e n g e t fro m p to q C H A P T E R 2 . P R O B L E M S O L U T IO N S 1 6 F ig u r e P 2 .1 6 b y fo llo a w a y t o n e d ir th e h o r w in g a h a t w e e c tio n iz o n ta p a th w h o s e e le c a n tra v e rs e th a n d , w h e n e v e r l o r v e r tic a l (b u t m e e p d ia n o n ts a th g o n t b o (1 ) a re f fro m p a l tra v e th ) d ire ro m to q l is n c tio n V , a n d (2 ) a re a r r a n g e d in s u c h b y tr a v e lin g d ia g o n a lly in o n ly o t p o s s ib le , b y m a k in g tu r n s in . ( b ) T h e p a th m a y o r m a y n o t b e u n iq u e , d e p e n d in g o n V a n d th e v a lu e s o f th e p o in ts a lo n g th e w a y . Problem 2.18 W it h r e fe r e n c e t o E q . ( 2 .6 - 1 ) , le t H d e n o t e t h e s u m o p e r a t o r, le t S 1 a n d S 2 d e n o te tw o d iffe r e n t s m a ll s u b im a g e a r e a s o f th e s a m e s iz e , a n d le t S 1 + S 2 d e n o te th e c o r r e s p o n d in g p ix e l- b y - p ix e l s u m o f th e e le m e n ts in S 1 a n d S 2 , a s e x p la in e d in S e c t io n 2 .6 .1 . N o t e t h a t t h e s iz e o f t h e n e ig h b o r h o o d ( i.e ., n u m b e r o f p ix e ls ) is n o t c h a n g e d b y th is p ix e l- b y - p ix e l s u m . T h e o p e r a to r H c o m p u te s th e s u m o f p ix e l v a lu e s in a g iv e n n e ig h b o r h o o d . T h e n , H (a S 1 + b S 2 ) m e a n s : (1 ) m u ltip ly th e p ix e ls in e a c h o f th e s u b im a g e a r e a s b y th e c o n s ta n ts s h o w n , (2 ) a d d th e p ix e l- b y - p ix e l v a lu e s fr o m a S 1 a n d b S 2 (w h ic h p r o d u c e s a s in g le s u b im a g e a r e a ), a n d (3 ) c o m p u te th e s u m o f th e v a lu e s o f a ll th e p ix e ls in th a t s in g le s u b im a g e a r e a . L e t a p 1 a n d b p 2 d e n o te tw o a r b itr a r y (b u t c o r r e s p o n d in g ) p ix e ls fr o m a S 1 + b S 2 . T h e n w e c a n w r ite H (a S 1 + b S 2 ) = a p p 1 2 S 1 p 1 2 S 1 a n d p = a p 2 S = a H (S 1 1 1 + b p 1 2 + 1 p 1 2 S b p p = a p 2 2 2 S 2 2 + b p p ) + b H (S 2 S 2 2 ) 2 2 2 1 7 w h ic h , a c c o r d in g t o E q . ( 2 .6 - 1 ) , in d ic a t e s t h a t H is a lin e a r o p e r a t o r. Problem 2.19 T h e m e d ia n , ζ , o f a s e t b e lo w ζ a n d th e o th e r h t h a t E q . ( 2 .6 - 1 ) is v io la f 4 ,5 ,6 g , a n d a = b = 1 . H (S 1 + S 2 ) = m e d ia n f 5 , 3 s u m o f S 1 a n d S 2 . N e x t, m e d ia n f 4 ,5 ,6 g = 5 . T h e t h a t E q . ( 2 .6 - 1 ) is v io la t e o f a lf te d In ,9 g w e n , d a n u m b e r s is s u c h th a t h a lf th e v a lu e s in a r e a b o v e it. A s im p le e x a m p le w ill s u ffi b y th e m e d ia n o p e r a to r. L e t S 1 = f 1 ,− th is c a s e H is th e m e d ia n o p e r a to r. W e = 5 , w h e re it is u n d e r s to o d th a t S 1 + S 2 c o m p u te H (S 1 ) = m e d ia n f 1 , − 2 , 3 g = 1 a b e c a u s e H ( a S 1 + b S 2 ) 6= a H ( S 1 ) + b H ( S 2 n d th e m e d ia n is a n o n lin e a r o p e r a to r. th e s e t a re c e to s h o w 2 ,3 g , S 2 = th e n h a v e is th e a r r a y n d H (S 2 ) = ), it fo llo w s Problem 2.20 F r o m E q . ( 2 .6 - 5 ) , a t a n y p o in t (x , y ), g = K 1 i th e f i a r o m e a n , o f E q . (2 ro v e th e e th e s o E .6 - 6 ) v a lid . i = 1 K i = 1 E f η ig . s a m e im a g e , s o E f f i g = f . A ls o , it is g iv e n th a t th e n o is e f η i g = 0 . T h u s , it fo llo w s th a t E f g g = f , w h ic h p r o v e s th e it y o f E q . ( 2 .6 - 7 ) c o n s id e r t h e p r e c e d in g e q u a t io n a g a in : g = It is k n o w n fr o m r e la te d r a n d o m v [1 9 9 1 ]). B e c a u s e u n c o r r e la te d , th e K i = 1 K 1 E f f ig + η i. K i = 1 K 1 E f g g = K 1 f i + K i = 1 T h e n B u t a ll h a s z e r v a lid ity T o p = g K K 1 K 1 g K = i K 1 f i + K i = 1 i = 1 1 K K η i. i = 1 r a n d o m - v a r ia b le th e o r y th a t th e v a r ia n c e o f th e s u m o f u n c o r a r ia b le s is th e s u m o f th e v a r ia n c e s o f th o s e v a r ia b le s (P a p o u lis it is g iv e n th a t th e e le m e n ts o f f a r e c o n s ta n t a n d th e η i a r e n σ 2 g = σ 2 f + 1 K 2 [σ 2 η 1 + σ 2 η 2 + ··· + σ 2 η K ]. T h e fi r s t te r m o n th e r ig h t s id e is 0 b e c a u s e th e e le m e n ts o f f a r e c o n s ta n ts . T h e v a r i o u s σ η2 i a r e s i m p l y s a m p l e s o f t h e n o i s e , w h i c h i s h a s v a r i a n c e σ η2 . T h u s , C H A P T E R 2 . P R O B L E M S O L U T IO N S 1 8 σ 2 η i = σ 2 η a n d w e h a v e σ 2 g = K K 2 σ 2 η = 1 σ K 2 η w h ic h p r o v e s t h e v a lid it y o f E q . ( 2 .6 - 7 ) . Problem 2.21 ( a ) P ix e ls a r e in te g e r v a lu e s , a n d 8 b its a llo w r e p r e s e n ta tio n o f 2 5 6 c o n tig u o u s in te g e r v a lu e s . In o u r w o r k , th e r a n g e o f in te n s ity v a lu e s fo r 8 - b it im a g e s is [0 , 2 5 5 ]. T h e s u b tr a c tio n o f v a lu e s in th is r a n g e c o v e r th e r a n g e [− 2 5 5 , 2 5 5 ]. T h is r a n g e o f v a lu e s c a n n o t b e c o v e r e d b y 8 b its , b u t it is g iv e n in th e p r o b le m s ta te m e n t th a t th e r e s u lt o f s u b tr a c tio n h a s to b e r e p r e s e n te d in 8 b its a ls o , a n d , c o n s is te n t w ith th e r a n g e o f v a lu e s u s e d fo r 8 - b it im a g e s th r o u g h o u t th e b o o k , w e a s s u m e th a t v a lu e s o f th e 8 - b it d iffe r e n c e im a g e s a r e in th e r a n g e [0 , 2 5 5 ]. W h a t th is m e a n s is th a t a n y s u b tr a c tio n o f 2 p ix e ls th a t y ie ld s a n e g a tiv e q u a n tity w ill b e c lip p e d a t 0 . T h e p r o c e s s o f re p e a te d s u b tr a c tio n s o f a n im a g e b (x ,y ) fr o m a n im a g e a (x ,y ) c a n b e e x p re s s e d a s K d K (x ,y ) = a (x ,y ) − b (x ,y ) k = 1 = a (x ,y ) − K × b (x ,y ) w h e r e d K (x , y ) is th e d iffe r e n c e im a g e r e s u ltin g a fte r K s u b tr a c tio n s . B e c a u s e im a g e s u b tr a c tio n is a n a r r a y o p e r a tio n (s e e S e c tio n 2 .6 .1 ), w e c a n fo c u s a tte n tio n o n th e s u b tr a c tio n o f a n y c o r r e s p o n d in g p a ir o f p ix e ls in th e im a g e s . W e h a v e a lr e a d y s ta te d th a t n e g a tiv e r e s u lts a r e c lip p e d a t 0 . O n c e a 0 r e s u lt is o b ta in e d , it w ill r e m a in s o b e c a u s e s u b tr a c tio n o f a n y n o n n e g a tiv e v a lu e fr o m 0 is a n e g a tiv e q u a n tity w h ic h , a g a in , is c lip p e d a t 0 . S im ila r ly , a n y lo c a tio n x 0 , y 0 fo r w h ic h b x 0 , y 0 = 0 , w ill p r o d u c e th e r e s u lt d K x 0 , y 0 = a x 0 , y 0 . T h a t is , r e p e a te d ly s u b tr a c tin g 0 fr o m a n y v a lu e r e s u lts in th a t v a lu e . T h e lo c a tio n s in b (x , y ) th a t a r e n o t 0 w ill e v e n tu a lly d e c r e a s e th e c o r r e s p o n d in g v a lu e s in d K (x ,y ) u n til th e y a re 0 . T h e m a x im u m n u m b e r o f s u b tr a c tio n s in w h ic h th is ta k e s p la c e in th e c o n te x t o f th e p r e s e n t p r o b le m is 2 5 5 , w h ic h c o r r e s p o n d s to th e c o n d itio n a t a lo c a tio n in w h ic h a (x , y ) is 2 5 5 a n d b (x , y ) is 1 . T h u s , w e c o n c lu d e fr o m th e p r e c e d in g d is c u s s io n th a t r e p e a te d ly s u b tr a c tin g a n im a g e fr o m a n o th e r w ill r e s u lt in a d iffe r e n c e im a g e w h o s e c o m p o n e n ts a r e 0 in th e lo c a tio n s in b (x , y ) th a t a r e n o t z e r o a n d e q u a l to th e o r ig in a l v a lu e s o f a (x , y ) a t th e lo c a tio n s in b (x , y ) th a t a r e 0 . T h is r e s u lt w ill b e a c h ie v e d in , a t m o s t, 2 5 5 s u b tr a c tio n s . 1 9 (b o r a re ) T h e d in a te x 0 ,y 0 s u lt in o rd e r d o e s m a tte r. F o r e x a m s , x 0 ,y 0 , a x 0 ,y 0 = 1 2 8 a n w ill r e s u lt in d K x 0 , y 0 = 1 2 a v a lu e o f 0 in th a t s a m e lo c a p le , d b 8 in tio n s u p p o s e th a t a t a p a ir o f a r b itr a r y c o x 0 ,y 0 = 0 . S u b tr a c tin g b x 0 ,y 0 fr o m th e lim it. R e v e r s in g th e o p e r a tio n w ill . Problem 2.22 L e t g (x , y ) d e n o te th e g o ld e n im a g e , a n d le t f (x , y ) d e n o te a n y in p u t im a g e a c q u ire d d u r in g r o u tin e o p e r a tio n o f th e s y s te m . C h a n g e d e te c tio n v ia s u b tr a c tio n is b a s e d o n c o m p u tin g th e s im p le d iffe r e n c e d (x , y ) = g (x , y ) − f (x , y ). T h e r e s u ltin g im a g e , d (x , y ), c a n b e u s e d in tw o fu n d a m e n ta l w a y s fo r c h a n g e d e te c tio n . O n e w a y is u s e p ix e l- b y - p ix e l a n a ly s is . In th is c a s e w e s a y th a t f (x , y ) is “ c lo s e e n o u g h ” to th e g o ld e n im a g e if a ll th e p ix e ls in d (x , y ) fa ll w ith in a s p e c ifi e d th r e s h o ld b a n d [T m in , T m a x ] w h e r e T m in is n e g a tiv e a n d T m a x is p o s itiv e . U s u a lly , th e s a m e v a lu e o f th r e s h o ld is u s e d fo r b o th n e g a tiv e a n d p o s itiv e d iffe r e n c e s , s o th a t w e h a v e a b a n d [− T , T ] in w h ic h a ll p ix e ls o f d (x , y ) m u s t fa ll in o r d e r fo r f (x , y ) to b e d e c la r e d a c c e p ta b le . T h e s e c o n d m a jo r a p p r o a c h is s im p ly to s u m a ll th e p ix e ls in d (x , y ) a n d c o m p a r e th e s u m a g a in s t a th r e s h o ld Q . N o te th a t th e a b s o lu te v a lu e n e e d s to b e u s e d to a v o id e r r o r s c a n c e lin g o u t. T h is is a m u c h c r u d e r te s t, s o w e w ill c o n c e n tr a te o n th e fi r s t a p p r o a c h . T h e re a re th re e fu n d a m e n ta l fa c to r s th a t n e e d tig h t c o n tr o l fo r d iffe re n c e b a s e d in s p e c tio n to w o r k : (1 ) p r o p e r r e g is tr a tio n , (2 ) c o n tr o lle d illu m in a tio n , a n d (3 ) n o is e le v e ls th a t a r e lo w e n o u g h s o th a t d iffe r e n c e v a lu e s a r e n o t a ffe c te d a p p r e c ia b ly b y v a r ia tio n s d u e to n o is e . T h e fi r s t c o n d itio n b a s ic a lly a d d r e s s e s th e r e q u ir e m e n t th a t c o m p a r is o n s b e m a d e b e tw e e n c o r r e s p o n d in g p ix e ls . T w o im a g e s c a n b e id e n tic a l, b u t if th e y a r e d is p la c e d w ith r e s p e c t to e a c h o th e r, c o m p a r in g th e d iffe re n c e s b e tw e e n th e m m a k e s n o s e n s e . O fte n , s p e c ia l m a r k in g s a r e m a n u fa c tu r e d in to th e p r o d u c t fo r m e c h a n ic a l o r im a g e - b a s e d a lig n m e n t C o n tr o lle d illu m in a tio n (n o te th a t “ illu m in a tio n ” is n o t lim ite d to v is ib le lig h t) o b v io u s ly is im p o r ta n t b e c a u s e c h a n g e s in illu m in a tio n c a n a ffe c t d r a m a tic a lly th e v a lu e s in a d iffe r e n c e im a g e . O n e a p p r o a c h u s e d o fte n in c o n ju n c tio n w ith illu m in a tio n c o n tr o l is in te n s ity s c a lin g b a s e d o n a c tu a l c o n d itio n s . F o r e x a m p le , th e p r o d u c ts c o u ld h a v e o n e o r m o r e s m a ll p a tc h e s o f a tig h tly c o n tr o lle d c o lo r, a n d th e in te n s ity (a n d p e r h a p s e v e n c o lo r ) o f e a c h p ix e ls in th e e n tir e im a g e w o u ld b e m o d ifi e d b a s e d o n th e a c tu a l v e r s u s e x p e c te d in te n s ity a n d / o r c o lo r o f th e p a tc h e s in th e im a g e b e in g p r o c e s s e d . F in a lly , th e n o is e c o n te n t o f a d iffe r e n c e im a g e n e e d s to b e lo w e n o u g h s o th a t it d o e s n o t m a te r ia lly a ffe c t c o m p a r is o n s b e tw e e n th e g o ld e n a n d in p u t im a g e s . G o o d s ig n a l s tr e n g th g o e s a lo n g w a y to w a r d r e d u c in g th e e ffe c ts o f n o is e . C H A P T E R 2 . P R O B L E M S O L U T IO N S 2 0 F ig u r e P 2 .2 3 A n o th e r (s o m e tim e s c o m p le m e n ta r y ) a p p r o a c h is to im p le m e n t im a g e p r o c e s s in g t e c h n iq u e s ( e .g ., im a g e a v e r a g in g ) t o r e d u c e n o is e . O b v io u s ly th e r e a r e a n u m b e r if v a r ia tio n s o f th e b a s ic th e m e ju s t d e s c r ib e d . F o r e x a m p le , a d d itio n a l in te llig e n c e in th e fo r m o f te s ts th a t a r e m o r e s o p h is tic a te d th a n p ix e l- b y - p ix e l th r e s h o ld c o m p a r is o n s c a n b e im p le m e n te d . A te c h n iq u e u s e d o fte n in th is r e g a r d is to s u b d iv id e th e g o ld e n im a g e in to d iffe r e n t r e g io n s a n d p e r fo r m d iffe r e n t (u s u a lly m o r e th a n o n e ) te s ts in e a c h o f th e r e g io n s , b a s e d o n e x p e c te d re g io n c o n te n t. Problem 2.23 ( a ) T h e a n s w e r is s h o w n in F ig . P 2 .2 3 . ( b ) W ith r e fe r e n c e to th e s e ts in th e p r o b le m s ta te m e n t, th e a n s w e r s a r e , fr o m le ft to r ig h t, (A \ B \ C ) − (B \ C ) ; (A \ B \ C ) [ (A \ C ) [ (A \ B ) ; c B \ (A [ C ) [ f (A \ C ) − [(A \ C ) \ (B \ C )]g . Problem 2.24 U s in g tr ia n g u la r r e g io n s m e a n s th r e e tie p o in ts , s o w e c a n s o lv e th e fo llo w in g s e t o f lin e a r e q u a tio n s fo r s ix c o e ffi c ie n ts : y x 0 0 = c 1 x + c 2 y + c 3 = c 4 x + c 5 y + c 6 2 1 to im p le m e n t s p a tia l tr a n s fo r m a tio n s . In te n s ity in te r p o la tio n is im p le m e n te d u s in g a n y o f t h e m e t h o d s in S e c t io n 2 .4 .4 . Problem 2.25 T h e F o u r ie r tr a n s fo r m a tio n k e r n e l is s e p a r a b le b e c a u s e r (x ,y ,u ,v ) = − j 2 π e = e = ( ) u x / M + v y / N − j 2 π (u x / M ) e − j 2 π ( v y / N ) r 1 (x ,u )r 2 (y ,v ). It is s y m m e tr ic b e c a u s e e − j 2 π ( u x / M + v y / N ) = e = − j 2 π (u x / M ) e − j 2 π ( v y / N ) r 1 (x ,u )r 1 (y ,v ). Problem 2.26 F r o m E q . ( 2 .6 - 2 7 ) a n d t h e d e fi n it io n o f s e p a r a b le k e r n e ls , M − 1 N − 1 T (u ,v ) f (x ,y )r (x ,y ,u ,v ) = x = 0 y = 0 M − 1 N − 1 r 1 (x ,u ) = x = 0 f (x ,y )r 2 (y ,v ) y = 0 M − 1 = T (x ,v )r 1 (x ,u ) x = 0 w h e re N − 1 T (x ,v ) = f (x ,y )r 2 (y ,v ). y = 0 F o r a fi x e d v a lu e o f x , th is e q u a tio n is o n e r o w o f f (x , y ). B y le ttin g x v a r y fr o m T (x ,v ). T h e n , b y s u b s titu tin g th is a r r a y tio n w e h a v e th e 1 - D tr a n s fo r m a lo n g t w h e n a k e r n e l is s e p a r a b le , w e c a n c o m o f th e im a g e . T h e n w e c o m p u te th e 1 - D te r m e d ia te r e s u lt to o b ta in th e fi n a l 2 - D r e s u lt b y c o m p u tin g th e 1 - D tr a n s fo r m a th e 1 - D tr a n s fo r m a lo n g th e r o w s o f th e r e c o g n iz e d a s th e 1 - D tr a n s fo r m a lo n g 0 to M − 1 w e c o m p u te th e e n tire a r r a y in to th e la s t lin e o f th e p r e v io u s e q u a h e c o lu m n s o f T (x , v ). In o th e r w o r d s , p u te th e 1 - D tr a n s fo r m a lo n g th e r o w s tr a n s fo r m a lo n g th e c o lu m n s o f th is in tr a n s fo r m , T (u ,v ). W e o b ta in th e s a m e lo n g th e c o lu m n s o f f (x , y ) fo llo w e d b y in te r m e d ia te r e s u lt. C H A P T E R 2 . P R O B L E M S O L U T IO N S 2 2 T h is r e s u lt p la y s a n im p o r ta n t r o le in C h a p te r 4 w h e n w e d is c u s s th e 2 - D F o u r ie r t r a n s fo r m . F r o m E q . ( 2 .6 - 3 3 ) , t h e 2 - D F o u r ie r t r a n s fo r m is g iv e n b y M − 1 N − 1 x = 0 ( − j 2 π f (x ,y )e T (u ,v ) = ). u x / M + v y / N y = 0 It is e a s ily v e r ifi e d t h a t t h e F o u r ie r t r a n s fo r m k e r n e l is s e p a r a b le ( P r o b le m 2 .2 5 ) , s o w e c a n w r ite th is e q u a tio n a s M − 1 N − 1 T (u ,v ) = f (x ,y )e x = 0 ( u x / M + v y / N ) y = 0 N − 1 M − 1 = − j 2 π e − j 2 π (u x / M ) x = 0 − j 2 π f (x ,y )e ( v y / N ) y = 0 M − 1 T (x ,v )e = − j 2 π (u x / M ) x = 0 w h e re N − 1 f (x ,y )e T (x ,v ) = − j 2 π ( v y / N ) y = 0 is th e 1 - D F o u r ie r tr a n s fo r m a lo n g th e r o w s o f f (x , y ), a s w e le t x = 0 , 1 , . . . , M − 1 . Problem 2.27 T h e g e o m e t r y o f t h e c h ip s is s h o w n in F ig . P 2 .2 7 ( a ) . F r o m F ig . P 2 .2 7 ( b ) a n d t h e g e o m e t r y in F ig . 2 .3 , w e k n o w t h a t Δ x = λ × 8 0 λ − z w h e re Δ x is th e s id e d im e n s io n o f th e im a g e (a s s u m e d s q u a re b e c a u s e th e v ie w in g s c r e e n is s q u a r e ) im p in g in g o n th e im a g e p la n e , a n d th e 8 0 m m r e fe r s to th e s iz e o f th e v ie w in g s c r e e n , a s d e s c r ib e d in th e p r o b le m s ta te m e n t. T h e m o s t in e x p e n s iv e s o lu tio n w ill r e s u lt fr o m u s in g a c a m e r a o f r e s o lu tio n 5 1 2 × 5 1 2 . B a s e d o n t h e in fo r m a t io n in F ig . P 2 .2 7 ( a ) , a C C D c h ip w it h t h is r e s o lu t io n w ill b e o f s iz e (1 6 μ ) × (5 1 2 ) = 8 m m o n e a c h s id e . S u b s titu tin g Δ x = 8 m m in th e a b o v e e q u a tio n g iv e s z = 9 λ a s th e r e la tio n s h ip b e tw e e n th e d is ta n c e z a n d th e fo c a l le n g th o f th e le n s , w h e r e a m in u s s ig n w a s ig n o r e d b e c a u s e it is ju s t a c o o r d in a te in v e r s io n . If a 2 5 m m le n s is u s e d , th e fr o n t o f th e le n s w ill h a v e to b e lo c a te d a t a p p r o x im a te ly 2 2 5 m m fr o m th e v ie w in g s c r e e n s o th a t th e s iz e o f th e 2 3 F ig u r e P 2 .2 7 im a m m b u t p o s g e o f th e s c r e e n p r o je c te d o n to th e C C D im a g e p la n e d o e s n o t e x c e e d th e 8 s iz e o f th e C C D c h ip fo r th e 5 1 2 × 5 1 2 c a m e r a . T h is v a lu e o f z is r e a s o n a b le , a n y o th e r g iv e n le n s s iz e s w o u ld b e a ls o ; th e c a m e r a w o u ld ju s t h a v e to b e itio n e d fu r th e r a w a y . A s s u m in g a 2 5 m m le n s , th e n e x t is s u e is to d e te r m in e if th e s m a lle s t d e fe c t w ill b e im a g e d o n , a t le a s t, a 2 × 2 p ix e l a r e a , a s r e q u ir e d b y th e s p e c ifi c a tio n . It is g iv e n th a t th e d e fe c ts a r e c ir c u la r, w ith th e s m a lle s t d e fe c t h a v in g a d ia m e te r o f 0 .8 m m . S o , a ll t h a t n e e d s t o b e d o n e is t o d e t e r m in e if t h e im a g e o f a c ir c le o f d ia m e t e r 0 .8 m m o r g r e a t e r w ill, a t le a s t , b e o f s iz e 2 × 2 p ix e ls o n t h e C C D im a g in g p la n e . T h is c a n b e d e t e r m in e d b y u s in g t h e s a m e m o d e l a s in F ig . P 2 .2 7 ( b ) w ith th e 8 0 m m r e p la c e d b y 0 .8 m m . U s in g λ = 2 5 m m a n d z = 2 2 5 m m in t h e a b o v e e q u a tio n y ie ld s Δ x = 1 0 0 μ . In o th e r w o r d s , a c ir c u la r d e fe c t o f d ia m e te r 0 .8 m m w ill b e im a g e d a s a c ir c le w it h a d ia m e t e r o f 1 0 0 μ o n t h e C C D c h ip o f a 5 1 2 × 5 1 2 c a m e r a e q u ip p e d w ith a 2 5 m m le n s a n d w h ic h v ie w s th e d e fe c t a t a d is ta n c e o f 2 2 5 m m . If, in o rd e r fo r a C C D re c e p to r to b e a c tiv a te d , its a re a h a s to b e e x c ite d in its e n tir e ty , th e n , it c a n b e s e e n fr o m F ig . P 2 .2 7 (a ) th a t to g u a r a n te e th a t a 2 × 2 a r r a y o f s u c h r e c e p to r s w ill b e a c tiv a te d , a c ir c u la r a r e a o f d ia m e te r n o le s s th a n (6 )(8 ) = 4 8 μ h a s to b e im a g e d o n to th e C C D c h ip . T h e s m a lle s t d e fe c t is im a g e d a s a c ir c le w ith d ia m e te r o f 1 0 0 μ , w h ic h is w e ll a b o v e th e 4 8 μ m in im u m re q u ire m e n t. 2 4 C H A P T E R 2 . P R O B L E M S O L U T IO N S T h e r e fo r e , w e c o n c lu d e th a t a C C D c a m e r a o f r e s o lu tio n 5 1 2 × 5 1 2 p ix e ls , u s in g a 2 5 m m le n s a n d im a g in g th e v ie w in g s c r e e n a t a d is ta n c e o f 2 2 5 m m , is s u ffi c ie n t to s o lv e th e p r o b le m p o s e d b y th e p la n t m a n a g e r. Chapter 3 Problem Solutions Problem 3.1 L e t f d e n o te th e o r ig in a l im a g e . F ir s t s u b tr a c t th e m in im u m v a lu e o f f d e n o te d f m in f r o m f t o y i e ld a f u n c t i o n w h o s e m i n i m u m v a lu e i s 0 : g = 1 f − f m in N e x t d iv id e g 1 b y its m a x im u m v a lu e to y ie ld a fu n c tio n in th e r a n g e [0 , 1 ] a n d m u ltip ly th e r e s u lt b y L − 1 to y ie ld a fu n c tio n w ith v a lu e s in th e r a n g e [0 , L − 1 ] = g = K e e p in m in d th a t f m in L − 1 g 1 m a x g 1 L − 1 m a x f − f m f − f m in in is a s c a la r a n d f is a n im a g e . Problem 3.2 2 ( a ) G e n e r a l fo r m : s = T (r ) = A e − K r . F o r th e c o n d itio n s h o w n in th e p r o b le m 2 fi g u r e , A e − K L 0 = A / 2 . S o lv in g fo r K y ie ld s − K L 2 0 = ln (0 .5 ) K = 0 .6 9 3 / L T h e n , − s = T (r ) = A e (b ) G e n e ra l fo r m : s = T (r ) = B (1 − e − K r 2 5 2 0 .6 9 3 L 2 0 2 . 0 r 2 . ). F o r th e c o n d itio n s h o w n in th e p r o b - C H A P T E R 3 . P R O B L E M S O L U T IO N S 2 6 F ig u r e P 3 .3 le m fi g u r e , B (1 − e 2 − K L 0 ) = B / 2 . T h e s o lu tio n fo r K is th e s a m e a s in (a ), s o − s = T (r ) = B (1 − e (c ) G e n e ra l fo r m : s = T (r ) = (D − C )(1 − e − K r 2 0 .6 9 3 L 2 0 2 r ) ) + C . Problem 3.3 (a ) s = T (r ) = 1 1 + (m / r ) E . ( b ) S e e F ig . P 3 .3 . (c ) W e w a n t s to b e 0 fo r r < m , a n d s to b e 1 fo r s = 1 / 2 . B u t, b e c a u s e th e v a lu e s o f r a r e in te g e r s , ⎧ w h e n r ≤ ⎨ 0 .0 0 .5 w h e n r = s = T (r ) = ⎩ 1 .0 w h e n r ≥ v a lu e s o f r > m . W h e n r = m , th e b e h a v io r w e w a n t is m − 1 m m + 1 . T h e q u e s tio n in th e p r o b le m s ta te m e n t is to fi n d th e s m a lle s t v a lu e o f E th a t w ill m a k e th e th r e s h o ld b e h a v e a s in th e e q u a tio n a b o v e . W h e n r = m , w e s e e fr o m ( a ) t h a t s = 0 .5 , r e g a r d le s s o f t h e v a lu e o f E . If C is t h e s m a lle s t p o s it iv e 2 7 n u m b th e n a s m a lle fo r E , e r re p re n y v a lu s t v a lu e u s in g th s e n ta b le e o f s le s o f E fo r e g iv e n v in th s th a w h ic a lu e e c o m n C / 2 h th is m = 1 p u te r, a n d k e e p in g in m in d th a t s is p o s itiv e , w ill b e c a lle d 0 b y th e c o m p u te r. T o fi n d th e h a p p e n s , s im p ly s o lv e th e fo llo w in g e q u a tio n 2 8 : 1 1 + [m / (m − 1 )] E < C / 2 . B e c a u s e th e fu n c tio n is s y m m e tr ic a b o u t m , th e r e s u ltin g v a lu e o f E w ill y ie ld s = 1 fo r r ≥ m + 1 . Problem 3.4 T h e tr a n s fo r m a tio n s r e q u ir e d to p r o d u c e th e in d iv id u a l b it p la n e s a r e n o th in g m o r e th a n m a p p in g s o f th e tr u th ta b le fo r e ig h t b in a r y v a r ia b le s . In th is tr u th ta b le , th e v a lu e s o f th e 8 th b it a r e 0 fo r b y te v a lu e s 0 to 1 2 7 , a n d 1 fo r b y te v a lu e s 1 2 8 to 2 5 5 , th u s g iv in g th e tr a n s fo r m a tio n m e n tio n e d in th e p r o b le m s ta te m e n t. N o te th a t th e g iv e n tr a n s fo r m e d v a lu e s o f e ith e r 0 o r 2 5 5 s im p ly in d ic a te a b in a r y im a g e fo r th e 8 th b it p la n e . A n y o th e r tw o v a lu e s w o u ld h a v e b e e n e q u a lly v a lid , th o u g h le s s c o n v e n tio n a l. C o n tin u in g w ith th e tr u th ta b le c o n c e p t, th e tr a n s fo r m a tio n r e q u ir e d to p r o d u c e a n im a g e o f th e 7 th b it p la n e o u tp u ts a 0 fo r b y te v a lu e s in th e r a n g e [0 , 6 3 ], a 1 fo r b y te v a lu e s in th e r a n g e [6 4 , 1 2 7 ], a 0 fo r b y te v a lu e s in th e r a n g e [1 2 8 , 1 9 1 ], a n d a 1 fo r b y te v a lu e s in th e r a n g e [1 9 2 , 2 5 5 ]. S im ila r ly , th e tr a n s fo r m a tio n fo r th e 6 th b it p la n e a lte r n a te s b e tw e e n e ig h t r a n g e s o f b y te v a lu e s , th e tr a n s fo r m a tio n fo r th e 5 th b it p la n e a lte r n a te s b e tw e e n 1 6 r a n g e s , a n d s o o n . F in a lly , th e o u tp u t o f th e tr a n s fo r m a tio n fo r th e lo w e s t- o r d e r b it p la n e a lte r n a te s b e tw e e n 0 a n d 2 5 5 d e p e n d in g o n w h e th e r th e b y te v a lu e s a r e e v e n o r o d d . T h u s , th is tr a n s fo r m a tio n a lte r n a te s b e tw e e n 1 2 8 b y te v a lu e r a n g e s , w h ic h e x p la in s w h y a n im a g e o f th a t b it p la n e is u s u a lly th e “ b u s ie s t” lo o k in g o f a ll th e b it p la n e im a g e s . Problem 3.5 (a th th th in ) T h e n u m b e r o f p ix e ls u s c a u s in g th e n u m b e r e n u m b e r o f p ix e ls w o u e re m a in in g h is to g r a m in te n s ity le v e l v a lu e s w h a o f ld p e ill v in g d iffe re n t in te n s ity c o m p o n e n ts in th e h is n o t c h a n g e , th is w o u ld a k s to in c re a s e in g e n e re d u c e c o n tra s t. le v e l v a lu to g ra m to c a u s e th r a l. T y p ic e s w o u d e c re a e h e ig h a lly , le s ld d e s e . B t o f s s v a r c re e c a o m ia b a s e , u s e e o f ility ( b ) T h e m o s t v is ib le e ffe c t w o u ld b e s ig n ifi c a n t d a r k e n in g o f th e im a g e . F o r e x a m p le , d r o p p in g th e h ig h e s t b it w o u ld lim it th e b r ig h te s t le v e l in a n 8 - b it im - C H A P T E R 3 . P R O B L E M S O L U T IO N S 2 8 a g e to b o f s o m e to g ra m lo c a te d e 1 2 7 . B e c a u s e th e n u m b e r o f p ix e ls w o u ld r e m a in c o n s ta n t, th e h e ig h t o f th e h is to g r a m p e a k s w o u ld in c r e a s e . T h e g e n e r a l s h a p e o f th e h is w o u ld n o w b e ta lle r a n d n a r r o w e r, w ith n o h is to g r a m c o m p o n e n ts b e in g p a s t 1 2 7 . Problem 3.6 A ll th a t h is to g r a m e q u a liz a tio n d o e s is r e m a p h is to g r a m c o m p o n e n ts o n th e in te n s ity s c a le . T o o b ta in a u n ifo r m (fl a t) h is to g r a m w o u ld r e q u ir e in g e n e r a l th a t p ix e l in te n s itie s a c tu a lly b e r e d is tr ib u te d s o th a t th e r e a r e L g r o u p s o f n / L p ix e ls w ith th e s a m e in te n s ity , w h e r e L is th e n u m b e r o f a llo w e d d is c r e te in te n s ity le v e ls a n d n = M N is th e to ta l n u m b e r o f p ix e ls in th e in p u t im a g e . T h e h is to g r a m e q u a liz a tio n m e th o d h a s n o p r o v is io n s fo r th is ty p e o f (a r tifi c ia l) in te n s ity r e d is tr ib u tio n p r o c e s s . Problem 3.7 L e t n = M N b e th e to ta l n u m b e r o f p ix e ls a n d le t n rj b e th e n u m b e r o f p ix e ls in th e in p u t im a g e w ith in te n s ity v a lu e r j . T h e n , th e h is to g r a m e q u a liz a tio n tr a n s fo r m a tio n is k s k = T (r k ) = n r j k 1 / n = n n j = 0 r j . j = 0 B e c a u s e e v e r y p ix e l (a n d n o o th e r s ) w ith v a lu e r k is m a p p e d to v a lu e s k , it fo llo w s th a t n sk = n rk . A s e c o n d p a s s o f h is to g r a m e q u a liz a tio n w o u ld p r o d u c e v a lu e s v k a c c o r d in g to th e tr a n s fo r m a tio n v B u t, n s j = n r j k = T (s k k 1 ) = n n s j . j = 0 , s o v k = T (s k ) = 1 n k n r j = s k j = 0 w h ic h s h o w s th a t a s e c o n d p a s s o f h is to g r a m e q u a liz a tio n w o u ld y ie ld th e s a m e r e s u lt a s th e fi r s t p a s s . W e h a v e a s s u m e d n e g lig ib le r o u n d - o ff e r r o r s . 2 9 Problem 3.8 T h e g e n e r a l h is to g r a m e q u a liz a tio n tr a n s fo r m a tio n fu n c tio n is r s = T (r ) = p (w ) d w . r 0 T h e re a re tw o im p o r ta n t p o in ts a b o u t w h ic h th e s tu d e n t m u s t s h o w a w a re n e s s in a n s w e r in g th is p r o b le m . F ir s t, th is e q u a tio n a s s u m e s o n ly p o s itiv e v a lu e s fo r r . H o w e v e r, th e G a u s s ia n d e n s ity e x te n d s in g e n e r a l fr o m − 1 to 1 . R e c o g n itio n o f th is fa c t is im p o r ta n t. O n c e re c o g n iz e d , th e s tu d e n t c a n a p p r o a c h th is d iffi c u lty in s e v e r a l w a y s . O n e g o o d a n s w e r is to m a k e s o m e a s s u m p tio n , s u c h a s th e s ta n d a r d d e v ia tio n b e in g s m a ll e n o u g h s o th a t th e a r e a o f th e c u r v e u n d e r p r (r ) fo r n e g a tiv e v a lu e s o f r is n e g lig ib le . A n o th e r is to s c a le u p th e v a lu e s u n til th e a r e a u n d e r th e n e g a tiv e p a r t o f th e c u r v e is n e g lig ib le . T h e s e c o n d m a jo r p o in t is to r e c o g n iz e is th a t th e tr a n s fo r m a tio n fu n c tio n its e lf, r s = T (r ) = p 1 2 π σ e − (w − m )2 2 σ 2 d w 0 h G u h h A p d a s n o c lo s e d - fo r m s o lu tio n . T h is is th e c u m u la tiv e d is tr ib u tio n fu n c tio n o f th e a u s s ia n d e n s ity , w h ic h is e ith e r in te g r a te d n u m e r ic a lly , o r its v a lu e s a r e lo o k e d p in a ta b le . A th ir d , le s s im p o r ta n t p o in t, th a t th e s tu d e n t s h o u ld a d d r e s s is th e ig h - e n d v a lu e s o f r . A g a in , th e G a u s s ia n P D F e x te n d s to + 1 . O n e p o s s ib ility e re is to m a k e th e s a m e a s s u m p tio n a s a b o v e re g a rd in g th e s ta n d a rd d e v ia tio n . n o th e r is to d iv id e b y a la r g e e n o u g h v a lu e s o th a t th e a r e a u n d e r th e p o s itiv e a r t o f th e P D F p a s t th a t p o in t is n e g lig ib le (th is s c a lin g r e d u c e s th e s ta n d a r d e v ia tio n ). A n o th e r a p p r o a c h th e s tu d e n t c a n ta k e is to w o r k w ith h is to g r a m s , in w h ic h c a s e th e tr a n s fo r m a tio n fu n c tio n w o u ld b e in th e fo r m o f a s u m m a tio n . T h e is s u e o f n e g a tiv e a n d h ig h p o s itiv e v a lu e s m u s t s till b e a d d r e s s e d , a n d th e p o s s ib le a n s w e r s s u g g e s te d a b o v e r e g a r d in g th e s e is s u e s s till a p p ly . T h e s tu d e n t n e e d s to in d ic a te th a t th e h is to g r a m is o b ta in e d b y s a m p lin g th e c o n tin u o u s fu n c tio n , s o s o m e m e n tio n s h o u ld b e m a d e r e g a r d in g th e n u m b e r o f s a m p le s (b its ) u s e d . T h e m o s t lik e ly a n s w e r is 8 b its , in w h ic h c a s e th e s tu d e n t n e e d s to a d d r e s s th e s c a lin g o f th e fu n c tio n s o th a t th e r a n g e is [0 , 2 5 5 ]. Problem 3.9 W e a r e in te r e s te d in ju s t o n e e x a m p le in o r d e r to s a tis fy th e s ta te m e n t o f th e p r o b le m . C o n s id e r t h e p r o b a b ilit y d e n s it y fu n c t io n in F ig . P 3 .9 ( a ) . A p lo t o f C H A P T E R 3 . P R O B L E M S O L U T IO N S 3 0 2(L - 1) L - 1 0 L /4 L /2 3L /4 L - 1 0 L /4 L /2 3L /4 L - 1 L - 1 (L - 1)/2 F ig u r e P 3 .9 . t h e t r a n s fo r m a t io n T (r ) in E q . ( 3 .3 - 4 ) u s in g t h is p a r t ic u la r d e n s it y fu n c t io n is s h o w n in F ig . P 3 .9 ( b ) . B e c a u s e p r (r ) is a p r o b a b ilit y d e n s it y fu n c t io n w e k n o w fr o m th e d is c u s s io n in S e c tio n 3 .3 .1 th a t th e tr a n s fo r m a tio n T (r ) s a tis fi e s c o n d it io n s ( a ) a n d ( b ) s t a t e d in t h a t s e c t io n . H o w e v e r, w e s e e fr o m F ig . P 3 .9 ( b ) t h a t th e in v e r s e tr a n s fo r m a tio n fr o m s b a c k to r is n o t s in g le v a lu e d , a s th e r e a r e a n in fi n ite n u m b e r o f p o s s ib le m a p p in g s fr o m s = (L − 1 ) / 2 b a c k to r . It is im p o r ta n t to n o te th a t th e re a s o n th e in v e r s e tr a n s fo r m a tio n fu n c tio n tu r n e d o u t n o t to b e s in g le v a lu e d is th e g a p in p r (r ) in th e in te r v a l [ L / 4 , 3 L / 4 ] . Problem 3.10 ( a ) W e n e e d to s h o w th a t th e tr a n s fo r m a tio n fu n c tio n in E q . (3 .3 - 8 ) is m o n o to n ic in t h e r a n g e [0 , L − 1 ], a n d t h a t it s v a lu e s a r e in t h e r a n g e [0 , L − 1 ]. F r o m E q . ( 3 .3 8 ) k s k = T (r k ) = (L − 1 ) p r (r j ) j = 0 B e c a u s e a ll th e p r (r j ) a r e p o s itiv e , it fo llo w s th a t T (r k ) is m o n o to n ic in th e r a n g e k 2 [0 , L − 1 ]. B e c a u s e th e s u m o f a ll th e v a lu e s o f p r (r j ) is 1 , it fo llo w s th a t 0 ≤ s k ≤ L − 1 . 3 1 ( b ) If n o n e o f th e in te n s ity le v e ls r k , k = 1 , 2 , . . . , L − 1 , a r e 0 , th e n T (r k ) w ill b e s tr ic tly m o n o to n ic . T h is im p lie s a o n e - to - o n e m a p p in g b o th w a y s , m e a n in g th a t b o th fo r w a r d a n d in v e r s e tr a n s fo r m a tio n s w ill b e s in g le - v a lu e d . Problem 3.11 F ir s t, w e o b ta in th e h is to g r a m e q u a liz a tio n tr a n s fo r m a tio n : r r s = T (r ) = p r (w ) d w = 0 2 (− 2 w + 2 ) d w = − r + 2 r . 0 N e x t w e fi n d z v = G (z ) = z p (w ) d w = z 2 w d w = z 0 2 . 0 F in a lly , − 1 z = G p (v ) = ± v . B u t o n ly p o s itiv e in te n s ity le v e ls a r e a llo w e d , s o z = s , w h ic h in tu r n is − r 2 + 2 r , a n d w e h a v e z = − r 2 p v . T h e n , w e r e p la c e v w ith + 2 r . Problem 3.12 T h e v a lu e o f th e h is to g r a m c o m p o n e n t c o r r e s p o n d in g to th e k th in te n s ity le v e l in a n e ig h b o r h o o d is n k p r (r k ) = n fo r k = 1 , 2 , . . . , K − 1 , w h e r e n k is th e n u m b e r o f p ix e ls h a v in g in te n s ity le v e l r k , n is th e to ta l n u m b e r o f p ix e ls in th e n e ig h b o r h o o d , a n d K is th e to ta l n u m b e r o f p o s s ib le in te n s ity le v e ls . S u p p o s e th a t th e n e ig h b o r h o o d is m o v e d o n e p ix e l to th e r ig h t (w e a r e a s s u m in g r e c ta n g u la r n e ig h b o r h o o d s ). T h is d e le te s th e le ftm o s t c o lu m n a n d in tr o d u c e s a n e w c o lu m n o n th e r ig h t. T h e u p d a te d h is to g r a m th e n b e c o m e s 1 p r0 ( r k ) = [n k − n L k + n R k ] n fo r k = 0 , 1 , . . . , K − 1 , w h e r e n L k is th e n u m b e r o f o c c u r r e n c e s o f le v e l r k o n th e le ft c o lu m n a n d n R k is th e s im ila r q u a n tity o n th e r ig h t c o lu m n . T h e p r e c e d in g e q u a tio n c a n b e w r itte n a ls o a s p r 0 (r k ) = p r (r k ) + 1 n [n R k − n L k ] C H A P T E R 3 . P R O B L E M S O L U T IO N S 3 2 fo r k = 0 , 1 , . . . , K − 1 . T h e s a m e c o n c e p t a p p lie s to o th e r m o d e s o f n e ig h b o r h o o d m o tio n : 1 [b k − a k ] p r0 ( r k ) = p r ( r k ) + n fo r k = 0 , 1 , . . . , K − 1 , w h e r e a k is th e n u m b e r o f p ix e ls w ith v a lu e r k in th e n e ig h b o r h o o d a r e a d e le te d b y th e m o v e , a n d b k is th e c o r r e s p o n d in g n u m b e r in tr o d u c e d b y th e m o v e . Problem 3.13 T h e p u r p o s e o f th is s im p le p r o b le m is to m a k e th e s tu d e n t th in k o f th e m e a n in g o f h is to g r a m s a n d a r r iv e a t th e c o n c lu s io n th a t h is to g r a m s c a r r y n o in fo r m a tio n a b o u t s p a tia l p r o p e r tie s o f im a g e s . T h u s , th e o n ly tim e th a t th e h is to g r a m o f th e im a g e s fo r m e d b y th e o p e r a tio n s s h o w n in th e p r o b le m s ta te m e n t c a n b e d e te r m in e d in te r m s o f th e o r ig in a l h is to g r a m s is w h e n o n e (b o th ) o f th e im a g e s is (a re ) c o n s ta n t. In (d ) w e h a v e th e a d d itio n a l re q u ire m e n t th a t n o n e o f th e p ix e ls o f g (x , y ) c a n b e 0 . A s s u m e fo r c o n v e n ie n c e th a t th e h is to g r a m s a r e n o t n o r m a liz e d , s o th a t, fo r e x a m p le , h f (r k ) is th e n u m b e r o f p ix e ls in f (x , y ) h a v in g in te n s ity le v e l r k . A s s u m e a ls o th a t a ll th e p ix e ls in g (x , y ) h a v e c o n s ta n t v a lu e c . T h e p ix e ls o f b o th im a g e s a r e a s s u m e d to b e p o s itiv e . F in a lly , le t u k d e n o te th e in te n s ity le v e ls o f th e p ix e ls o f th e im a g e s fo r m e d b y a n y o f th e a r ith m e tic o p e r a tio n s g iv e n in th e p r o b le m s ta te m e n t. U n d e r th e p r e c e d in g s e t o f c o n d itio n s , th e h is to g r a m s a r e d e te r m in e d a s fo llo w s : (a ) W e o b ta in h sum (u k ) = h n e n ts o f h sum in te n s ity a x is th e f ( r k a re a re h is to ) fo r th e s s h ifte g ra a ll a m d r m h su m (u k ) o f th e s u m b y le ttin g u k = r k + c , a n d a ls o k . In o th e r w o r d s , th e v a lu e s (h e ig h t) o f th e c o m p o e a s th e c o m p o n e n ts o f h f , b u t th e ir lo c a tio n s o n th e ig h t b y a n a m o u n t c . ( b ) S i m i la r ly , t h e h i s t o g r a m h d iff( u k ) o f t h e d i f f e r e n c e h a s t h e s a m e c o m p o n e n t s a s h f b u t th e ir lo c a tio n s a r e m o v e d le ft b y a n a m o u n t c a s a r e s u lt o f th e s u b tr a c tio n o p e r a tio n . ( c ) F o llo w in g th e s a m e r e a s o n to g r a m h p ro d (u k ) o f th e p r o d u k = c × r k . N o te th a t w h ile h is to g r a m s in (a ) a n d (b ) w a s h p ro d (u k ) w ill b e s p r e a d o u t b (d th c o p r ) F in o s e o m p o e c e d a lly , a s s f h f , b u n e n ts o in g s o lu u m in g th a t t th e ir lo c a t f h d iv ( u k ) w tio n s a re a p in g , th e v a lu e s (h u c t a re th e s a m e th e s p a c in g b e tw n o t a ffe c te d , th e y a n a m o u n t c . c =6 io n ill b p lic 0 , th e c o m p s w ill b e a t u k e c o m p re s s e d a b le if im a g e e ig h ts ) o a s h f , b e e n c o m s p a c in g o n e n ts = r k / c b y a n f (x , y ) f th e u t th p o n e b e tw c o m p e ir lo n ts o e e n c o f h d iv ( u k ) . T h u s , th e a m o u n t e q is c o n s ta n t o n e n ts o f h is c a tio n s a re a t f th e r e s u ltin g o m p o n e n ts o f a re th s p a c in u a l to a ls o . I e s a m e g b e tw e 1 / c . T n th is c a a s e n h e s e 3 3 F ig u r e P 3 .1 4 th e fo u r h is to g r a m s ju s t d is c u s s e d w o u ld e a c h h a v e o n ly o n e c o m p o n e n t. T h e ir lo c a tio n w o u ld b e a ffe c te d a s d e s c r ib e d (a ) th r o u g h (d ). Problem 3.14 (a ) T h e n la r g e r in p o in ts w r ig h t, s o (b ) T a s s u fro m a 3 × o f v a m e n s u m c o n s th e r u m th e ill g th e b e r o f im a g iv e r is h is to g b o u n e o n e to a ra m s d a r y th e r la r g o f th p o ig h e r e t in ts b e tw e e n th e b la c k a n d w h ite r e g io n s is m u c h t. W h e n th e im a g e s a r e b lu r r e d , th e b o u n d a r y n u m b e r o f d iffe r e n t v a lu e s fo r th e im a g e o n th e w o b lu r r e d im a g e s w ill b e d iffe r e n t. o h a n d le th e b o r d e r e ffe c ts , w e s u r r o u n d th e im a g e w ith a b o r d e r o f 0 s . W e m e th a t im a g e is o f s iz e N × N (th e fa c t th a t th e im a g e is s q u a re is e v id e n t th e r ig h t im a g e in th e p r o b le m s ta te m e n t). B lu r r in g is im p le m e n te d b y 3 m a s k w h o s e c o e ffi c ie n t s a r e 1 / 9 . F ig u r e P 3 .1 4 s h o w s th e d iffe r e n t t y p e s lu e s th a t th e b lu r r e d le ft im a g e w ill h a v e (s e e im a g e in th e p r o b le m s ta te t ) . T h e v a lu e s a r e s u m m a r iz e d in T a b le P 3 .1 4 - 1 . It is e a s ily v e r ifi e d t h a t t h e o f th e n u m b e r s o n th e le ft c o lu m n o f th e ta b le is N 2 . A h is to g r a m is e a s ily tr u c te d fr o m th e e n tr ie s in th is ta b le . A s im ila r (te d io u s ) p r o c e d u r e y ie ld s e s u lt s in T a b le P 3 .1 4 - 2 . T a b le P 3 .1 4 - 1 N o . o f P o in ts V a lu e N N2 − 1 0 2 2 / 9 N − 2 3 / 9 4 4 / 9 3 N − 8 6 / 9 1 ( N − 2 ) N2 − 2 C H A P T E R 3 . P R O B L E M S O L U T IO N S 3 4 T a b le P 3 .1 4 - 2 N o . o f P o in ts V a lu e 2 N 2 2 N 2 − 1 4 N 2 8 1 4 N − 1 2 8 9 8 1 6 N − − 1 6 N + 9 8 0 2 / 9 3 / 9 4 / 9 5 / 9 6 / 9 1 2 2 4 2 5 6 + 1 2 8 Problem 3.15 (a th in th th ) C o n s id e r a e 1 / 9 s c a le fa te n s ity v a lu e e re s p o n s e o e r ig h t, it p ic 3 × 3 m a s k c to r), th e s o f p ix e ls f th e m a s k k s u p o n ly fi rs t. B n e t e ffe u n d e r t . H o w e o n e n e e c a u s e c t o f th h e m a s v e r, w h w c o lu a ll e lo k . I e n m n th e c o e ffi c ie n ts a re 1 (w e w p a s s fi lte r o p e r a tio n is t n itia lly , it ta k e s 8 a d d itio n th e m a s k m o v e s o n e p ix e . T h e n e w re s p o n s e c a n b a re o a s to l lo e c ig n o r in d d a ll th p ro d u c c a tio n t o m p u te g e e o d a s R n e w = R o ld − C 1 + C 3 w h e r e C 1 is th e s u m o f p ix e ls u n d e r th e fi r s t c o lu m n o f th e m a s k b e fo r e it w a s m o v e d , a n d C 3 is th e s im ila r s u m in th e c o lu m n it p ic k e d u p a fte r it m o v e d . T h is is th e b a s ic b o x - fi lte r o r m o v in g - a v e r a g e e q u a tio n . F o r a 3 × 3 m a s k it ta k e s 2 a d d itio n s to g e t C 3 (C 1 w a s a lr e a d y c o m p u te d ). T o th is w e a d d o n e s u b tr a c tio n a n d o n e a d d itio n to g e t R n ew . T h u s , a to ta l o f 4 a r ith m e tic o p e r a tio n s a re n e e d e d to u p d a te th e re s p o n s e a fte r o n e m o v e . T h is is a re c u r s iv e p r o c e d u re fo r m o v in g fr o m le ft to r ig h t a lo n g o n e r o w o f th e im a g e . W h e n w e g e t to th e e n d o f a r o w , w e m o v e d o w n o n e p ix e l (th e n a tu re o f th e c o m p u ta tio n is th e s a m e ) a n d c o n tin u e th e s c a n in th e o p p o s ite d ire c tio n . F o r a m a s k o f s iz e n × n , (n − 1 ) a d d itio n s a r e n e e d e d to o b ta in C 3 , p lu s th e s in g le s u b tr a c tio n a n d a d d itio n n e e d e d to o b ta in R n e w , w h ic h g iv e s a to ta l o f (n + 1 ) a r ith m e tic o p e r a tio n s a fte r e a c h m o v e . A b r u te - fo r c e im p le m e n ta tio n w o u ld r e q u ir e n 2 − 1 a d d itio n s a fte r e a c h m o v e . (b ) T h e c o m p u ta tio n a l a d v a n ta g e is A = n 2 − 1 = n + 1 (n + 1 )(n − 1 ) = n − 1 . (n + 1 ) T h e p lo t o f A a s a fu n c tio n o f n is a s im p le lin e a r fu n c tio n s ta r tin g a t A = n = 2 . 1 fo r 3 5 Problem 3.16 ( a ) T h e k e y to s o lv in g th is p r o b le m is to r e c o g n iz e (1 ) th a t th e c o n v o lu tio n r e s u lt a t a n y lo c a tio n (x , y ) c o n s is ts o f c e n te r in g th e m a s k a t th a t p o in t a n d th e n fo r m in g th e s u m o f th e p r o d u c ts o f th e m a s k c o e ffi c ie n ts w ith th e c o r re s p o n d in g p ix e ls in th e im a g e ; a n d (2 ) th a t c o n v o lu tio n o f th e m a s k w ith th e e n tir e im a g e r e s u lts in e v e r y p ix e l in th e im a g e b e in g v is ite d o n ly o n c e b y e v e r y e le m e n t o f t h e m a s k ( i.e ., e v e r y p ix e l is m u lt ip lie d o n c e b y e v e r y c o e ffi c ie n t o f t h e m a s k ) . B e c a u s e th e c o e ffi c ie n ts o f th e m a s k s u m to z e r o , th is m e a n s th a t th e s u m o f th e p r o d u c ts o f th e c o e ffi c ie n ts w ith th e s a m e p ix e l a ls o s u m to z e r o . C a r r y in g o u t th is a r g u m e n t fo r e v e r y p ix e l in th e im a g e le a d s to th e c o n c lu s io n th a t th e s u m o f th e e le m e n ts o f th e c o n v o lu tio n a r r a y a ls o s u m to z e r o . (b is re c o ) T h e o ro ta te d la tin g a r r e la tio n ly d b y 1 n im n im iffe 8 0 ◦ a g e a g e re n c e b e tw e . T h is d o e s w ith a m a s w h o s e e le m e n n o t k w e n t c o a f h o s a n v fe c s e ls o o lu tio n a t th e c o n c o e ffi c ie s u m to z n d c lu n ts e ro c o r r e la tio n is th a t th e m a s k s io n s re a c h e d in (a ), s o c o rs u m to z e r o w ill p r o d u c e a . Problem 3.17 O n e o f th e e a s ie s t w a y s to lo o s u p e r p o s itio n . L e t f (x , y ) a n r e s p e c tiv e ly . A s s u m in g s q u a e x p re s s f (x , y ) a s th e s u m o n o n z e r o p ix e l (in itia lly , w e a s r u n n in g h (x , y ) o v e r f (x , y ) c h (x ,y ) k a t re p e a te d d h (x , y ) d e n re im a g e s o f f a t m o s t N 2 s u m e th a t N a n b e e x p re s f (x ,y ) = h (x ,y ) a p p lic a tio n s o o te th e im a g e s iz e N × N fo im a g e s , e a c h c a n b e in fi n ite s e d a s th e fo llo f 1 (x ,y ) + f a s p a tia l fi lte r is to u s e a n d th e fi lte r fu n c tio n , r c o n v e n ie n c e , w e c a n o f w h ic h h a s o n ly o n e ). T h e n , th e p ro c e s s o f w in g c o n v o lu tio n : f 2 (x ,y ) + ··· + f N 2 (x ,y ) . S u p p o s e fo r illu s tr a tiv e p u r p o s e s th a t f i (x , y ) h a s v a lu e 1 a t its c e n te r, w h ile th e o t h e r p ix e ls a r e v a lu e d 0 , a s d is c u s s e d a b o v e ( s e e F ig . P 3 .1 7 a ) . If h (x , y ) is a 3 × 3 m a s k o f 1 / 9 ’s ( F i g . P 3 . 1 7 b ) , t h e n c o n v o l v i n g h ( x , y ) w i t h f i ( x , y ) w i l l p r o d u c e a n i m a g e w i t h a 3 × 3 a r r a y o f 1 / 9 ’s a t i t s c e n t e r a n d 0 s e l s e w h e r e , a s F i g . P 3 .1 7 ( c ) s h o w s . If h (x , y ) is n o w a p p lie d t o t h is im a g e , t h e r e s u lt in g im a g e w ill b e a s s h o w n in F ig . P 3 .1 7 ( d ) . N o t e t h a t t h e s u m o f t h e n o n z e r o p ix e ls in b o t h F ig s . P 3 .1 7 ( c ) a n d ( d ) is t h e s a m e , a n d e q u a l t o t h e v a lu e o f t h e o r ig in a l p ix e l. T h u s , it is in tu itiv e ly e v id e n t th a t s u c c e s s iv e a p p lic a tio n s o f h (x , y ) w ill ” d iffu s e ” th e n o n z e r o v a lu e o f f i (x , y ) (n o t a n u n e x p e c te d r e s u lt, b e c a u s e h (x , y ) is a b lu r r in g fi lte r ). S in c e th e s u m r e m a in s c o n s ta n t, th e v a lu e s o f th e n o n z e r o e le m e n ts w ill b e c o m e s m a lle r a n d s m a lle r, a s th e n u m b e r o f a p p lic a tio n s o f th e fi lte r in c r e a s e s . T h e o v e r a ll r e s u lt is g iv e n b y a d d in g a ll th e c o n v o lv e d f k (x , y ), fo r k = 1 , 2 , ..., N 2 . 3 6 C H A P T E R 3 . P R O B L E M S O L U T IO N S F ig u r e P 3 .1 7 It is n o te d th a t e v e r y ite r a tio n o f b lu r r in g fu r th e r d iffu s e s th e v a lu e s o u tw a r d ly fr o m th e s ta r tin g p o in t. In th e lim it, th e v a lu e s w o u ld g e t in fi n ite ly s m a ll, b u t, b e c a u s e th e a v e r a g e v a lu e r e m a in s c o n s ta n t, th is w o u ld r e q u ir e a n im a g e o f in fi n ite s p a tia l p r o p o r tio n s . It is a t th is ju n c tio n th a t b o r d e r c o n d itio n s b e c o m e im p o r ta n t. A lth o u g h it is n o t r e q u ir e d in th e p r o b le m s ta te m e n t, it is in s tr u c tiv e to d is c u s s in c la s s th e e ffe c t o f s u c c e s s iv e a p p lic a tio n s o f h (x , y ) to a n im a g e o f fi n ite p r o p o r tio n s . T h e n e t e ffe c t is th a t, b e c a u s e th e v a lu e s c a n n o t d iffu s e o u tw a r d p a s t th e b o u n d a r y o f th e im a g e , th e d e n o m in a to r in th e s u c c e s s iv e a p p lic a tio n s o f a v e r a g in g e v e n tu a lly o v e r p o w e r s th e p ix e l v a lu e s , d r iv in g th e im a g e to z e r o in t h e lim it . A s im p le e x a m p le o f t h is is g iv e n in F ig . P 3 .1 7 ( e ) , w h ic h s h o w s a n a r r a y o f s iz e 1 × 7 th a t is b lu r r e d b y s u c c e s s iv e a p p lic a tio n s o f th e 1 × 3 m a s k h ( y ) = 13 [ 1 , 1 , 1 ] . W e s e e t h a t , a s l o n g a s t h e v a l u e s o f t h e b l u r r e d 1 c a n d i f f u s e o u t, th e s u m , S , o f th e r e s u ltin g p ix e ls is 1 . H o w e v e r, w h e n th e b o u n d a r y is m e t, 3 7 a n a tre a d ia t b o u g in s 1 / (3 s s u m p tio n m u s t b e m a d e re g a rd in g h o te d . H e r e , w e u s e d th e c o m m o n ly m a d e ly p a s t th e b o u n d a r y a r e 0 . T h e m a s n d a r y , h o w e v e r. In th is e x a m p le , w e s e to d e c r e a s e w ith s u c c e s s iv e a p p lic a tio )n w o u ld o v e r p o w e r th e s u m o f th e p ix w m a s k o p e e a s s u m p tio k o p e r a tio n e th a t th e s u n s o f th e m a e l v a lu e s , y ie r a tio n s o n th e b o rd e r a re n th a t p ix e l v a lu e im m e d o e s n o t g o b e y o n d th e m o f th e p ix e l v a lu e s b e s k . In th e lim it, th e te r m ld in g a n a r r a y o f 0 s . Problem 3.18 ( a ) T h e r e a r e n 2 p o in ts in a n n × n m e d ia n fi lte r m a s k . B e c a u s e n is o d d , th e m e d ia n v a lu e , ζ , is s u c h th a t th e r e a r e (n 2 − 1 )/ 2 p o in ts w ith v a lu e s le s s th a n o r e q u a l to ζ a n d th e s a m e n u m b e r w ith v a lu e s g r e a te r th a n o r e q u a l to ζ . H o w e v e r, b e c a u s e th e a r e a A (n u m b e r o f p o in ts ) in th e c lu s te r is le s s th a n o n e h a lf n 2 , a n d A a n d n a r e in te g e r s , it fo llo w s th a t A is a lw a y s le s s th a n o r e q u a l to (n 2 − 1 )/ 2 . T h u s , e v e n in th e e x tr e m e c a s e w h e n a ll c lu s te r p o in ts a r e e n c o m p a s s e d b y th e fi lte r m a s k , th e r e a r e n o t e n o u g h p o in ts in th e c lu s te r fo r a n y o f th e m to b e e q u a l to th e v a lu e o f th e m e d ia n (r e m e m b e r, w e a r e a s s u m in g th a t a ll c lu s te r p o in ts a r e lig h te r o r d a r k e r th a n th e b a c k g r o u n d p o in ts ). T h e r e fo r e , if th e c e n te r p o in t in th e m a s k is a c lu s te r p o in t, it w ill b e s e t to th e m e d ia n v a lu e , w h ic h is a b a c k g r o u n d s h a d e , a n d th u s it w ill b e “ e lim in a te d ” fr o m th e c lu s te r. T h is c o n c lu s io n o b v io u s ly a p p lie s to th e le s s e x tr e m e c a s e w h e n th e n u m b e r o f c lu s te r p o in ts e n c o m p a s s e d b y th e m a s k is le s s th a n th e m a x im u m s iz e o f th e c lu s te r. ( b ) F o r th e c o n c lu s io n r e a c h e d in (a ) to h o ld , th e n u m b e r o f p o in ts th a t w e c o n s id e r c lu s te r (o b je c t) p o in ts c a n n e v e r e x c e e d (n 2 − 1 )/ 2 . T h u s , tw o o r m o r e d iffe r e n t c lu s te r s c a n n o t b e in c lo s e e n o u g h p r o x im ity fo r th e fi lte r m a s k to e n c o m p a s s p o in ts fr o m m o r e th a n o n e c lu s te r a t a n y m a s k p o s itio n . It th e n fo llo w s th a t n o tw o p o in ts fr o m d iffe r e n t c lu s te r s c a n b e c lo s e r th a n th e d ia g o n a l d im e n s io n o f th e m a s k m in u s o n e c e ll (w h ic h c a n b e o c c u p ie d b y a p o in t fr o m o n e o f th e c lu s te r s ). A s s u m in g a g r id s p a c in g o f 1 u n it, th e m in im u m d is ta n c e b e tw e e n p 2 (n − 1 ). In o th e r a n y tw o p o in ts o f d iffe r e n t c lu s te r s th e n m u s t g r e a te r th a n w o r d s , th e s e p o in ts m u s t b e s e p a r a te d b y a t le a s t th e d is ta n c e s p a n n e d b y n − 1 c e lls a lo n g th e m a s k d ia g o n a l. Problem 3.19 ( a ) N u m e r ic a lly s o r t th e n 2 v a lu e s . T h e m e d ia n is ζ = [(n 2 + 1 )/ 2 ]- th la r g e s t v a lu e . C H A P T E R 3 . P R O B L E M S O L U T IO N S 3 8 ( b ) O n c e th e v a lu e s h a v e b e e n s o r te d o n e tim e , w e s im p ly d e le te th e v a lu e s in th e tr a ilin g e d g e o f th e n e ig h b o r h o o d a n d in s e r t th e v a lu e s in th e le a d in g e d g e in th e a p p r o p r ia te lo c a tio n s in th e s o r te d a r r a y . Problem 3.20 (a ) T h e m o s t e x t a 3 - p ix e l g a p , a lo a c o m p le te ly b la m a s k s iz e u p is T h u s , th e s m a lle (b ) T h e s m a o n ly tw o p ix n a r y , lik e th A m in , a n d t h le s s th a n B . c re a te o n e b re m n g a n k fi g u a s t m e c a s e is w th in s e g m e ld . S in c e ra n te e d to a s k th a t w h e n th e m a s k e n t, in w h ic h th is is k n o w n e n c o m p a s s ill d o th e jo b is p o c a s e to b e s o m e is a 5 s itio a 3 × th e o f t × 5 a n e d o n th 3 m a s k w la r g e s t g a h e p ix e ls v e r a g in g lle s t a v e r a g e v a lu e p r o d u c e d b y th e m a s k is e ls o f th e s e g m e n t. T h is a v e r a g e v a lu e is a g r e r e s t o f th e s e g m e n t p ix e ls . D e n o te th e s m a e b in a r y v a lu e s o f p ix e ls in th e th in s e g m e n t T h e n , s e ttin g th e b in a r iz in g th r e s h o ld s lig h tly in a r y p ix e l o f v a lu e B in th e c e n te r o f th e m a s e c e n te o u ld e n p , th e n in th e m a s k . w h e n it a y - s c a le lle s t a v e b y B . C s m a lle r k . r p ix e l o f c o m p a s s e x t (o d d ) s e g m e n t. e n c o m p a s s e s v a lu e , n o t b ir a g e v a lu e b y le a r ly , A m in i s t h a n A m in w i ll Problem 3.21 F a h e q a r o m F ig . 3 .3 3 w e k n o w t h a t t h e v e r t ic a l b a r s a r e 5 p ix e ls w id e , 1 0 0 p ix e ls h ig h , n d th e ir s e p a r a tio n is 2 0 p ix e ls . T h e p h e n o m e n o n in q u e s tio n is r e la te d to th e o r iz o n ta l s e p a r a tio n b e tw e e n b a r s , s o w e c a n s im p lify th e p r o b le m b y c o n s id r in g a s in g le s c a n lin e th r o u g h th e b a r s in th e im a g e . T h e k e y to a n s w e r in g th is u e s tio n lie s in th e fa c t th a t th e d is ta n c e (in p ix e ls ) b e tw e e n th e o n s e t o f o n e b a r n d th e o n s e t o f th e n e x t o n e (s a y , to its r ig h t) is 2 5 p ix e ls . C o n s id e r t h e s c a n lin e s h o w n in F ig . P 3 .2 1 . A ls o s h o w n is a c r o s s s e c t io n o f a 2 5 × 2 5 m a s k . T h e r e s p o n s e o f th e m a s k is th e a v e r a g e o f th e p ix e ls th a t it e n c o m p a s s e s . W e n o te th a t w h e n th e m a s k m o v e s o n e p ix e l to th e r ig h t, it lo s e s o n e v a lu e o f th e v e r tic a l b a r o n th e le ft, b u t it p ic k s u p a n id e n tic a l o n e o n th e r i g h t , s o t h e r e s p o n s e d o e s n ’t c h a n g e . I n f a c t , t h e n u m b e r o f p i x e l s b e l o n g i n g to th e v e r tic a l b a r s a n d c o n ta in e d w ith in th e m a s k d o e s n o t c h a n g e , r e g a r d le s s o f w h e r e th e m a s k is lo c a te d (a s lo n g a s it is c o n ta in e d w ith in th e b a r s , a n d n o t n e a r th e e d g e s o f th e s e t o f b a rs ). T h e fa c t th a t th e n u m b e r o f b a r p ix e ls u n d e r th e m a s k d o e s n o t c h a n g e is d u e to th e p e c u lia r s e p a r a tio n b e tw e e n b a r s a n d th e w id th o f th e lin e s in r e la tio n to th e 2 5 - p ix e l w id th o f th e m a s k T h is c o n s ta n t re s p o n s e is th e re a s o n w h y n o w h ite g a p s a r e s e e n in th e im a g e s h o w n in th e p r o b le m s ta te m e n t. N o te th a t th is c o n s ta n t re s p o n s e d o e s n o t h a p p e n w ith th e 2 3 × 2 3 o r th e 4 5 × 4 5 m a s k s b e c a u s e th e y a re n o t ” s y n c h r o n iz e d ” w ith th e w id th o f th e b a r s a n d th e ir s e p a r a tio n . 3 9 F ig u r e P 3 .2 1 Problem 3.22 T h e re a re a t m o s t q 2 p o in ts in th e a re a in w h ic h w e w a n t to re d u c e th e in te n s ity le v e l o f e a c h p ix e l to o n e - te n th its o r ig in a l v a lu e . C o n s id e r a n a v e r a g in g m a s k o f s iz e n × n e n c o m p a s s in g th e q × q n e ig h b o r h o o d . T h e a v e r a g in g m a s k h a s n 2 p o in ts o f w h ic h w e a r e a s s u m in g th a t q 2 p o in ts a r e fr o m th e o b je c t a n d th e r e s t fr o m th e b a c k g r o u n d . N o te th a t th is a s s u m p tio n im p lie s s e p a r a tio n b e tw e e n o b je c ts th a t, a t a m in im u m , is e q u a l to th e a r e a o f th e m a s k a ll a r o u n d e a c h o b je c t. T h e p r o b le m b e c o m e s in tr a c ta b le u n le s s th is a s s u m p tio n is m a d e . T h is c o n d itio n w a s n o t g iv e n in th e p r o b le m s ta te m e n t o n p u r p o s e in o r d e r to fo r c e th e s tu d e n t to a r r iv e a t th a t c o n c lu s io n . If th e in s tr u c to r w is h e s to s im p lify th e p r o b le m , th is s h o u ld th e n b e m e n tio n e d w h e n th e p r o b le m is a s s ig n e d . A fu r th e r s im p lifi c a tio n is to te ll th e s tu d e n ts th a t th e in te n s ity le v e l o f th e b a c k g r o u n d is 0 . L e t B r e p r e s e n t th e in te n s ity le v e l o f b a c k g r o u n d p ix e ls , le t a i d e n o te th e in te n s ity le v e ls o f p o in ts in s id e th e m a s k a n d o i th e le v e ls o f th e o b je c ts . In a d d itio n , le t S a d e n o te th e s e t o f p o in ts in th e a v e r a g in g m a s k , S o th e s e t o f p o in ts in th e o b je c t, a n d S b th e s e t o f p o in ts in th e m a s k th a t a r e n o t o b je c t p o in ts . T h e n , th e re s p o n s e o f th e a v e r a g in g m a s k a t a n y p o in t o n th e im a g e c a n b e w r itte n a s R = 1 a 2 n a ⎡ 2 n ⎡ 2 n = q n ⎤ o o ⎢q ⎣ q 1 = i a ⎢ ⎣ 1 = 2 S i j 2 S Q + a a o 2 o 2 o 2 2 + j j 1 n 2 2 S j k ⎤ 2 S b 2 ⎥ ⎦+ − q ⎥ ⎦ ⎡ 1 2 n o (n k 2 ⎤ ⎢ ⎣ a a )B k 2 S b k ⎥ ⎦ C H A P T E R 3 . P R O B L E M S O L U T IO N S 4 0 w h e a v e r o f th th a n re a g e o Q e m n d e n o te v a lu e o a s k a t a e -te n th s th e a v f o b je c t n y p o in Q max , o q n e r a g e v a lu e o f o b je c t p o in ts . L e t th e m a x im u m e x p e c te d p o in ts b e d e n o te d b y Q m a x . T h e n w e w a n t th e re s p o n s e t o n th e o b je c t u n d e r th is m a x im u m c o n d itio n to b e le s s r 2 2 Q m a x 1 + n 2 (n 2 − q 2 m a x − B ) 1 < )B 1 0 Q m a x fr o m w h ic h w e g e t th e re q u ire m e n t 1 0 (Q n > q fo r th e s ity is b y th e th is a n m in im 0 , th e n in s tr u c s w e r fo u m s iz e o f th e m in im to r, o r th e s llo w s a lm o th e u m tu d s t b a v e m a e n t y in (Q ra s k m s p 1 / 2 − 1 0 B ) m a x g in g m a s k . N o te th a t if th e b a c k g r o u n d in te n p 1 0 q . If th is w a s a fa c t s p e c ifi e d s iz e is n < a d e th is a s s u m p tio n fr o m th e b e g in n in g , th e n e c tio n . Problem 3.23 T h e s tu d e n t s h o u ld r e a liz e th a t b o th th e L a p la c ia n a n d th e a v e r a g in g p r o c e s s a r e lin e a r o p e r a tio n s , s o it m a k e s n o d iffe r e n c e w h ic h o n e is a p p lie d fi r s t. Problem 3.24 T h e L a p la c ia n o p e r a to r is d e fi n e d a s 2 r 2 @ f = f 2 @ x 2 @ + f 2 @ y fo r th e u n r o ta te d c o o rd in a te s , a n d a s 2 r f = 2 @ @ x f 02 + @ @ y 2 f 02 . fo r r o ta te d c o o rd in a te s . It is g iv e n th a t x = x 0 c o s θ − y 0 s in θ a n d y = x 0 s in θ + y 0 c o s θ w h e r e θ is th e a n g le o f r o ta tio n . W e w a n t to s h o w th a t th e r ig h t s id e s o f th e fi r s t tw o e q u a tio n s a r e e q u a l. W e s ta r t w ith @ f = @ x 0 = @ f @ x @ f @ y + @ x @ x 0 @ y @ x 0 @ f @ f c o s θ + s in θ . @ x @ y 4 1 0 T a k in g th e p a r tia l d e r iv a tiv e o f th is e x p re s s io n a g a in w ith re s p e c t to x 2 @ f @ x 02 2 @ = f 2 c o s 2 θ + @ x @ @ x @ f @ y @ f @ x @ s in θ c o s θ + @ y 2 @ c o s θ s in θ + y ie ld s f 2 @ y s in 2 θ . N e x t, w e c o m p u te @ f @ y @ x @ y @ f @ y @ y @ y 0 @ f f s in θ + c o s θ . x @ y @ f @ x @ = − @ = 0 + 0 T a k in g th e d e r iv a tiv e o f th is e x p re s s io n a g a in w ith re s p e c t to y @ @ y 2 f 02 = 2 @ @ x f 2 s in 2 θ − @ @ x @ f @ y @ c o s θ s in θ − @ f @ x @ y 0 g iv e s s in θ c o s θ + 2 @ @ y f 2 c o s 2 θ . A d d in g th e tw o e x p r e s s io n s fo r th e s e c o n d d e r iv a tiv e s y ie ld s @ @ x 2 f 02 + @ @ y 2 f 02 = 2 @ @ x f 2 + 2 @ @ y f 2 w h ic h p r o v e s th a t th e L a p la c ia n o p e r a to r is in d e p e n d e n t o f r o ta tio n . Problem 3.25 T h e L a p la c ia n m a s k w ith a − 4 in th e c e n te r p e r fo r m s a n o p e r a tio n p r o p o r tio n a l to d iffe re n tia tio n in th e h o r iz o n ta l a n d v e r tic a l d ire c tio n s . C o n s id e r fo r a m o m e n t a 3 × 3 “ L a p la c ia n ” m a s k w ith a − 2 in th e c e n te r a n d 1 s a b o v e a n d b e lo w th e c e n te r. A ll o th e r e le m e n ts a r e 0 . T h is m a s k w ill p e r fo r m d iffe r e n tia tio n in o n ly o n e d ir e c tio n , a n d w ill ig n o r e in te n s ity tr a n s itio n s in th e o r th o g o n a l d ir e c tio n . A n im a g e p r o c e s s e d w ith s u c h a m a s k w ill e x h ib it s h a r p e n in g in o n ly o n e d ir e c tio n . A L a p la c ia n m a s k w ith a - 4 in th e c e n te r a n d 1 s in th e v e r tic a l a n d h o r iz o n ta l d ir e c tio n s w ill o b v io u s ly p r o d u c e a n im a g e w ith s h a r p e n in g in b o th d ir e c tio n s a n d in g e n e r a l w ill a p p e a r s h a r p e r th a n w ith th e p r e v io u s m a s k . S im ila r ly , a n d m a s k w ith a − 8 in th e c e n te r a n d 1 s in th e h o r iz o n ta l, v e r tic a l, a n d d ia g o n a l d ir e c tio n s w ill d e te c t th e s a m e in te n s ity c h a n g e s a s th e m a s k w ith th e − 4 in th e c e n te r b u t, in a d d itio n , it w ill a ls o b e a b le to d e te c t c h a n g e s a lo n g th e d ia g o n a ls , th u s g e n e r a lly p r o d u c in g s h a r p e r - lo o k in g r e s u lts . C H A P T E R 3 . P R O B L E M S O L U T IO N S 4 2 F ig u r e P 3 .2 6 Problem 3.26 (a ) T h e s iz e a n d c o e ffi c ie n ts o f th e 3 × d e fi n itio n o f th e L a p la c ia n g iv e n in E o f c o e ffi c ie n ts (a n d th u s s iz e o f th e m th e s e c o n d d e r iv a tiv e . A la r g e r “ L a p la p le m e n tin g a s e c o n d d e r iv a tiv e , s o w e s h a r p e r r e s u lts . In fa c t, a s e x p la in e d in 3 L a p la c ia n m a s q . ( 3 .6 - 6 ) . In o a s k ) is a d ire c t r c ia n - lik e ” m a s k c a n n o t e x p e c t t p a r t (b ), ju s t th e k c o m e d ir e c tly fr o m th th e r w o rd s , th e n u m b e e s u lt o f th e d e fi n itio n o w o u ld n o lo n g e r b e im h a t in g e n e r a l it w ill g iv o p p o s ite o c c u r s . e r f e ( b ) In g e n e r a l, in c r e a s in g th e s iz e o f th e “ L a p la c ia n - lik e ” m a s k p r o d u c e s b lu r r in g . T o s e e w h y th is is s o , c o n s id e r a n im a g e c o n s is tin g o f tw o v e r tic a l b a n d s , a b la c k b a n d o n th e le ft a n d a w h ite b a n d o n th e r ig h t, w ith th e tr a n s itio n b e tw e e n th e b a n d s o c c u r r in g th r o u g h th e c e n te r o f th e im a g e . T h a t is , th e im a g e h a s a s h a r p v e r t ic a l e d g e t h r o u g h it s c e n t e r. F r o m F ig . 3 .3 6 w e k n o w t h a t a s e c o n d d e r iv a tiv e s h o u ld p r o d u c e a d o u b le e d g e in th e r e g io n o f th e v e r tic a l e d g e w h e n a 3 × 3 L a p la c ia n m a s k is c e n te r e d o n th e e d g e . A s th e c e n te r o f th e m a s k m o v e s m o r e th a n tw o p ix e ls o n e ith e r s id e o f th e e d g e th e e n tir e m a s k w ill e n c o m p a s s a c o n s ta n t a r e a a n d its r e s p o n s e w o u ld b e z e r o , a s it s h o u ld . H o w e v e r, s u p p o s e th a t th e m a s k is m u c h la r g e r. A s its c e n te r m o v e s th r o u g h , s a y , th e b la c k (0 ) a r e a , o n e h a lf o f th e m a s k w ill b e to ta lly c o n ta in e d in th a t a r e a . H o w e v e r, d e p e n d in g o n its s iz e , p a r t o f th e m a s k w ill b e c o n ta in e d in th e w h ite (2 5 5 ) a r e a . T h e s u m o f p r o d u c ts w ill th e r e fo r e b e d iffe r e n t fr o m 0 . T h is m e a n s th a t th e r e w ill b e a r e s p o n s e in a n a r e a w h e r e th e r e s p o n s e s h o u ld h a v e b e e n 0 b e c a u s e t h e m a s k is c e n t e r e d o n a c o n s t a n t a r e a . F ig u r e P 3 .2 6 s h o w s t h e s e e ffe c t s . T h e 4 3 0 0 0 0 1 0 0 0 0 1 9 17 (b) (a) F ig u r e P 3 .2 7 fi g u re o n r e s u lt o f u s h o w s th e a n d 1 2 5 × m a s k s iz e th e to p le ft is th e b a n d ju s in g a 3 × 3 L a p la c ia n m a r e s u lts o f u s in g “ L a p la c ia 1 2 5 , r e s p e c tiv e ly . T h e p r is e v id e n t in th e s e r e s u lts s t s k n o g . m w lik re e n tio n ith a n e ” m a s s s iv e ly e d a n 8 in t k s o f in c re d h e s iz a s th e c e e s in g fi n t 1 5 b g u re n e r. T h e × 1 5 , 3 lu r r in g e x t o t 5 × a s to h e r 3 5 , a r it is th e fi g u re s 7 5 × 7 5 , e s u lt o f Problem 3.27 W it h r e fe r e n c e t o E q s . ( 3 .6 - 8 ) a n d ( 3 .6 - 9 ) , a n d u s in g k fo llo w in g e q u a tio n fo r u n s h a r p m a s k in g : g (x ,y ) 1 w e c a n w r ite th e f (x , y ) − f¯ (x , y ) 2 f ( x , y ) − f¯ ( x , y ) = f (x ,y ) + = C o n v o lv in g f (x , y ) w ith th e in g f (x ,y ) w ith th e m a s k in o p e r a tio n s a r e lin e a r, w e c a n e q u a tio n th a t u s in g tw o m a s 3 .3 2 ( a ) p r o d u c e s t h e c o m p o w ith f (x ,y ) p r o d u c e s g (x ,y ) = m a s F ig . u s e k s o s ite , th e k in 3 .3 2 s u p f th e m a s u n s F ig . P 3 .2 7 ( a ) p r o d u c e ( a ) p r o d u c e s f¯ ( x , y ) . T e r p o s itio n , a n d w e s e e fo r m in F ig . P 3 .2 7 ( a ) a k in F ig . P 3 .2 7 ( b ) . C o h a r p r e s u lt. s f h e fro n d n v (x n , m th o lv ,y b e th e in ). C o n v o lv c a u s e th e s e e p re c e d in g m a s k in F ig . g th is m a s k Problem 3.28 C o n s id e r th e fo llo w in g e q u a tio n : f (x ,y ) − r 2 f (x ,y ) = f (x ,y ) − f (x + 1 ,y ) + f (x − 1 ,y ) + f (x ,y + 1 ) = + f (x ,y − 1 ) − 4 f (x ,y ) 6 f (x ,y ) − f (x + 1 ,y ) + + f (x ,y − 1 ) + f (x ,y ) f (x − 1 ,y ) + f (x ,y + 1 ) C H A P T E R 3 . P R O B L E M S O L U T IO N S 4 4 = = w h te r T re fa c e r e d a t to e f a t in g rs , (x ,y ) d (x ,y ) a th e c o w e m a y e n n d n s w 1 .2 f (x , y )− 1 f (x + 1 ,y ) + f (x − 1 ,y ) + 5 + f (x ,y − 1 ) + f (x ,y ) 5 1 .2 f (x , y ) − 5 r ig h a lity n in th e L t s fa E q a p f (x ,y ) o te s th e a v e r a g e o f f (x ,y ) in a p re d e fi n e d n e ig h b o r h o o d c e n in c lu d in g th e c e n te r p ix e l a n d its fo u r im m e d ia te n e ig h b o r s . ta n ts in th e la s t lin e o f th e a b o v e e q u a tio n a s p r o p o r tio n a lity r ite 2 f (x ,y ) − r T h e tio n g iv e in g f (x ,y + 1 ) id e o f th is c to rs to b s . ( 3 .6 - 8 ) la c ia n fr o e q u a tio e o f th e a n d ( 3 .6 m a n im f (x ,y ) n is re s a m e -9 ). T a g e is c o fo h u p r f (x ,y ) − f (x ,y ). g n iz e d w ith in r m a s th e d e s , it h a s b e e n o p o r tio n a l to th fi n d e u n e ju s t itio n m o n s s h a rp -m o f tra m e n t u n s te d a s k 2 1 / 2 io n e d p r o p o rh a r p m a s k in g th a t s u b tra c tin g . Problem 3.29 ( a ) F r o m P r o b le m 3 .2 4 , f (x , y ) @ f = @ x 0 a n d @ f @ y 0 @ f c o s θ + @ x @ f s in θ @ y @ f s in θ + @ x = − @ f c o s θ @ y fr o m w h ic h it fo llo w s th a t 2 @ f @ x @ f @ y + 0 o r @ f @ x 0 2 @ f @ y + 2 2 0 1 / 2 @ f @ y + @ f @ x = 0 2 @ f @ x = 2 + @ f @ y 2 . T h u s , w e s e e th a t th e m a g n itu d e o f th e g r a d ie n t is a n is o tr o p ic o p e r a to r. ( b ) F r o m E q . ( 3 .6 - 1 0 ) , ( 3 .6 - 1 2 ) , a n d t h e p r e c e d in g r e s u lt s , jG x j = @ f @ x G y = @ f @ y , 4 5 jG 0 x @ f @ x j = a n d G C l e a r l y , jG x 0 j+ G y 0 y 6= j G 0 x = @ f @ y j+ G = 0 @ f s in θ @ y @ f c o s θ + @ x = 0 @ f c o s θ @ y @ f s in θ + @ x − , . . y Problem 3.30 It is g iv e n th a t th e r a n g e o f illu m in a tio n s ta y s in th e lin e a r p o r tio n o f th e c a m e r a r e s p o n s e r a n g e , b u t n o v a lu e s fo r th e r a n g e a r e g iv e n . T h e fa c t th a t im a g e s s ta y in th e lin e a r r a n g e im p lie s th a t im a g e s w ill n o t b e s a tu r a te d a t th e h ig h e n d o r b e d r iv e n in th e lo w e n d to s u c h a n e x te n t th a t th e c a m e r a w ill n o t b e a b le to r e s p o n d , th u s lo s in g im a g e in fo r m a tio n ir r e tr ie v a b ly . T h e o n ly w a y to e s ta b lis h a b e n c h m a r k v a lu e fo r illu m in a tio n is w h e n th e v a r ia b le (d a y lig h t) illu m in a tio n is n o t p r e s e n t. L e t f 0 (x , y ) d e n o te a n im a g e ta k e n u n d e r a r tifi c ia l illu m in a tio n o n ly , w it h n o m o v in g o b je c t s ( e .g ., p e o p le o r v e h ic le s ) in t h e s c e n e . T h is b e c o m e s th e s ta n d a r d b y w h ic h a ll o th e r im a g e s w ill b e n o r m a liz e d . T h e r e a r e n u m e r o u s w a y s to s o lv e th is p r o b le m , b u t th e s tu d e n t m u s t s h o w a w a r e n e s s th a t a r e a s in th e im a g e lik e ly to c h a n g e d u e to m o v in g o b je c ts s h o u ld b e e x c lu d e d fr o m th e illu m in a tio n - c o r r e c tio n a p p r o a c h . O n e w a y is to s e le c t v a r io u s r e p r e s e n ta tiv e s u b a r e a s o f f 0 (x , y ) n o t lik e ly to b e o b s c u r e d b y m o v in g o b je c ts a n d c o m p u te th e ir a v e r a g e in te n s itie s . W e th e n s e le c t th e m in im u m a n d m a x im u m o f a ll th e in d iv id u a l a v e r a g e v a lu e s , d e n o te d b y , f m in a n d f m a x . T h e o b je c t i v e t h e n i s t o p r o c e s s a n y i n p u t i m a g e , f ( x , y ) , s o t h a t i t s m i n i m u m a n d m a x i m u m w i ll b e e q u a l t o f m in a n d f m a x , r e s p e c t i v e ly . T h e e a s ie s t w a y to d o th is is w ith a lin e a r tr a n s fo r m a tio n fu n c tio n o f th e fo r m f (x ,y ) = a f (x ,y ) + b o u t w h e r e f o u t is th e s c a le d o u tp u t im a g e . It is e a s ily v e r ifi e d th a t th e o u tp u t im a g e w ill h a v e th e r e q u ir e d m in im u m a n d m a x im u m v a lu e s if w e c h o o s e a = f f − m a x − f m a x f m in m in a n d b = w h e re f m a x a n d f m in f m in f f m a x m a x f − − f m a x f m in m in a r e th e m a x im u m a n d m in im u m v a lu e s o f th e in p u t im a g e . C H A P T E R 3 . P R O B L E M S O L U T IO N S 4 6 N o te th a t th e k e y a s s u m th e lin e a r o p e r a tin g r a n g e tie s a re n o t a n is s u e . A n o t p r is e a r e la tiv e ly s m a ll a r e o b je c ts w o u ld o v e r p o w e r t n o t m a k e s e n s e . If th e s tu to g r a m e q u a liz a tio n ), h e / s tio n s . p tio n b e h in d th is m e th o d is th a t a ll im a o f th e c a m e r a , th u s s a tu r a tio n a n d o th h e r im p lic it a s s u m p tio n is th a t m o v in g a in th e fi e ld o f v ie w o f th e c a m e r a , o t h e s c e n e a n d th e v a lu e s o b ta in e d fr o m d e n t s e le c ts a n o th e r a u to m a te d a p p r o h e m u s t d is c u s s th e s a m e o r s im ila r ty p g e s s ta y w ith in e r n o n lin e a r io b je c ts c o m h e r w is e th e s e f 0 (x , y ) w o u ld a c h ( e .g ., h is e s o f a s s u m p - Problem 3.31 S u b s t it u t in g d ir e c t ly in t o E q . ( 3 .8 - 9 ) 2 b − c − b c 2 a 1 = a − a − a 2 = b = 1 2 a + c . 2 Problem 3.32 A ll fi g u r e s c a n b e c o n s tr u c te d u s in g v a r io u s m e m b e r s h ip fu n c tio n s fr o m F ig . 3 .4 6 a n d t h e d e fi n it io n o f fu z z y u n io n ( t h e p o in t w is e m a x im a b e t w e e n t h e c u r v e s ) , a s fo llo w s . ( a ) T h e fi g u r e in p a r t (a ) o f th e p r o b le m s ta te m e n t c a n b e c o n s tr u c te d u s in g tw o t r a p e z o id a l fu n c t io n s [F ig s . 3 .4 6 ( b ) ] a n d o n e t r ia n g u la r fu n c t io n [F ig . 3 .4 6 ( a ) ], a s F ig . P 3 .3 2 ( a ) s h o w s . ( b ) T h e fi g u r e in p a r t (b ) o f th e p r o b le m s ta te m e n t c a n b e c o n s tr u c te d u s in g tw o tr a p e z o id a l fu n c tio n s in w h ic h th e o n e o n th e r ig h t te r m in a te s v e r tic a lly , a s F ig . P 3 .3 2 ( b ) s h o w s . ( c ) T h e fi g u r e in p a r t (c ) o f th e p r o b le m s ta te m e n t c a n b e c o n s tr u c te d u s in g tw o t r ia n g u la r fu n c t io n s , a s F ig . P 3 .3 2 ( c ) s h o w s . Problem 3.33 T b o a h e o r h n e 3 × th ic k n e o o d in c p ix e l- th 3 n e ig h s s o f th re a s e s . ic k s tr a b o r h o o e b o W e ig h t d is u n d a r ie s s u p p o r t t b la c k lin e u s e d , a n y in c h is r u n e re a c o n n ig h s e s a s a th e s iz n c lu s io n w ith a in g v e r tic a lly th b o r h o o d s w h o s e o f th e fi lte r in g n e ig h n e x a m p le . C o n s id e r a r o u g h a w h ite im a g e . If e c e n te rs a re m o re th a n 4 7 1 1 1 .5 .5 .5 0 a - c a - b a a + b a + c 1 z 0 a a +c b (a) b +c d 1 z 0 (b) a - b a =.5 a +b 1 z (c) F ig u r e P 3 .3 2 tw o p ix e ls a w a y fr o m c e n te r p ix e l w ill b e d lo c a tio n , if w e in c r e a b e e n c o m p a s s e d a n d d e s ig n a te d a b o u n d a th e s iz e o f th e n e ig h b fr o m th e lin e b e fo r e t is , th e th ic k n e s s o f th h o o d in c re a s e s . th e lin e w ill p r o d u c e d iffe r e n c e s w ith v a lu e s o f z e r o a n d th e e s ig n a te d a r e g io n p ix e l. L e a v in g th e c e n te r p ix e l a t s a m e s e th e s iz e o f th e n e ig h b o r h o o d to , s a y , 5 × 5 , th e lin e w ill n o t a ll d iffe r e n c e s b e z e r o , s o th e c e n te r p ix e l w ill n o w b e r y p o in t, th u s in c re a s in g th e th ic k n e s s o f th e b o u n d a r y . A s o r h o o d in c r e a s e s , w e w o u ld h a v e to b e fu r th e r a n d fu r th e r h e c e n te r p o in t c e a s e s to b e c a lle d a b o u n d a r y p o in t. T h a t e b o u n d a r y d e te c te d in c re a s e s a s th e s iz e o f th e n e ig h b o r- Problem 3.34 ( a ) If th e in te n s ity o f th e c e n te r p ix e l o f a 3 × 3 r e g io n is la r g e r th a n th e in te n s ity o f a ll its n e ig h b o r s , th e n d e c r e a s e it. If th e in te n s ity is s m a lle r th a n th e in te n s ity o f a ll its n e ig h b o r s , th e n in c r e a s e it. E ls e , d o n o t n o th in g . ( b ) R u le s IF d 2 is P O A N D d IF d 2 is N E A N D d E L S E v is Z R . N o te : In r u le 1 , a ll (z 5 ) is le s s th a n th z 50 m o r e p o s i t i v e s te r p ix e l c lo s e r to d iffe re n c e s a re n e n o a c tio n b e c a u s e s h o u ld b e z e r o (k e (c re o v fu ) T s p e r n c h e e c t la p tio 4 4 is P O A N D d is N E A N D d 6 6 is P O A N D d is N E A N D d 8 8 is P O T H E N v is P O is N E T H E N v is N E p o s itiv e d iffe r e n c e s m e a n th a t th e in te n s ity o f th e n o is e p u ls e a t o f a ll it s 4 - n e ig h b o r s . T h e n w e ’ll w a n t t o m a k e t h e o u t p u t o th a t w h e n it is a d d e d to z 5 it w ill b r in g th e v a lu e o f th e c e n th e v a lu e s o f its n e ig h b o r s . T h e c o n v e r s e is tr u e w h e n a ll th e g a tiv e . A m ix tu r e o f p o s itiv e a n d n e g a tiv e d iffe r e n c e s c a lls fo r th e c e n te r p ix e l is n o t a c le a r s p ik e . In th is c a s e th e c o r r e c tio n e p in m in d th a t z e r o is a fu z z y s e t to o ). m e m b e r s h ip fu n c tio n s P O a n d N E a r e tr ia n g le s fr o m − 1 to 0 a n d 0 to 1 , iv e ly . M e m b e r s h ip fu n c tio n Z R is a ls o a tr ia n g le . It is c e n te r e d o n 0 a n d s t h e o t h e r tw o s lig h t ly . F ig u r e P 3 .3 4 ( a ) s h o w s t h e s e t h r e e m e m b e r s h ip n s . C H A P T E R 3 . P R O B L E M S O L U T IO N S 4 8 (d ) o ffi = o b t F ig c e n 2 ,4 a in u re te r ,6 ,8 th e P 3 e le . T n e .3 4 ( b ) s h o w s in g m e n ts in th e 3 × 3 h e v a lu e v in th e c w i n t e n s i t y , z 50 , i n r a p h ic f n e ig h b e n te r is th a t lo c o r o r th a t m h o e c io n th e th r e e r u le s fr o m p a r t (b ). T h e o d s a re d iffe re n c e s d i = z i − z 5 , fo r o r r e c tio n th a t w ill b e a d d e d to z 5 to . ( e ) F ig u r e P 3 .3 4 ( c ) d e s c r ib e s t h e fu z z y s y s t e m r e s p o n s ib le fo r g e n e r a t in g t h e c o r r e c t io n fa c t o r, v . T h is d ia g r a m is s im ila r t o F ig . 3 .5 2 , w it h t w o m a in d iffe r e n c e s : (1 ) th e r u le s a r e c o m p o s e d o f A N D s , m e a n in g th a t w e h a v e to u s e th e m in o p e r a t io n w h e n a p p ly in g t h e lo g ic a l o p e r a t io n s ( s t e p 2 in F ig . 3 .5 2 ) ; a n d ( 2 ) w e s h o w h o w to im p le m e n t a n E L S E r u le . T h is r u le is n o th in g m o r e th a t c o m p u tin g 1 m in u s th e m in im u m v a lu e o f th e o u tp u ts o f s te p 2 , a n d u s in g th e r e s u lt to c lip th e Z R m e m b e r s h ip fu n c tio n . It is im p o r ta n t to u n d e r s ta n d th a t th e o u tp u t o f th e fu z z y s y s te m is th e c e n te r o f g r a v ity o f th e r e s u lt o f a g g r e g a tio n (s te p 4 in F ig . 3 .5 2 ) . T h u s , fo r e x a m p le , if b o t h t h e fi r s t a n d s e c o n d r u le s w e r e t o p r o d u c e a m in im u m o f 0 , th e “ s tr e n g th ” o f th e E L S E r u le w o u ld b e 1 . T h is w o u ld p r o d u c e th e c o m p le te Z R m e m b e r s h ip fu n c tio n in th e im p lic a tio n s te p (s te p 3 in F ig . 3 .5 2 ) . T h e o t h e r t w o r e s u lt s w o u ld b e z e r o , s o t h e r e s u lt o f a g g r e g a t io n w o u ld b e th e Z R fu n c tio n . T h e c e n te r o f g r a v ity o f th is fu n c tio n is 0 , s o th e o u tp u t o f th e s y s te m w o u ld b e v = 0 , in d ic a tin g n o c o r r e c tio n , a s it s h o u ld b e . F o r th e p a r tic u la r v a lu e s o f t h e d i 0s s h o w n in F ig . P 3 .3 4 ( c ) , t h e a g g r e g a t e d fu n c t io n is b ia s e d t o th e r ig h t, s o th e v a lu e o f th e c o r r e c tio n (c e n te r o f g r a v ity ) w ill b e p o s itiv e . T h is is a s it s h o u ld b e b e c a u s e th e d iffe r e n c e s a r e a ll p o s itiv e , in d ic a tin g th a t th e v a lu e o f z 5 is le s s th a n th e v a lu e o f its 4 - n e ig h b o r s . 4 9 1 NE PO ZE 0 0 L - 1 0 L - 1 - L +1 - L +1 0 L - 1 - L +1 (a) IF d d IF d 2 is PO d v 4 is PO d THEN 6 is PO d v is PO 2 is NE d 8 is PO ELSE d v 4 is NE 6 is NE THEN v is NE 8 is NE v is ZR (b) 1. Fuzzify inputs. 2. Apply fuzzy logical operation(s) (AND =min). 3. Apply implication method (min). l1 d IF 2 is PO d AND d 6 is PO AND 4 is PO d AND THEN 8 is PO v is PO l IF d 2 is NE AND d AND 4 is NE d 6 is NE AND d 8 is NE 2 v is NE THEN l E =min{1 - l 1, 1 - l 2}=1 d ELSE v is ZR d 2 4 d d 6 4. Apply aggregation method (max). 8 v Neighborhood differences Input z 5. Defuzzify (center of gravity.) Correction from fuzzy system 5 v + (c) F ig u r e 3 .3 4 Output, z 5 Chapter 4 Problem Solutions Problem 4.1 F (μ ) 1 = f (t )e − j 2 π μ t d t − 1 T = A e − j 2 π μ t d t 0 = = = = If w 4 .1 fu n e x p − A − A T e − j2π μ t 0 = j 2 π μ j 2 π μ A e jπ μ T − e − jπ μ T e j 2 π μ A s in π μ T e − jπ μ T π μ s in π μ T A T e − jπ μ T . π μ T e − j 2 π μ t − 1 − j π μ T e le t T = W , th e o n ly d iffe r e n c e b e tw e e n th is r e s u lt a n d th e r e s u lt in E x a m p le is th e e x p o n e n tia l te r m . It is a p h a s e te r m th a t a c c o u n ts fo r th e s h ift in th e c tio n . T h e m a g n itu d e o f th e F o u r ie r tr a n s fo r m is th e s a m e in b o th c a s e s , a s e c te d . 5 1 C H A P T E R 4 . P R O B L E M S O L U T IO N S 5 2 Problem 4.2 (a ) T o p r o v e in fi n ite p e r io d ic ity in b o th d ire c tio n s w ith p e r io d 1 / Δ T , w e h a v e to s h o w t h a t F˜ μ + k [ 1 / Δ T ] = F˜ ( μ ) f o r k = 0 , ± 1 , ± 2 , . . . . F r o m E q . ( 4 .3 - 5 ) , F˜ μ + k [1 / Δ T ] 1 1 = 4 T n = − 1 1 1 = 4 T n = − 1 1 1 4 T = F˜ = k F μ + F μ + k − n 4 T μ − m 4 T F − 4 T m = − 1 n 4 T μ w h e r e th e th ir d lin e fo llo w s fr o m th e fa c t th a t k a n d n a r e in te g e r s a n d th e lim its o f s u m m a tio n a r e s y m m e tr ic a b o u t th e o r ig in . T h e la s t s te p fo llo w s fr o m E q . ( 4 .3 - 5 ) . ( b ) A g a i n , w e n e e d t o s h o w t h a t w e h a v e t o s h o w t h a t F˜ k = 0 , ± 1 , ± 2 , . . . . F r o m E q . ( 4 .4 - 2 ) , F˜ μ + k / Δ T 1 = n e − j 2 π f n e − j 2 π μ n Δ T f n e − j 2 π μ n Δ T n = − 1 1 = = n = − 1 1 ( f μ + k / Δ T μ + k / Δ T e ) = F˜ ( μ ) f o r n Δ T − j 2 π k n n = − 1 = F˜ μ w h e r e th e th ir d lin e fo llo w s fr o m th e fa c t th a t e − j 2 π k n = 1 b e c a u s e b o th k a n d n a r e i n t e g e r s ( s e e E u l e r ’s f o r m u l a ) , a n d t h e l a s t l i n e f o l l o w s f r o m E q . ( 4 . 4 - 2 ) . Problem 4.3 F r o m t h e d e fi n it io n o f t h e 1 - D F o u r ie r t r a n s fo r m in E q . ( 4 .2 - 1 6 ) , 5 3 F μ 1 = − 1 1 = − 1 − j 2 = = − j 2 − j 2 π μ t f (t ) e d t − j 2 π μ t s in (2 π n t ) e 1 e j 2 π n t − e e j 2 π n t e − 1 1 d t − j 2 π n t − j 2 π μ t e − j 2 π μ t d t 1 − j 2 d t − − 1 e − j 2 π n t e − j 2 π μ t d t . − 1 F r o m th e tr a n s la tio n p r o p e r ty in T a b le 4 .3 w e k n o w th a t j 2 π μ f (t )e 0 t , F μ − μ 0 a n d w e k n o w fr o m th e s ta te m e n t o f th e p r o b le m th a t th e F o u r ie r tr a n s fo r m o f a c o n s ta n t f (t ) = 1 is a n im p u ls e . T h u s , j 2 π μ (1 ) e 0 t , δ μ − μ 0 . T h u s , w e s e e th a t th e le ftm o s t in te g r a l in th e th e la s t lin e a b o v e is th e F o u r ie r tr a n s fo r m o f (1 ) e j 2 π n t , w h ic h is δ μ − n , a n d s im ila r ly , th e s e c o n d in te g r a l is th e tr a n s fo r m o f (1 ) e − j 2 π n t , o r δ μ + n . C o m b in in g a ll r e s u lts y ie ld s F μ = j 2 δ μ + n − δ μ − n a s d e s ire d . Problem 4.4 (a ) T h e p e r io d is s u c h th a t 2 π n t = 2 π , o r t = 1 / n . (b ) T h e fre q fo r m o f th e tra n s fo r m o lu s tr a te d in s tr u c tio n if s a tis fi e d ). u e n c y is 1 d iv id e d b y g iv e n s in e w a v e lo o k f th e s a m p le d d a ta (s F ig . P 4 .4 ( b ) ( th e d a s h th e s in e fu n c tio n w e th e p e r io d , o r n . T h e c s a s in F ig . P 4 .4 ( a ) ( s h o w in g a fe w p e r io d s e d b o x is a n id e a l fi lte r e s a m p le d , w ith th e o n tin u o u s F o u r ie r tr a n s e e P r o b le m 4 .3 ) , a n d t h e ) h a s th e g e n e r a l fo r m ilr th a t w o u ld a llo w r e c o n s a m p lin g th e o r e m b e in g ( c ) T h e N y q u is t s a m p lin g r a te is e x a c tly tw ic e th e h ig h e s t fr e q u e n c y , o r 2 n . T h a t is , (1 / Δ T ) = 2 n , o r Δ T = 1 / 2 n . T a k in g s a m p le s a t t = ± Δ T , ± 2 Δ T , . . . w o u ld y ie ld th e s a m p le d fu n c tio n s in (2 π n Δ T ) w h o s e v a lu e s a r e a ll 0 s b e c a u s e Δ T = C H A P T E R 4 . P R O B L E M S O L U T IO N S 5 4 F (m) -n n m (a) F (m) .... 1 - n DT 1 DT -n n -1 DT 1 DT +n m .... (b) F (m) .... 1 - n DT n 1 DT -n -1 DT 1 DT +n m .... (c) F ig u r e P 4 .4 1 / 2 n a n d n is a n in t e g e r. In t e r m s o f F ig . P 4 .4 ( b ) , w e s e e t h a t w h e n Δ T = 1 / 2 n a ll th e p o s itiv e a n d n e g a tiv e im p u ls e s w o u ld c o in c id e , th u s c a n c e lin g e a c h o th e r a n d g iv in g a r e s u lt o f 0 fo r th e s a m p le d d a ta . (d ) W h s u c h a in th is fo r m a th e b o a n y s h e n th e s a m p lin g r a te is le s s s th e o n e illu s tr a te d in F ig . c a s e . F o r s o m e v a lu e s o f s a s in g le s in e w a v e a n d a p lo t o k . O th e r v a lu e s w o u ld r e s a p e o b ta in a b le b y s a m p lin g th a n th e N y q u is t r a te , w e c a P 4 .4 ( c ) , w h ic h is t h e s u m m p lin g , th e s u m o f th e tw o o f th e s a m p le s w o u ld a p p e u lt in fu n c tio n s w h o s e s a m th e s u m o f tw o s in e s . n h a v e a s itu a tio n o f tw o s in e w a v e s s in e s c o m b in e to a r a s in F ig . 4 .8 o f p le s c a n d e s c r ib e 5 5 Problem 4.5 S t a r t in g fr o m E q . ( 4 .2 - 2 0 ) , f (t ) 1 g (t ) = f (τ )g (t − τ )d τ . − 1 T h e F o u r ie r tr a n s fo r m o f th is e x p re s s io n is = f (t ) g (t ) 1 = − 1 1 = ⎡ ⎣ ⎤ 1 f (τ )g (t − τ )d τ ⎦e − 1 ⎡ f (τ ) ⎣ − 1 1 − j 2 π μ t d t ⎤ g (t − τ )e − j 2 π μ t d t ⎦d τ . − 1 T h e te r m in s id e th e in n e r b r a c k e ts is th e F o u r ie r tr a n s fo r m o f g (t − τ ). B u t, w e k n o w fr o m t h e t r a n s la t io n p r o p e r t y ( T a b le 4 .3 ) t h a t = g (t − τ ) = G (μ )e − j 2 π μ τ s o = f (t ) g (t ) 1 = − 1 G (μ ) = = f (τ ) G (μ )e 1 f (τ )e − j 2 π μ τ − j 2 π μ τ d τ d τ − 1 G (μ )F (μ ). T h is p r o v e s th a t m u ltip lic a tio n in th e fr e q u e n c y d o m a in is e q u a l to c o n v o lu tio n in th e s p a tia l d o m a in . T h e p r o o f th a t m u ltip lic a tio n in th e s p a tia l d o m a in is e q u a l to c o n v o lu tio n in th e s p a tia l d o m a in is d o n e in a s im ila r w a y . C H A P T E R 4 . P R O B L E M S O L U T IO N S 5 6 Problem 4.6 f (t ) = f˜ ( t ) h (t ) 1 = − 1 1 = − 1 1 = h ( z ) f˜ ( t − z ) d z 1 = s in [π (t − n Δ T ) / Δ T ] [π (t − n Δ T ) / Δ T ] f (n Δ T ) n = − 1 1 f (t − z ) δ (t − n Δ T − z )d z n = − 1 s in (π z / Δ T ) f (t − z ) δ (t − n Δ T − z )d z (π z / Δ T ) − 1 n = − 1 1 = 1 s in (π z / Δ T ) (π z / Δ T ) f (n Δ T ) s in c [(t − n Δ T ) / Δ T ] . n = − 1 Problem 4.7 T h e te n t fu n c tio n is o b fo r m o f a b o x is a s in F o u r ie r tr a n s fo r m o f th tr a n s fo r m s , it fo llo w s t tio n s q u a re d . ta in e c fu n e s p a h a t th d b y c c tio n tia l c o e F o u . o n v B n v o r ie r o lv e c a lu t tra in u io n g tw o b o s e , b y th n o f tw o s fo r m o f x e s e c fu n a te , a n o n v c tio n t f d r e c a ll th a t o lu tio n th e n s is th e p r o u n c tio n is a th e tra n s o re m , th e d u c t th e ir s in c fu n c - Problem 4.8 ( a ) W e s o lv e th is p r o b le m b y d ir e c t s u b s titu tio n u s in g o r th o g o n a lity . S u b s titu tin g E q . ( 4 .4 - 5 ) in t o ( 4 .4 - 4 ) y ie ld s M − 1 F = m n = 0 = F − j 2 π r n / M F r e ⎦e − j 2 π m n / M r = 0 ⎡ F r = 0 ⎤ M − 1 1 ⎣ M M − 1 1 M = ⎡ r ⎣ ⎤ M − 1 e − j 2 π r n / M e − j 2 π m n / M ⎦ n = 0 m w h e r e th e la s t s te p fo llo w s fr o m th e o r th o g o n a lity c o n d itio n g iv e n in th e p r o b le m s t a t e m e n t . S u b s t it u t in g E q . ( 4 .4 - 4 ) in t o ( 4 .6 - 5 ) a n d u s in g t h e s a m e b a s ic p r o c e d u r e y ie ld s a s im ila r id e n tity fo r f n . 5 7 ( b ) W e s o lv e th is p r o b le m a s a b o v e , b y d ir e c t s u b s titu tio n a n d u s in g o r th o g o n a lit y . S u b s t it u t in g E q . ( 4 .4 - 7 ) in t o ( 4 .4 - 6 ) y ie ld s M − 1 F (u ) = x = 0 = 1 M = ⎡ 1 ⎣ M M − 1 ⎤ M − 1 r = 0 ⎡ F (r ) ⎣ r = 0 ⎦e − j 2 π r x / M F (u )e − j 2 π u x / M ⎤ M − 1 − j 2 π r x / M e e − j 2 π u x / M ⎦ x = 0 F (u ) w h e r e th e la s t s te p fo llo w s fr o m th e o r th o g o n a lity c o n d itio n g iv e n in th e p r o b le m s t a t e m e n t . S u b s t it u t in g E q . ( 4 .4 - 6 ) in t o ( 4 .6 - 7 ) a n d u s in g t h e s a m e b a s ic p r o c e d u r e y ie ld s a s im ila r id e n tity fo r f (x ). Problem 4.9 T o p r o v e in fi n ite p e r io d ic ity w e h a v e to s h o w th a t F (u + k M ) = 0 , ± 1 , ± 2 , . . . . W e d o t h is b y d ir e c t s u b s t it u t io n in t o E q . ( 4 .4 - 6 ) : F (u ) fo r k = M − 1 F (u + k M ) = f (x )e − j 2 π [u + k M ]x / M x = 0 ⎡ ⎤ M − 1 = ⎣ = F (u ) f (x )e − j 2 π u x / M ⎦e − j 2 π k x x = 0 w h e r e th e la s t s te p fo llo w s fr o m th e fa c t th a t e − j2 π k x = 1 b e c a u s e k a n d x a r e in te g e r s . N o te th a t th is h o ld s fo r p o s itiv e a n d n e g a tiv e v a lu e s o f k . W e p r o v e th e v a lid it y o f E q . ( 4 .4 - 9 ) in a s im ila r w a y . Problem 4.10 W it h r e fe r e n c e t o t h e s t a t e m e n t o f t h e c o n v o lu t io n t h e o r e m g iv e n in E q s . ( 4 .2 2 1 ) a n d ( 4 .2 - 2 2 ) , w e n e e d t o s h o w t h a t f (x ) h (x ) , F (u )H (u ) a n d th a t f (x )h (x ) , F (u ) H (u ). C H A P T E R 4 . P R O B L E M S O L U T IO N S 5 8 F r o m E q . ( 4 .4 - 1 0 ) a n d t h e d e fi n it io n o f t h e D F T in E q . ( 4 .4 - 6 ) , ⎡ M − 1 = f (x ) h (x ) M − 1 ⎣ = x = 0 m = 0 M − 1 ⎤ f (m )h (x − m )⎦e ⎡ f (m ) ⎣ = m = 0 − j 2 π u x / M ⎤ M − 1 h (x − m )e − j 2 π u x / M ⎦ x = 0 M − 1 = f (m )H (u )e − j 2 π u m / M m = 0 M − 1 = H (u ) f (m )e = H (u )F (u ). − j 2 π u m / M m = 0 T h e o th e r h a lf o f th e d is c r e te c o n v o lu tio n th e o r e m is p r o v e d in a s im ila r m a n n e r. Problem 4.11 W it h r e fe r e n c e t o E q . ( 4 .2 - 2 0 ) , f (t ,z ) h (t ,z ) = 1 1 − 1 − 1 f (α ,β )h (t − α ,z − β )d α d β . Problem 4.12 T h e lim it o f th e im a g in g s y s te m is 1 p ix e l p e r s q u a r e , s o e a c h r o w in th e r e s u ltin g im a g e w o u ld b e o f th e fo r m . . . 1 0 1 0 1 0 1 0 1 . . . . T t h is w a v e fo r m is P = 2 m m , s o t h e m a x fr e q u e n c y is μ = 1 / P = 0 .5 T o a v o id a lia s in g w e h a v e to s a m p le a t a r a te th a t e x c e e d s tw ic e th o r 2 (0 .5 ) = 1 s a m p le / m m . T h a t is , t h e s a m p lin g r a t e w o u ld h a v e s a m p le / m m . S o , e a c h s q u a r e h a s to c o r r e s p o n d to s lig h tly m o r e th in th e im a g in g s y s te m . a n d c o lu m n h e p e r io d o f c y c le s / m m . is fre q u e n c y to e x c e e d 1 a n o n e p ix e l Problem 4.13 S h r in k in g c is n o t th e c n e w d e ta il ra te , s o z o o a n a s in m c a u s e a lia s in e in z o o m in g in tr o d u c e d b in g c a n n o t re g b e , w h y z o s u lt c a u s e ic h in o m in g in a lia th e e ffe c tiv e s a m p lin g r a te is r e d u c e d . T h is tr o d u c e s a d d itio n a l s a m p le s . A lth o u g h n o , it c e r ta in ly d o e s n o t r e d u c e th e s a m p lin g s in g . 5 9 Problem 4.14 F r o m E q . ( 4 .5 - 7 ) , F (μ ,ν ) = = f (t ,z ) 1 1 − 1 − 1 = − j 2 π (μ t + ν z ) f (t ,z )e R e c a ll th a t in u s e (t ,z ) a n d c o n tin u o u s v (x ,y ) a n d (u , v a r ia b le s . d t d z . F r o m E q . ( 2 .6 - 2 ) , t h e F o u r ie r t r a n s fo r m o p e r a t io n is lin e a r if = a f 1 (t ,z ) + a 1 f 2 (t ,z ) 2 = a = 1 f 1 (t ,z ) + a = 2 f 2 (t ,z ) . S u b s titu tin g in to th e d e fi n itio n o f th e F o u r ie r tr a n s fo r m y ie ld s = a 1 f 1 (t ,z ) + a 2 f 2 (t ,z ) 1 1 − 1 − 1 = a = a 1 − 1 + a = a 1 = 1 1 − 1 − 1 2 f 1 (t ,z ) + a = 2 2 f 2 (t ,z ) d t d z − j 2 π (μ t + ν z ) f (t ,z )e 1 − 1 f 1 (t ,z ) + a − j 2 π (μ t + ν z ) × e 1 1 f 2 (t ,z )e d t d z − j 2 π (μ t + ν z ) d t d z f 2 (t ,z ) . w h e r e th e s e c o n d s te p fo llo w s fr o m th e d is tr ib u tiv e p r o p e r ty o f th e in te g r a l. S im ila r ly , fo r th e d is c r e te c a s e , M − 1 N − 1 = a 1 f 1 (x ,y ) + a 2 f 2 (x ,y ) = a 1 f 1 (x ,y ) + a 2 f 2 (x ,y ) e − j 2 π (u x / M + v y / N ) x = 0 y = 0 M − 1 N − 1 = − j 2 π (u x / M + v y / N ) f 1 (x ,y )e a 1 x = 0 y = 0 M − 1 N − 1 + a f 2 (x ,y )e 2 x = 0 = a 1 = − j 2 π (u x / M + v y / N ) y = 0 f 1 (x ,y ) + a 2 = f 2 (x ,y ) . T h e lin e a r ity o f th e in v e r s e tr a n s fo r m s is p r o v e d in e x a c tly th e s a m e w a y . Problem 4.15 S e le c t a n im a g e o f y o u r c h o ic e a n d c o m p u te its a v e r a g e v a lu e : f¯ ( x , y ) = 1 M N M − 1 N − 1 f (x ,y ). x = 0 y = 0 th is (μ ,ν a r ia b v ) fo c h a p te r w e ) fo r le s , a n d r d is c re te C H A P T E R 4 . P R O B L E M S O L U T IO N S 6 0 C o m p u te th 1 / M N w a s 2 1 )]. S im ila D F T . F in a lly m u la tio n o f o f f (x ,y ) a n d d in fr o n t o f th ( 0 , 0 ) = f¯ ( x , y ) p M N f (x ,y 0 )= e D F T a n d ID F e D F T in c lu d e r ly , if F , if F (0 , b o th th o b e th ), T . ta in F (0 ID F T [s e e 1 / M N th e te r m ,0 ). e E q te r m p 1 / F (0 ,0 ( 4 .5 - 1 a s in c N w a If s . w M ) = 5 ), lu d s in M N f¯ ( x , y ) , ( 4 .5 - 1 6 ) a n d e d in fr o n t o c lu d e d in th e th e n ( 4 .6 f th e fo r- Problem 4.16 ( a ) F r o m E q . ( 4 .5 - 1 5 ) , M − 1 N − 1 = f (x ,y )e j 2 π (u 0 x + v 0 y ) = j 2 π (u f (x ,y )e x = 0 0 x + v 0 y ) e − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = f (x ,y )e x = 0 = − j 2 π [ (u − u 0 )x / M + (v − v 0 )y / N ] y = 0 F (u − u ,v − v 0 ). 0 ( b ) F r o m E q . ( 4 .5 - 1 6 ) , = − 1 F (u ,v )e − j 2 π (u x 0 + u y 0 ) = M − 1 N − 1 1 M N 0 + u y 0 ) j 2 π (u x / M + v y / N ) M − 1 N − 1 M N F (u ,v ) u = 0 v = 0 × e = − j 2 π (u x u = 0 v = 0 × e 1 = F (u ,v )e f (x − x 0 j 2 π [(u (x − x 0 )/ M + v (y − y 0 )/ N )] ,y − y 0 ). Problem 4.17 F r o m E q . ( 4 .5 - 7 ) , F μ ,ν = = 1 1 − 1 1 − 1 1 − 1 − 1 f (t ,z ) e s in 2 π μ − j 2 π (μ t + ν z ) 0 t + 2 π ν 0 z d t d z e − j 2 π (μ t + ν z ) d t d z . 6 1 E x p r e s s in g th e s in e fu n c tio n in te r m s o f e x p o n e n tia ls y ie ld s F μ ,ν − j 2 = 1 j 2 π (μ e ⎡ − j ⎣ 2 = 1 − 1 − 1 1 j 2 π (μ − 1 ⎡ − j ⎣ − 2 − e − j 2 π (μ t + ν 0 z ) 0 − j 2 π (μ t + ν z ) e d t d z ⎤ 1 e − 1 t + ν 0 z ) 0 0 1 t + ν 0 z ) − j 2 π (μ t + ν z ) d t d z ⎦ ⎤ 1 − j 2 π (μ e − 1 e 0 t + ν 0 z ) e − j 2 π (μ t + ν z ) d t d z ⎦. − 1 W e re c o g n iz e th e te r m s in s id e th e b r a c k e ts a s th e F o u r ie r tr a n s fo r m s o f j 2 π (μ (1 )e t + ν 0 z ) 0 a n d (1 )e F ro m 4 .3 w fo r m tra n s th e e k n o . T h e fo r m p r o b le w th a t re fo re , . P lu g g = m th = in s in − j 2 π (μ s ta te m e n t w e k n o w e e x p o n e n tia l ju s t in ( 1 ) e j 2 π (μ 0 t + ν 0 z ) = δ g th e s e r e s u lts in th e 2 π μ 0 t + 2 π ν 0 z 0 t + ν 0 z ) th a tro d (μ − p re j = . t th e = u c e s a μ 0 ,ν − c e d in g [1 ] = δ (μ s h ift in th ν 0 ), a n d s e q u a tio n δ (μ + μ 2 0 ,ν ), a e o r ig im ila r y ie ld n d fr o m T a b le in o f th e tr a n s ly fo r th e o th e r s , ) − δ (ν − ν 0 ) . Problem 4.18 W e c o n s id e r t h e 1 - D c a s e fi r s t . F r o m E q . ( 4 .4 - 6 ) , M − 1 F (u ) = f (x )e − j 2 π u x / M . x = 0 W h e n f ( x ) = 1 a n d u = 0 , F ( u ) = 1 . W h e n f ( x ) = 1 a n d u 6= 0 , M − 1 F (u ) = e − j 2 π u x / M . x = 0 T h is e x p r e s s io n is 0 fo r a n y in te g e r v a lu e o f u in th e r a n g e [0 , N − 1 ]. T h e r e a r e v a r i o u s w a y s o f p r o v i n g t h i s . O n e o f t h e m o s t i n t u i t i v e i s b a s e d o n u s i n g E u l e r ’s fo r m u la to e x p r e s s th e e x p o n e n tia l te r m a s e − j 2 π u x / M = c o s (2 π u x / M ) − j s in (2 π u x / M ). C H A P T E R 4 . P R O B L E M S O L U T IO N S 6 2 T h is e x p re s s io n d e s c r ib e s a u n it v e c to r in th e c o te re d a t th e o r ig in a n d its d ire c tio n d e p e n d s o n a n y in te g e r v a lu e o f u in th e r a n g e [0 , N − 1 ] th v a lu e s o f x in th e s a m e r a n g e . T h is m e a n s th a t th b e r o f r e v o lu tio n s a b o u t th e o r ig in in e q u a l in c v a lu e o f c o s (2 π u x / M ), th e r e w ill b e a c o r r e s p o n T h is p r o d u c e s a z e r o s u m fo r th e re a l p a r t o f th a p p ly th e im a g in a r y p a r t. T h e r e fo r e , w h e n f (x F (u ) = 0 . T h u s , w e h a v e s h o w n th a t fo r d is c re te if u = 0 i f u =6 0 . 1 = [1 ] = δ (u ) = m p le x p la n e . T h e v e c to r is c e n th e v a lu e o f th e a r g u m e n t. F o r e a r g u m e n t r a n g e s o v e r in te g e r e v e c to r m a k e s a n in te g e r n u m re m e n ts . T h u s , fo r a n y p o s itiv e d in g n e g a tiv e v a lu e o f th is te r m . e e x p o n e n t. S im ila r c o m m e n ts ) = 0 a n d u 6= 0 , i t f o l l o w s t h a t q u a n titie s , 0 A s im ila r p r o c e d u r e a p p lie s in th e c a s e o f tw o v a r ia b le s , a n d w e h a v e th a t if u = 0 a n d v = 0 o th e r w is e . 1 = [1 ] = δ (u ,v ) = 0 Problem 4.19 F r o m E q . ( 4 .5 - 1 5 ) , a n d u s in g t h e e x p o n e n t ia l r e p r e s e n t a t io n o f t h e s in e fu n c t io n , w e h a v e M − 1 N − 1 F (u ,v ) = 2 π u s in x = 0 − j 2 = − j 2 = = x + 2 π v 0 y e − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 e j 2 π (u x + v 0 0 y ) − e − j 2 π (u 0 x + v y ) 0 e − j 2 π (u x / M + v y / N ) x = 0 y = 0 M − 1 N − 1 e j 2 π (M u 0 x / M + N v 0 y / N ) e − j 2 π (u x / M + v y / N ) x = 0 y = 0 − j − 2 = 0 M − 1 N − 1 e − j 2 π (M u 0 x / M + N v 0 y / N ) e − j 2 π (u x / M + v y / N ) x = 0 y = 0 − j j = ( 1 ) e j 2 π (M u 0 x / M + N v 0 y / N ) + = ( 1 ) e − j 2 π (u 0 x 2 2 j [δ (u + M u 0 ,v + N v 0 ) − δ (u − M u 0 ,v − N v 0 )] 2 + v 0 y ) w h e r e t h e fo u r t h s t e p fo llo w s fr o m t h e d is c u s s io n in P r o b le m 4 .1 7 , a n d t h e la s t lin e fo llo w s fr o m T a b le 4 .3 . 6 3 Problem 4.20 T o a w F h e fo llo w in g a r e p r o o th e r p r o p e r tie s a re g iv s im a g in a r y , its re a l p a h o s e re a l a n d im a g in a o u r ie r tr a n s fo r m p a ir s fs e n r t r y . S o f in is z p a im s o m e o f th e p r o p e r tie s in T a b le C h a p te r 4 . R e c a ll th a t w h e n w e e r o . W e u s e th e te r m c o m p le x to r ts a r e n o t z e r o . W e p r o v e o n ly th ila r te c h n iq u e s a r e u s e d to p r o v e 4 .1 . re fe d e n e fo th e P r r to o te r w a in v o o fs a fu a fu rd p e rs e o f th n c tio n c tio a r t th p a r t. e n n e (a ) P r o p e r ty 2 : If f (x ,y ) is im a g in a r y , f (x ,y ) , F ∗ (− u ,− v ) = − F (u ,v ). P r o o f: B e c a u s e f (x ,y ) is im a g in a r y , w e c a n e x p re s s it a s j g (x ,y ), w h e re g (x ,y ) is a re a l fu n c tio n . T h e n th e p r o o f is a s fo llo w s : ⎤∗ ⎡ F ∗ (− u − v ) ⎢ ⎣ = M − 1 N − 1 j 2 π (u x / M + v y / N ) j g (x ,y )e x = 0 ⎥ ⎦ y = 0 M − 1 N − 1 = − j 2 π (u x / M + v y / N ) − j g (x ,y )e x = 0 y = 0 M − 1 N − 1 = j g (x ,y ) e − x = 0 − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = f (x ,y )e − x = 0 = − j 2 π (u x / M + v y / N ) y = 0 − F (u ,v ). (b ) P r o p e r ty 4 : If f (x ,y ) is im a g in a r y , th e n R (u ,v ) is o d d a n d I (u ,v ) is e v e n . P r o o f: F is c o m p le x , s o it c a n b e e x p r e s s e d a s F (u ,v ) = re a l [F (u ,v )] + j im a g [F (u ,v )] = T h e n , − B u t, b e th e n fo is o d d ) F (u , c a u s e llo w s a n d I v ) f fro (u = − R (u ,v ) − (x ,y ) is im a g m th e p re v io ,v ) = I (− u ,− R (u ,v ) + j I (u ,v ). j I in u s v ) (u ,v a r y , tw o (I is ) a n F ∗(− e q u e v e d F ∗(− u ,− v ) = R (− u ,− v ) − j I (− u ,− v ). u ,− v ) = − F (u ,v ) (s e e P ro p e r ty 2 ). It a t io n s t h a t R (u , v ) = − R (− u , − v ) ( i.e ., R n ). (c ) P r o p e r ty 5 : f (− x ,− y ) , F ∗ (u ,v ). T h a t is , if f (x ,y ) is re a l a n d its tr a n s fo r m is F (u , v ), th e n th e tr a n s fo r m o f f (− x , − y ) is F ∗ (u , v ). A n d c o n v e r s e ly . P r o o f: F r o m E x a m p le 4 .1 2 , M − 1 N − 1 = f (− x ,− y ) f (m ,n )e = m = 0 n = 0 j 2 π (u m / M + v n / N ) . C H A P T E R 4 . P R O B L E M S O L U T IO N S 6 4 T o s e e w h a t h a p p e n s w h e n f (x , y ) is r e a l, w e w r ite th e r ig h t s id e o f th is e q u a tio n a s ⎡ M − 1 N − 1 f (m ,n )e ⎣ j 2 π (u m / M + v n / N ) = m = 0 n = 0 ⎡ = ⎣ = F ⎤∗ M − 1 N − 1 ∗ f (m ,n )e − j 2 π (u m / M + v n / N ) m = 0 n = 0 ⎦ ⎤∗ M − 1 N − 1 f (m ,n )e − j 2 π (u m / M + v n / N ) ⎦ m = 0 n = 0 ∗ (u ,v ) w h e r e th e s e c o n d s te p fo llo w s fr o m th e fa c t th a t f (x , y ) is r e a l. T h u s , w e h a v e s h o w n th a t = f (− x ,− y ) = F ∗ (u ,v ). ( d ) P r o p e r ty 7 : W h e n f (x , y ) is c o m p le x , f ∗ (x , y ) , F ∗ (− u ,− v ). P ro o f: M − 1 N − 1 = f ∗ (x ,y ) f ∗ (x ,y )e = x = 0 y = 0 ⎡ = ⎢ ⎣ M − 1 N − 1 F ∗ (e ) c o n is e th e P ro v e r v e n n w p e r ty 9 : If f (x ,y ) is re s e ly . P r o o f: B e c a u s e a n d its im a g in a r y p a e w ill h a v e c o m p le te d ⎤∗ f (x ,y )e x = 0 = − j 2 π (u x / M + v y / N ) j 2 π (u x / M + v y / N ) ⎥ ⎦ y = 0 (− u ,− v ). a l a n d f (x ,y ) r t is o d th e p r o d is d . o o d , th e n F (u ,v ) is im a g in a r y a n d o d d , a n d r e a l, w e k n o w th a t th e r e a l p a r t o f F (u , v ) If w e c a n s h o w th a t F is p u r e ly im a g in a r y , f. M − 1 N − 1 F (u ,v ) = f (x ,y )e x = 0 − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = f (x ,y ) x = 0 e − j 2 π (u x / M ) e − j 2 π (v y / N ) y = 0 M − 1 N − 1 = [o d d ] e v e n − j o d d x = 0 y = 0 e v e n − j o d d 6 5 M − 1 N − 1 [o d d ] (e v e n )(e v e n ) − 2 j (e v e n )(o d d ) − (o d d )(o d d ) = x = 0 y = 0 M − 1 N − 1 = M − 1 N − 1 [(o d d )(e v e n )] − 2 j x = 0 y = 0 [(e v e n )(e v e n )] x = 0 y = 0 M − 1 N − 1 [(o d d )(e v e n )] − x = 0 = y = 0 im a g in a r y w h e r e t h e la s t s t e p fo llo w s fr o m E q . ( 4 .6 - 1 3 ) . (f ) P e v e n re a l re a l n a r y ro p e r ty , a n d c o p a r t o f F p a r t is 0 , w e c a n 1 0 : If f (x ,y ) is n v e r s e ly . P r o o f (u ,v ) is o d d a n , th e n w e w ill h e x p re s s it a s j g im a g in a r y a n d e v e n : W e k n o w th a t w h e d its im a g in a r y p a r t a v e p r o v e d th is p r o (x ,y ), w h e re g is a r h e n F (u ,v ) is im a g in a r y a n f (x ,y ) is im a g in a r y , th e n th e v e n . If w e c a n s h o w th a t th r ty . B e c a u s e f (x ,y ) is im a g l fu n c tio n . T h e n , , t n is p e e a d e e i- M − 1 N − 1 F (u ,v ) = f (x ,y )e x = 0 − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = j g (x ,y ) x = 0 − j 2 π (u x / M ) e e − j 2 π (v y / N ) y = 0 M − 1 N − 1 = [j e v e n ][e v e n − j o d d ][e v e n − j o d d ] x = 0 y = 0 M − 1 N − 1 [j e v e n ] (e v e n )(e v e n ) − 2 j (e v e n )(o d d ) − (o d d )(o d d ) = x = 0 y = 0 M − 1 N − 1 = M − 1 N − 1 [(e v e n )(e v e n )] + 2 j x = 0 y = 0 [(e v e n )(o d d )] x = 0 y = 0 M − 1 N − 1 [(e v e n )(e v e n )] − j x = 0 y = 0 = w h e re th (g ) P ro p e c o n v e rs e is o d d a n im a g in a r y e la s t s te p r ty 1 1 : If f ly . P r o o f: d its im a g fo (x If in llo w ,y ) f (x a r y s fro m E q . (4 is im a g in a r y ,y ) is im a g in p a r t is e v e n . .6 - 1 a n d a r y , If w 3 ). o d d , th e n F (u ,v ) is re a l a n d o d d , a n d w e k n o w th a t th e re a l p a r t o f F (u ,v ) e c a n s h o w th a t th e im a g in a r y p a r t is C H A P T E R 4 . P R O B L E M S O L U T IO N S 6 6 z e r o , th e n w e w ill h a v e th e p r o o f fo r th is p r o p e r ty . A s a b o v e , M − 1 N − 1 F (u ,v ) = [j o d d ] (e v e n )(e v e n ) − 2 j (e v e n )(o d d ) − (o d d )(o d d ) x = 0 y = 0 M − 1 N − 1 = [j o d d ][e v e n − j o d d ][e v e n − j o d d ] x = 0 y = 0 M − 1 N − 1 = M − 1 N − 1 [(o d d )(e v e n )] + 2 j x = 0 y = 0 [(e v e n )(e v e n )] x = 0 y = 0 M − 1 N − 1 [(o d d )(e v e n )] − j x = 0 y = 0 = re a l w h e r e t h e la s t s t e p fo llo w s fr o m E q . ( 4 .6 - 1 3 ) . (h ) e v e im a b o t f (x P ro p e r n , a n d g in a r y h its re ,y ) = f f (x ,y ) ly . P r o F (u ,v ) a g in a r y j f ie (x , If rs e o f im ) + ty 1 2 : c o n v e p a r ts a l a n d r e ( x , y is c o f: a re p a y ). o m p le H e re , e v e n . r ts a re T h e n , x a n d e w e h a v R e c a ll e v e n . T v e n , th e to p r th a t if h u s , w e n F o v e t f (x ,y e c a n (u , h a t ) is w r v ) b o a n ite is th e th c o m th e v e n is fu p le x re a l fu n c n c tio a n d a n d tio n , n a s M − 1 N − 1 F (u ,v ) = [ f x = 0 r e (x ,y ) + j f i e (x ,y )]e − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = f x = 0 r e (x ,y )e − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 = + j f x = 0 T h e w h ic im a g th a t e v e n p ro o fi rs t t h w e in a r y th e th im a g f. e r m o k n o w e v e n e tra n in a r y f th is is a re fu n c t s fo r m p a r t, re s u a l, e io n , o f a a n d lt is r e c o g n v e n fu n c tio w h ic h w e k c o m p le x , e is th u s a c o i e (x ,y )e − j 2 π (u x / M + v y / N ) . y = 0 iz e d a s th e D F T o f a n . T h e s e c o n d te r m is n o w is im a g in a r y a n d v e n fu n c tio n , h a s a n e m p le x e v e n fu n c tio n . r e a l, e v e n th e D F T o e v e n . T h u v e n re a l p a T h is c o n c fu n c tio n , f a p u r e ly s , w e s e e r t a n d a n lu d e s th e ( i) P r o p e r ty 1 3 : If f (x , y ) is c o m p le x a n d o d d , th e n F (u , v ) is c o m p le x a n d o d d , 6 7 a n d c o n v e r s e ly . P r o o f: T h e p r o o f p a r a lle ls th e p r o o f in (h ). M − 1 N − 1 F (u ,v ) = x = 0 [ f r o (x ,y ) + j f f r o (x ,y )e − j 2 π (u x / M + v y / N ) (x ,y )]e i o y = 0 M − 1 N − 1 = x = 0 − j 2 π (u x / M + v y / N ) y = 0 M − 1 N − 1 + j f x = 0 T o k w h e fi rs t t d d . T h e n o w is re a n te d to e r m is s e c o n a l a n d p ro v e i o (x ,y )e − j 2 π (u x / M + v y / N ) . y = 0 th e D F T o f a n o d d , re a l fu n c tio n , w h ic h k n o w is im a g in a r y a n d d te r m is th e D F T o f p u r e ly im a g in a r y o d d fu n c tio n , w h ic h w e o d d . T h u s , th e s u m o f th e tw o is a c o m p le x , o d d fu n c tio n , a s w e . Problem 4.21 R e c a ll th a t th e r e a s o n fo r p a d d in g is to e s ta b lis h a “ b u ffe r ” b e tw e e n th e p e r io d s th a t a r e im p lic it in th e D F T . Im a g in e th e im a g e o n th e le ft b e in g d u p lic a te d in fi n ite ly m a n y tim e s to c o v e r th e x y - p la n e . T h e r e s u lt w o u ld b e a c h e c k e r b o a r d , w ith e a c h s q u a r e b e in g in th e c h e c k e r b o a r d b e in g th e im a g e (a n d th e b la c k e x te n s io n s ). N o w im a g in e d o in g th e s a m e th in g to th e im a g e o n th e r ig h t. T h e r e s u lts w o u ld b e id e n tic a l. T h u s , e ith e r fo r m o f p a d d in g a c c o m p lis h e s th e s a m e s e p a r a tio n b e tw e e n im a g e s , a s d e s ire d . Problem 4.22 U n le s s a ll d u c e s s ig n T h e s e c a n th e s p a tia l h o r iz o n ta l b o rd e rs ifi c a n t d b e s tro n d o m a in a x e s o f t o n o f a n im a g is c o n tin u itie s g h o r iz o n ta l a in tr o d u c e h ig h h e s p e c tr u m . e a r e b la c k , p a d d (e d g e s ) a t o n e o r n d v e r tic a l e d g e s -fre q u e n c y c o m p in g th m o re . T h e o n e n t e im a g e w it b o rd e rs o f s e s h a rp tra s a lo n g th e v Problem 4.23 ( a ) T h e a v e r a g e s o f th e tw o im a g e s a r e c o m p u te d a s fo llo w s : f¯ ( x , y ) = 1 M N M − 1 N − 1 f (x ,y ) x = 0 y = 0 h th n s e r 0 s in e im itio n tic a l tro a g e . s in a n d C H A P T E R 4 . P R O B L E M S O L U T IO N S 6 8 a n d f ¯p ( x , y ) P − 1 Q − 1 1 = f P Q f (x ,y ) P Q x = 0 M N P Q = (x ,y ) M − 1 N − 1 1 = p x = 0 y = 0 y = 0 f¯ ( x , y ) w h e r e th e s e c o n d s te p is r e s u lt o f th e fa c t th a t th e im a g e is p a d d e d w ith 0 s . T h u s , th e r a tio o f th e a v e r a g e v a lu e s is r = P Q M N T h u s , w e s e e th a t th e r a tio in c re a s e s a s a fu n c tio n o f P Q , in d ic a tin g th a t th e a v e r a g e v a lu e o f th e p a d d e d im a g e d e c r e a s e s a s a fu n c tio n o f P Q . T h is is a s e x p e c te d ; p a d d in g a n im a g e w ith z e r o s d e c r e a s e s its a v e r a g e v a lu e . ( b ) Y e s , t h e y a r e e q u a l . W e k n o w t h a t F ( 0 , 0 ) = M N f¯ ( x , y ) a n d F A n d , f r o m p a r t ( a ) , f¯p ( x , y ) = M N f¯ ( x , y ) / P Q . T h e n , F p (0 ,0 ) P Q F p (0 ,0 ) = = p ( 0 , 0 ) = P Q f¯p ( x , y ) . M N F (0 ,0 ) P Q M N F (0 ,0 ). Problem 4.24 W e s o lv e th e p r o b le m b y d ir e c t s u b s titu tio n in to th e d e fi n itio n o f th e 2 - D D F T : M − 1 N − 1 F (u + k 1 M ,v + k 2 N ) = x = 0 f (x ,y )e − j 2 π ([u + k f (x ,y )e − j 2 π (u x / M + v y / N ) 1 M ]x / M + [v + k 2 N ]y / N ) y = 0 M − 1 N − 1 = x = 0 = e − j 2 π k 1 x e − j 2 π k 2 y y = 0 F (u ,v ) w ith k 1 a n d k 2 h a v in g v a lu e s 0 , ± 1 , ± 2 , . . . . T h e la s t s te p fo llo w s fr o m th e fa c t th a t k 1 x a n d k 2 y a r e in te g e r s , w h ic h m a k e s th e tw o r ig h tm o s t e x p o n e n tia ls e q u a l to 1 . 6 9 Problem 4.25 ( a ) F r o m E q . ( 4 .4 - 1 0 ) a n d t h e d e fi n it io n o f t h e 1 - D D F T , M − 1 = f (x ) h (x ) = f (x ) − j 2 π u x / M h (x )e x = 0 M − 1 M − 1 = − j 2 π u x / M f (m )h (x − m )e x = 0 m = 0 M − 1 = M − 1 f (m ) m = 0 h (x − m )e − j 2 π u x / M x = 0 b u t M − 1 h (x − m )e − j 2 π u x / M x = 0 = = [h (x − m )] = H (u )e − j 2 π m u / M w h e r e t h e la s t s t e p fo llo w s fr o m E q . ( 4 .6 - 4 ) . S u b s t it u t in g t h is r e s u lt in t o t h e p r e v io u s e q u a tio n y ie ld s M − 1 = f (x ) h (x ) = − j 2 π m u / M f (m )e H (u ) m = 0 = F (u )H (u ). T h e o th e r p a r t o f th e c o n v o lu tio n th e o r e m is d o n e in a s im ila r m a n n e r. (b ) A s in (a ), M − 1 N − 1 = f (x ,y ) h (x ,y ) = f (x ,y ) x = 0 y = 0 M − 1 N − 1 = x = 0 y = 0 = M − 1 N − 1 = ⎡ ⎣ h (x ,y )e M − 1 N − 1 ⎤ f (m ,n )h (x − m ,y − n )⎦ m = 0 n = 0 × e − j 2 π (u x / M + v y / N ) M − 1 N − 1 f (m ,n ) m = 0 n = 0 M − 1 N − 1 = h (x − m ,y − n ) x = 0 × e y = 0 − j 2 π (u x / M + v y / N ) f (m ,n )e m = 0 n = 0 = − j 2 π (u x / M + v y / N ) F (u ,v )H (u ,v ). − j 2 π (u m / M + v n / N ) H (u ,v ) C H A P T E R 4 . P R O B L E M S O L U T IO N S 7 0 ( c ) C o r r e la tio n is d o n e in th e s a m e w a y , b u t b e c a u s e o f th e d iffe r e n c e in s ig n in th e a r g u m e n t o f h th e r e s u lt w ill b e a c o n ju g a te : M − 1 N − 1 = f (x ,y ) h (x ,y ) = f (x ,y ) x = 0 y = 0 M − 1 N − 1 = x = 0 ⎡ ⎣ y = 0 M − 1 N − 1 ⎤ f (m ,n )h (x + m ,y + n )⎦ m = 0 n = 0 − j 2 π (u x / M + v y / N ) × e M − 1 N − 1 = M − 1 N − 1 f (m ,n ) m = 0 n = 0 h (x + m ,y + n ) x = 0 y = 0 − j 2 π (u x / M + v y / N ) × e M − 1 N − 1 = − j 2 π (u x / M + v y / N ) h (x ,y )e f (m ,n )e j 2 π (u m / M + v n / N ) H (u ,v ) m = 0 n = 0 ∗ = (u ,v )H (u ,v ). F ( d ) W e b e g in w ith o n e v a r ia b le : = d f (z ) d z 1 = d f (z ) e d z − 1 − j 2 π ν z d z In te g r a tio n b y p a r ts h a s th e fo llo w in g g e n e r a l fo r m , s d w = s w − L e t s = e − j 2 π ν z a n d w = d w = w d s . f (z ). T h e n , d w / d z = d f (z )/ d z o r d f (z ) d z d z d s = (− j 2 π ν )e a n d − j 2 π ν z d z s o it fo llo w s th a t = d f (z ) d z 1 = − 1 = = = d f (z ) e d z f (z ) e (j 2 π ν ) − j 2 π ν z − j 2 π ν z 1 1 1 − 1 (j 2 π ν )F (ν ) d z 1 − f (z )e f (z )(− j 2 π ν )e − 1 − j 2 π ν z d z − j 2 π ν z d z 7 1 b e c a u s e f (± 1 ) = 0 b y a s s u m p tio n (s e e T a b le 4 .3 ). C o n s id e r n e x t th e s e c o n d d e r iv a tiv e . D e fi n e g (z ) = d f (z )/ d z . T h e n d g (z ) d z = = ( j 2 π ν )G (ν ) w h e re G (ν ) is th e F o u r ie r tr a n s fo r m o f g (z ). B u t g (z ) = (j 2 π ν )F (ν ), a n d d 2 f (z ) = = (j 2 π ν )2 F (ν ). d z 2 d f (z )/ d z , s o G (ν ) = C o n tin u in g in th is m a n n e r w o u ld r e s u lt in th e e x p r e s s io n d = If s a to w w e n o m e re in d ic o u ld h w g o to s u lt a s a te th e a v e F ( 2 in v μ -D a n d th e p r a r ia b le ,ν ). T h n f (z ) d z n = (j 2 π ν )n F (ν ). ta k e th e d e r iv a tiv e o f o n ly o n e v a r ia b le , w e w o u ld g e t th e e c e d in g e x p re s s io n , b u t w e h a v e to u s e p a r tia l d e r iv a tiv e s to w h ic h d iffe r e n tia tio n a p p lie s a n d , in s te a d o f F (μ ), w e u s , n @ = D e fi n e g (t ,z ) = @ n f (t ,z )/ @ t = m @ f (t ,z ) @ z n n = (j 2 π ν )n F (μ ,ν ). , th e n g (t ,z ) @ t m = (j 2 π μ ) m G (μ ,ν ). B u t G (μ ,ν ) is th e tr a n s fo r m o f g (t ,z ) = @ n f (t ,z )/ @ t n , w h ic h w e k n o w is e q u a l to ( j 2 π μ )n F (μ , ν ). T h e r e fo r e , w e h a v e e s ta b lis h e d th a t = @ @ t m @ @ z n f (t ,z ) = (j 2 π μ ) m (j 2 π ν )n F (μ ,ν ). B e c a u s e th e F o u r ie r tr a n s fo r m is u n iq u e , w e k n o w th a t th e in v e r s e tr a n s fo r m o f th e r ig h t o f th is e q u a tio n w o u ld g iv e th e le ft, s o th e e q u a tio n c o n s titu te s a F o u r ie r tr a n s fo r m p a ir (k e e p in m in d th a t w e a r e d e a lin g w ith c o n tin u o u s v a r ia b le s ). Problem 4.26 ( a ) F r o m C h a p te r 3 , th e L a p la c ia n o f a fu n c tio n f (t , z ) o f tw o c o n tin u o u s v a r ia b le s is d e fi n e d a s @ 2 f (t ,z ) @ 2 f (t ,z ) r 2 f (t ,z ) = + . @ t 2 @ z 2 C H A P T E R 4 . P R O B L E M S O L U T IO N S 7 2 W e o b ta in th e F o u r ie r tr a n s fo r m o f th e L a p la c ia n u s in g th e r e s u lt fr o m P r o b le m 4 .2 5 ( e n t r y 1 2 in T a b le 4 .3 ) : 2 r = f (t ,z ) 2 @ = = f (t ,z ) @ t 2 + = @ 2 f (t ,z ) @ z 2 (j 2 π μ )2 F (μ ,ν ) + (j 2 π ν )2 F (μ ,ν ) = − 4 π = 2 (μ 2 + ν 2 )F (μ ,ν ). W e r e c o g n iz e th is a s th e fa m ilia r fi lte r in g e x p r e s s io n G (μ , ν ) = H (μ , ν )F (μ , ν ), in w h ic h H (μ ,ν ) = − 4 π 2 (μ 2 + ν 2 ). ( b ) A s th e p r e c e d in g d e r iv a tio n s h o w s , th e L a p la c ia n fi lte r a p p lie s to c o n tin u o u s v a r ia b le s . W e c a n g e n e r a te a fi lte r fo r u s in g w ith th e D F T s im p ly b y s a m p lin g th is fu n c tio n : H (u ,v ) = − 4 π 2 (u 2 + v 2 ) fo r u = 0 ,1 ,2 , . . . , M − 1 a n d v = 0 , 1 , 2 , . . . , N − 1 . W h e n w o r k in g w it h c e n t e r e d tr a n s fo r m s , th e L a p la c ia n fi lte r fu n c tio n in th e fr e q u e n c y d o m a in is e x p r e s s e d a s H (u ,v ) = − 4 π 2 ([u − M / 2 ]2 + [v − N / 2 ]2 ). In s u m m a r y , w e h a v e th e fo llo w in g F o u r ie r tr a n s fo r m p a ir r e la tin g th e L a p la c ia n in th e s p a tia l a n d fre q u e n c y d o m a in s : r 2 f (x ,y ) , − 4 π 2 ([u − M / 2 ]2 + [v − N / 2 ]2 )F (u ,v ) w h e r e it is u n d e r s to o d th a t th e fi lte r is a s a m p le d v e r s io n o f a c o n tin u o u s fu n c tio n . ( c ) T h e L a p la c ia n fi lte r is is o tr o p ic , s o its s y m m e tr y is a p p r o x im a te d m u c h c lo s e r b y a L a p la c ia n m a s k h a v in g th e a d d itio n a l d ia g o n a l te r m s , w h ic h r e q u ir e s a − 8 in th e c e n te r s o th a t its re s p o n s e is 0 in a re a s o f c o n s ta n t in te n s ity . Problem 4.27 ( a ) T h e s p a tia l a v e r a g e (e x c lu d in g th e c e n te r te r m ) is 1 g (x ,y ) = 4 f (x ,y + 1 ) + f (x + 1 ,y ) + f (x − 1 ,y ) + f (x ,y − 1 ) . F r o m p r o p e r t y 3 in T a b le 4 .3 , G (u ,v ) = = 1 e j2π v /N + e 4 H (u ,v )F (u ,v ) j 2 π u / M + e − j 2 π u / M + e − j 2 π v / N F (u ,v ) 7 3 w h e re 1 H (u ,v ) = [c o s (2 π u / M ) + c o s (2 π v / N )] 2 is th e fi lte r tr a n s fe r fu n c tio n in th e fr e q u e n c y d o m a in . ( b ) T o s e e th a t th is is a lo w p a s s fi lte r, it h e lp s to e x p r e s s th in th e fo r m o f o u r fa m ilia r c e n te r e d fu n c tio n s : 1 [c o s (2 π [u − M / 2 ])/ M ) + c o s (2 π [v − H (u ,v ) = 2 C o n s id e r o n e v a r ia b le fo r c o n v e n ie n c e . A s u r a n g e s fr o m o f c o s (2 π [u − M / 2 ]/ M ) s ta r ts a t − 1 , p e a k s a t 1 w h e n u th e fi lte r ) a n d th e n d e c r e a s e s to − 1 a g a in w h e n u = M . a m p litu d e o f th e fi lte r d e c r e a s e s a s a fu n c tio n o f d is ta n c e c e n te r e d fi lte r, w h ic h is th e c h a r a c te r is tic o f a lo w p a s s fi lte is e a s ily c a r r ie d o u t w h e n c o n s id e r in g b o th v a r ia b le s s im u e p re c e d in g e q u a tio n = N / 2 ]/ N )] . 0 to M M / 2 T h u s , w fro m th r. A s im lta n e o u − 1 , th e (th e c e n e s e e th e o r ig in ila r a r g u s ly . v a te a t o f m lu r o th th e n e Problem 4.28 ( a ) A s in P r o b le m 4 .2 7 , t h e fi lt e r e d im a g e is g iv e n b y : g (x ,y ) = f (x + 1 ,y ) − f (x ,y ) + f (x ,y + 1 ) − f (x ,y ). F r o m p r o p e r t y 3 in T a b le 4 .3 , G (u ,v ) = j 2 π u / M F (u ,v )e = [e = j 2 π u / M − F (u ,v ) + F (u ,v )e j 2 π v / N − 1 ]F (u ,v ) + [e j 2 π v / N − F (u ,v ) − 1 ]F (u ,v ) H (u ,v )F (u ,v ) w h e r e H (u , v ) is th e fi lte r fu n c tio n : H (u ,v ) (e = = 2 j j 2 π u / M − 1 ) + (e s in (π u / M )e j 2 π v / N j π u / M − 1 ) + s in (π v / N )e j π v / N . ( b ) T o s e e th a t th is is a h ig h p a s s fi lte r, it h e lp s to e x p r e s s th e fi lte r fu n c tio n in th e fo r m o f o u r fa m ilia r c e n te r e d fu n c tio n s : H (u ,v ) = 2 j s in (π [u − M / 2 ]/ M )e T h e fu n c tio n is 0 a t th e c e n te r v a lu e o f th e fi lte r d e c r e a s e s , r e a M − 1 a n d v = M − 1 . T h e n e g a t d e r iv a tiv e s a re ta k e n . If, in s te a f (x + 1 ,y ) a n d f (x ,y ) − f (x ,y + lim itin g v a lu e . T h e im p o r ta n t h ig h e r fre q u e n c ie s a re p a s s e d , j π u / M + s in (π [v − N / 2 ]/ N )e o f th e fi lte r u = M / 2 ). c h in g its lim itin g v a lu e iv e lim itin g v a lu e is d u e d w e h a d ta k e n d iffe re n 1 ), th e fi lte r w o u ld h a v e p o in t h e re is th a t th e d w h ic h is th e c h a r a c te r is A s o f to c e te j π v / N . u a n d v in c re a s e , th e c lo s e to − 4 j w h e n u = th e o rd e r in w h ic h th e s o f th e fo r m f (x ,y ) − n d e d to w a rd a p o s itiv e c te r m is e lim in a te d a n d tic o f a h ig h p a s s fi lte r. f e e t C H A P T E R 4 . P R O B L E M S O L U T IO N S 7 4 Problem 4.29 T h e fi lte r e d fu n c tio n is g iv e n b y g (x ,y ) = [ f (x + 1 ,y ) + f (x − 1 ,y ) + f (x ,y + 1 ) + f (x ,y − 1 )] − 4 f (x ,y ). A s in P r o b le m 4 .2 8 , G (u ,v ) = H (u ,v )F (u ,v ) w h e re H (u ,v ) = e j 2 π u / M + e − j 2 π u / M j 2 π v / N + e + e − j 2 π v / N − 4 2 [c o s (2 π u / M ) + c o s (2 π v / N ) − 2 ] . = S h iftin g th e fi lte r to th e c e n te r o f th e fr e q u e n c y r e c ta n g le g iv e s H (u ,v ) = 2 [c o s (2 π [u − M / 2 ] / M ) + c o s (2 π [v − N / 2 ] / N ) − 2 ] . W h e n (u ,v ) = u e s a w a y fro m o rd e r in w h ic h e lim in a te d a n d a h ig h p a s s fi lte (M th e d e th r. / 2 ,N c e n r iv a t e h ig / te iv h 2 ) r, e s e r (t H a fr h e (u re e q c e n te r ,v ) d e c ta k e n . u e n c ie o f th e s h ifte re a s e s (a s in T h e im p o r ta s a re p a s s e d , d fi lte r ), P r o b le m n t p o in t w h ic h is H (u 4 .2 is t th e ,v ) = 8 ) b e c h e th e c h a ra 0 . a u s d c c te F o r v a le o f th e te r m is r is tic o f Problem 4.30 T h e a a n d s T h e F (a s in c o m p n s w e q u a re o u r ie P ro b u te d r is ro o r tra le m d ire n o . T ts in v n s fo r 4 .2 8 ) c tly in h e F o u r ie r tr o lv e d in c o m m c o u ld b e u , b u t th e s q u th e s p a tia l d a n s fo r m is p u tin g th e s e d to c o m a re s , s q u a r o m a in . a lin g ra d p u te e ro o e a r p ro c e ie n t a re n th e d e r iv t, o r a b s o s s , w o n lin a tiv e lu te h ile e a r s a s v a lu th e o p e r d iffe e s m s q a t re u u a re io n s . n c e s s t b e Problem 4.31 W e w a n t to s h o w th a t = − 1 A e − (μ 2 + ν 2 )/ 2 σ 2 = A 2 π σ 2 e − 2 π 2 σ 2 (t 2 + z 2 ) . T h e e x p la n a tio n w ill b e c le a r e r if w e s ta r t w ith o n e v a r ia b le . W e w a n t to s h o w th a t, if H (μ ) = e − μ 2 / 2 σ 2 7 5 th e n h (t ) − 1 = = H (μ ) 1 = − 1 p = 2 − μ e 2 π σ 2 / 2 σ 2 − 2 π σ j 2 t μ t e 2 2 t d μ . W e c a n e x p re s s th e in te g r a l in th e p re c e d in g e q u a tio n s a s 1 h (t ) = 1 2 σ 2 − e 2 [μ 2 − j 4 π σ μ t ] d μ . − 1 M a k in g u s e o f th e id e n tity e (2 π )2 σ 2 t 2 2 − (2 π )2 σ 2 t 2 2 e = 1 in th e p r e c e d in g in te g r a l y ie ld s h (t ) = = e e 1 (2 π )2 σ 2 t 2 2 − − e − 1 2 σ 2 [μ e − 1 2 σ 2 [μ − j 2 π σ − 1 1 (2 π )2 σ 2 t 2 2 2 2 − j 4 π σ 2 μ t − (2 π )2 σ t ] 2 4 t 2 ] d μ . d μ . − 1 2 N e x t, w e m a k e th e c h a n g e o f v a r ia b le s r = μ − j 2 π σ p re c e d in g in te g r a l b e c o m e s − h (t ) = e 1 (2 π )2 σ 2 t 2 2 r 2 2 σ 2 − e t . T h e n , d r = d μ a n d th e d r . − 1 F in a lly , w e m u ltip ly a n d d iv id e th e r ig h t s id e o f th is e q u a tio n b y ta in ⎤ ⎡ 1 p r 2 (2 π )2 σ 2 t 2 1 − − ⎣p 2 h (t ) = 2 π σ e e 2σ2 d r ⎦. 2 π σ − 1 p 2 π σ a n d o b - T h e e x p r e s s io n in s id e th e b r a c k e ts is r e c o g n iz e d a s th e G a u s s ia n p r o b a b ility d e n s ity fu n c tio n w h o s e v a lu e fr o m - 1 to 1 is 1 . T h e r e fo r e , h (t ) = p − 2 π 2 π σ e 2 2 σ 2 t . W ith th e p r e c e d in g r e s u lts a s b a c k g r o u n d , w e a r e n o w r e a d y to s h o w th a t h (t ,z ) − 1 A e A 2 π σ 2 = = = e − (μ 2 − 2 π 2 + ν 2 σ 2 )/ 2 σ (t 2 + z 2 2 ) . C H A P T E R 4 . P R O B L E M S O L U T IO N S 7 6 B y s u b s titu tin g d ir e c tly in to th e d e fi n itio n o f th e in v e r s e F o u r ie r tr a n s fo r m w e h a v e : h (t ,z ) 1 = 1 − 1 1 = ⎡ − 1 2 − (μ A e 1 ⎣ )/ 2 σ 2 j 2 π (μ t + ν z ) e ⎤ ! μ 2 2 σ 2 − A e − 1 2 + ν + j 2 π μ t d μ d ν " d μ ⎦e − # ν 2 2 σ 2 + j 2 π ν z d ν . − 1 T h e in te g r a l in s id e th e b r a c k e ts is re c o g n iz e d fr o m th e p re v io u s d is c u s s io n to b e p 2 2 2 e q u a l to A 2 π σ e − 2 π σ t . T h e n , th e p re c e d in g in te g r a l b e c o m e s h (t ,z ) = A p − 2 π 2 π σ e 2 2 σ " 1 2 t − e ν 2 2 σ 2 # + j 2 π ν z − 1 W e n o w re c o g n iz e th e re m a in in g in te g r a l to b e e q u a l to w h ic h w e h a v e th e fi n a l r e s u lt: p p 2 2 2 2 π σ e − h (t ,z ) = A 2 π σ e − 2π σ t = A 2 π σ 2 e 2 − 2 π σ 2 (t 2 + z 2 ) d ν . p 2 π 2 π σ e 2 2 σ z − 2 π 2 σ 2 z 2 , fro m 2 . Problem 4.32 T h e s p a tia l fi lte r is o b ta in e d b y ta k in g th e in v e r s e F o u r ie r tr a n s fo r m o f th e fr e q u e n c y d o m a in fi lte r : h H P (t ,z ) = = = = = − 1 1 − H L P − 1 [1 ] − = − 1 δ (0 ) − A 2 π σ (μ ,ν ) H 2 e L P ( μ − 2 π 2 σ ,ν ) 2 (t 2 + z 2 ) . T h is r e s u lt is fo r c o n tin u o u s fu n c tio n s . T o u s e th e m w ith d is c r e te v a r ia b le s w e s im p ly s a m p le th e fu n c tio n in to its d e s ir e d d im e n s io n s . Problem 4.33 T h e c o m p le x c o n ju g a te s im p ly c h a n g e s j to − j in th e in v e r s e tr a n s fo r m , s o th e im a g e o n th e r ig h t is g iv e n b y M − 1 N − 1 = − 1 F ∗ (u ,v ) = x = 0 F (u ,v )e − j 2 π (u x / M + v y / N ) F (u ,v )e j 2 π (u (− x )/ M + v (− y )/ N ) y = 0 M − 1 N − 1 = x = 0 = y = 0 f (− x ,− y ) 7 7 w h ic h s im p ly m ir r o r s f (x , y ) a b o u t th e o r ig in , th u s p r o d u c in g th e im a g e o n th e r ig h t. Problem 4.34 T h e e q u a lly - s p a c e d , v e r tic a l b a r s o n th e le ft, lo w e r th ir d o f th e im a g e . Problem 4.35 W ith c a n b k n o w g iv e s re fe re n c e to e e x p re s s e d d o n o t h a v e a n im p u ls e a E q . a 1 a n t th (4 m im e o .9 - 1 ), in u s p u ls e r ig in a ll th e th e tra a t th e in th e h ig h p a n s fe r fu o r ig in ). h ig h p a s s s fi n c t T h s s p lt io e a e rs n o in v tia l in d is c u s s e d in S e c t io n 4 .9 f lo w p a s s fi lte r (w h ic h w e e r s e F o u r ie r tr a n s fo r m o f 1 fi lte r s . Problem 4.36 ( o t r a o a ) T h e r in g in fa n ly (th e fo llo w in h e d a rk c e n te r a e s u lt lo o k s s o b r re m u c h h ig h e r f th e r e s u lt. c t g re ig th h a s a d a rk c e im a g e s h o w s a is a v e r a g e d h t is th a t th e a n a n y w h e re n te r a re a a s a re s u th e r e s u lt o f h ig h p o u t b y th e lo w p a s d is c o n tin u ity (e d g e ls e in th e im a g e , lt o f th e h ig h p a s s o p e r a tio n a s s fi lte r in g o n ly ). H o w e v e r, s fi lte r. T h e r e a s o n th e fi n a l e ) o n b o u n d a r ie s o f th e r in g th u s d o m in a tin g th e d is p la y ( b ) F ilte r in g w ith th e F o u r ie r tr a n s fo r m is a lin e a r p r o c e s s . T h e o r d e r d o e s n o t m a tte r. Problem 4.37 ( a ) O n e a p p lic a tio n o f th e fi lte r g iv e s : G (u ,v ) = H (u ,v )F (u ,v ) = e 2 − D (u ,v )/ 2 D 0 2 F (u ,v ). S im ila r ly , K a p p lic a tio n s o f th e fi lte r w o u ld g iv e G T h e in v e th e G a u s p a s s fi lte v a lu e o f lo w p a s s rs e D F T s ia n fi lte r, p a s s in th e im a g fi lte r in g o r. g e w K (u ,v ) = e − K D f G K (u , v ) w o u ld g iv If K is “ la r g e e n o u g h o n ly F (0 , 0 ). W e k n o . S o , th e r e is a v a lu e ill s im p ly p r o d u c e a 2 (u ,v )/ 2 D e th e ,” t h e w th a o f K c o n s t 0 2 F (u ,v ). im a g e r e s u ltin g G a u s s ia n L P F w t th is te r m is e q a fte r w h ic h th e a n t im a g e . T h e fro m K ill b e c o m u a l to th r e s u lt o f v a lu e o f p a s e a e a v re p a ll s e s o f n o tc h e ra g e e a te d p ix e ls C H A P T E R 4 . P R O B L E M S O L U T IO N S 7 8 F ig u r e P 4 .3 6 . o n th p r o f th is e a n s o a c h fi lte r im w e a n in g a g e w ill b e e q u a l to th e a v e r a g e v a lu e o f th e o r ig in a l im a g e . N o te th a t r a p p lie s e v e n a s K a p p r o a c h e s in fi n ity . In th is c a s e th e fi lte r w ill a p im p u ls e a t th e o r ig in , a n d th is w o u ld s till g iv e u s F (0 , 0 ) a s th e r e s u lt . ( b ) T o g u a r a n te e th e r e s u lt in (a ), K h a s to b e c h o s e n la r g e e n o u g h s o th a t th e fi lte r b e c o m e s a n o tc h p a s s fi lte r (a t th e o r ig in ) fo r a ll v a lu e s o f D (u , v ). K e e p in g in m in d th a t in c r e m e n ts o f fr e q u e n c ie s a r e in u n it v a lu e s , th is m e a n s H K (u ,v ) = e − K D 2 (u ,v )/ 2 D 0 2 = 0 1 if (u ,v ) = (0 ,0 ) O th e r w is e . B e c a u s e u a n d v a r e in te g e r s , th e c o n d itio n s o n th e s e c o n d lin a r e s a tis fi e d fo r a ll u > 1 a n d / o r v > 1 . W h e n u = v = 0 , H K (u , v ) = 1 , a s d e s ir e d . W e w a n t a ll v a lu e s o f th e fi lte r to b e o f t h e d is t a n c e fr o m t h e o r ig in t h a t a r e g r e a t e r t h a n 0 ( i.e ., fo r v v g r e a te r th a n 0 ). H o w e v e r, th e fi lte r is a G a u s s ia n fu n c tio n , s o g r e a te r th a n 0 fo r a ll fi n ite v a lu e s o f D (u , v ). B u t, w e a r e d e n u m b e r s , w h ic h w ill b e d e s ig n a te d a s z e r o w h e n e v e r th e v a lu e th a n o n e - h a lf th e s m a lle s t p o s itiv e n u m b e r r e p r e s e n ta b le in th u s e d . A s g iv e n in th e p r o b le m s ta te m e n t, th e v a lu e o f th is n u v a lu e s o f K fo r w h ic h fo r w h ic h th e fi lte r fu n c tio n is g r e a te r t e in th is e q u a tio n D (u ,v ) = 0 , a n d z e r o fo r a ll v a lu e s a lu e s o f u a n d / o r its v a lu e is a lw a y s a lin g w ith d ig ita l o f th e fi lte r is le s s e c o m p u te r b e in g m b e r i s c m in . S o , h a n 0 .5 × c m in w i ll 7 9 s u ffi c e . T h a t is , w e w a n t th e m in im u m v a lu e o f K fo r w h ic h e − K D 2 (u ,v )/ 2 D 0 2 < 0 .5 c m in o r > K > A s n o B e c a u o r ig in th e re ln (0 .5 c − 2 D − 2 D ) m in (u ,v )/ 2 D 0 2 ln (0 .5 c 2 D 0 2 ) m in . (u ,v ) e q u a tio n fo r h o ld fo r a ll v a lu e s o f D 2 (u , v ) > 0 . a s e s a s a fu n c tio n o f in c re a s in g d is ta n c e fr o m th e p o s s ib le v a lu e o f D 2 (u , v ), w h ic h is 1 . T h is g iv e s te d a b o v e , w e w a n t th is s e th e e x p o n e n tia l d e c re , w e c h o o s e th e s m a lle s t s u lt K > − 2 D 2 0 ln (0 .5 c m in ) w h i c h y i e ld s a p o s i t i v e n u m b e r b e c a u s e c m in < < 1 . T h i s r e s u lt g u a r a n t e e s t h a t th e lo w p a s s fi lte r w ill a c t a s a n o tc h p a s s fi lte r, le a v in g o n ly th e v a lu e o f th e tr a n s fo r m a t th e o r ig in . T h e im a g e w ill n o t c h a n g e p a s t th is v a lu e o f K . Problem 4.38 ( a ) T h e k e y fo r th e s tu d e n t to b e a b le to s o lv e th is p r o b le m is to tr e a t th e n u m b e r o f a p p lic a tio n s (d e n o te d b y K ) o f th e h ig h p a s s fi lte r a s 1 m in u s K a p p lic a tio n s o f th e c o r r e s p o n d in g lo w p a s s fi lte r, s o th a t H K (u ,v ) = = H K (u ,v )F (u ,v ) $ 2 1 − e − K D (u ,v )/ 2 w h e r e th e G a u s s ia n lo w p a s s fi lte r r e c tly w ith th e e x p r e s s io n o f th e a n d a tte m p t to r a is e it to th e K th p T h e s o lu tio n to th e p r o b le m p h o w e v e r, th e fi lte r w ill a p p r o a c h a w ill p r o d u c e a n im a g e w ith z e r o a v th e r e is a v a lu e o f K a fte r w h ic h s im p ly p r o d u c e a c o n s ta n t im a g e . D 0 2 % H (u ,v ) is G o a n e fr o m P r o b le m 4 .3 7 . S t u d e n t s w h o s t a r t d i2 2 a u s s i a n h i g h p a s s fi l t e r 1 − e − K D (u ,v )/ 2 D 0 w e r w ill r u n in to a d e a d e n d . r a lle ls t h e s o lu t io n o f P r o b le m 4 .3 7 . H e r e , o tc h fi lte r th a t w ill ta k e o u t F (0 , 0 ) a n d th u s r a g e v a lu e (th is im p lie s n e g a tiv e p ix e ls ). S o , th e r e s u lt o f r e p e a te d h ig h p a s s fi lte r in g w ill ( b ) T h e p r o b le m h e r e is to d e te r m in e th e v a lu e o f K fo r w h ic h H K (u ,v ) = 1 − e − K D 2 (u ,v )/ 2 D 0 2 = 1 0 if (u ,v ) = (0 ,0 ) o th e r w is e . C H A P T E R 4 . P R O B L E M S O L U T IO N S 8 0 B e c a u s e u a n d v a r e in te g e r s , th e c o n d itio n s o n th e s e c o n d lin e in th is e q h a v e to b e s a tis fi e d fo r a ll u ≥ 1 a n d / o r v ≥ 1 . W h e n u = v = 0 , D (u , v ) = H K (u , v ) = 0 , a s d e s ir e d . W e w a n t a ll v a lu e s o f th e fi lte r to b e 1 fo r a ll v a t h e d is t a n c e fr o m t h e o r ig in t h a t a r e g r e a t e r t h a n 0 ( i.e ., fo r v a lu e s o f u a n g re a te r th a n 0 ). F o r H K (u ,v ) to b e c o m e 1 , th e e x p o n e n tia l te r m h a s to b 0 fo r v a lu e s o f u a n d / o r v g r e a te r th a n 0 . T h is is th e s a m e r e q u ir e m e n P r o b le m 4 .3 7 , s o th e s o lu tio n o f t h a t p r o b le m a p p lie s h e r e a s w e ll. u a tio n 0 , a n d lu e s o f d / o r v e c o m e t a s in Problem 4.39 ( a ) E x p r e s s fi lte r in g a s c o n v o lu tio n to r e d u c e a ll p r o c e s s e s to th e s p a tia l d o m a in . T h e n , th e fi lte r e d im a g e is g iv e n b y g (x ,y ) = h (x ,y ) f (x ,y ) w h e r e h is th e s p a tia l fi lte r (in v e r s e F o u r ie r tr a n s fo r m o f th e fr e q u e n c y - d o m a in fi lte r ) a n d f is th e in p u t im a g e . H is to g r a m p r o c e s s in g th is r e s u lt y ie ld s g 0(x ,y ) = = T g (x ,y ) T h (x ,y ) f (x ,y ) , w h e r e T d e n o te s th e h is to g r a m e q u a liz a tio n tr a n s fo r m a tio n . If w e h is to g r a m e q u a liz e fi r s t, th e n g (x ,y ) = T f (x ,y ) a n d g 0(x ,y ) = h (x ,y ) f (x ,y ) . T In g e n e r a l, T is a n o n lin e a r fu n c tio n d e te r m in e d b y th e n a tu r e o f th e p ix e ls in t h e i m a g e f r o m w h i c h i t i s c o m p u t e d . T h u s , i n g e n e r a l , T h ( x , y ) f ( x , y ) =6 h (x ,y ) T f (x ,y ) a n d th e o rd e r d o e s m a tte r. (b ) A tra s t m e n e q u a te r in e q u a s in o f a t is liz e g p r liz e d ic a te d in S e c n im a g e . A lth o u s u a lly n o t d r d fi r s t, th e g a in o c e s s . T h e re fo th e im a g e a fte t io n 4 .9 , h ig h p a s s fi lt e r in g s e v e r e ly d im in is u g h h ig h - fr e q u e n c y e m p h a s is h e lp s s o m e , a m a t ic ( s e e F ig . 4 .5 9 ) . T h u s , if a n im a g e in c o n tr a s t im p r o v e m e n t w ill e s s e n tia lly b e r e , th e p r o c e d u r e in g e n e r a l is to fi lte r fi r s t a n r th a t. h e s th e c o n th e im p r o v e is h is to g r a m lo s t in th e fi ld h is to g r a m - Problem 4.40 F r o m E q . ( 4 .9 - 3 ) , t h e t r a n s fe r fu n c t io n o f a B u t t e r w o r t h h ig h p a s s fi lt e r is H (u ,v ) = $ 1 + 1 D 0 D (u ,v ) %2 n . 8 1 W e w a n t th e fi lte r to h a v e a v a lu e o f γ L w h e n D (u h ig h v a lu e s o f D (u , v ). T h e p r e c e d in g e q u a tio n is th is : (γ H − γ H (u ,v ) = γ L + $ D 0 1 + D (u ,v ,v ) = 0 , a n d a p p ro a c h γ H fo r e a s ily m o d ifi e d to a c c o m p lis h ) %2 n . L ) T h e v a lu e o f n c o n tr o ls th e s h a r p n e s s o f th e tr a n s itio n b e tw e e n γ L a n d γ H . Problem 4.41 B e c a u s e M = 2 n , w e c a n w r it e E q s . ( 4 .1 1 - 1 6 ) a n d ( 4 .1 1 - 1 7 ) a s 1 m (n ) = M n 2 a n d a (n ) = M n . P r o o f b y in d u c tio n b e g in s b y s h o w in g th a t b o th e q u a tio n s h o ld fo r n = 1 : m (1 ) = 2 1 (2 )(1 ) = 1 a (1 ) = (2 )(1 ) = 2 . a n d W e k n o w t h e s e r e s u lt s t o b e c o r r e c t fr o m t h e d is c u s s io n in S e c t io n 4 .1 1 .3 . N e x t , w e a s s u m e th a t th e e q u a tio n s h o ld fo r n . T h e n , w e a r e r e q u ir e d to p r o v e th a t t h e y a ls o a r e t r u e fo r n + 1 . F r o m E q . ( 4 .1 1 - 1 4 ) , m (n + 1 ) = 2 m (n ) + 2 n . S u b s titu tin g m (n ) fr o m a b o v e , m (n + 1 ) = 1 + 2 2 n n 2 (n + 1 ) + 2 2 2 = 2 1 = = M n 2 n 1 2 2 n + 1 n (n + 1 ). T h e r e fo r e , E q . ( 4 .1 1 - 1 6 ) is v a lid fo r a ll n . F r o m E q . ( 4 .1 1 - 1 7 ) , a (n + 1 ) = 2 a (n ) + 2 n n + 1 . C H A P T E R 4 . P R O B L E M S O L U T IO N S 8 2 S u b s titu tin g th e a b o v e e x p r e s s io n fo r a (n ) y ie ld s a (n + 1 ) = 2 M n + 2 = 2 (2 = 2 n n + 1 n + 1 n ) + 2 n + 1 (n + 1 ) w h ic h c o m p le te s th e p r o o f. Problem 4.42 C o n s id e r a s in g le s ta r, m o d e le d a s a n im p u ls e δ (x − x f (x ,y ) = K δ (x − x 0 ,y − y 0 ). T h e n , 0 ,y − y 0 ) fr o m w h ic h z (x ,y ) = = ln f (x , y ) = ln K + ln δ (x − x 0 K 0 + δ (x − x 0 0 ,y − y 0 ) ,y − y 0 ). T a k in g th e F o u r ie r tr a n s fo r m o f b o th s id e s y ie ld s = z (x ,y ) = = F r o m th is r e s u lt, it is e v id e n t th a a t th e o r ig in o f th e fr e q u e n c y p la p o n e n t w ill ta k e c a r e o f th e p r o b im p u ls e s (s ta r s ) is im p le m e n te d th e fi lte r w ill b e th e s a m e . A t th e c o m b in e d b y a d d itio n , fo llo w e d n e s s b e tw e e n th e s ta r s is p re s e r v = K 0 + = δ (0 ,0 ) + e δ 0(x − x − 2 π (u x 0 0 ,y − y 0 ) + v y 0 ) . t th e c o n tr ib u tio n o f illu m in a tio n is a n im p u ls e n e . A n o tc h fi lte r th a t a tte n u a te s o n ly th is c o m le m . E x te n s io n o f th is d e v e lo p m e n t to m u ltip le b y c o n s id e r in g o n e s ta r a t a tim e . T h e fo r m o f e n d o f th e p r o c e d u r e , a ll in d iv id u a l im a g e s a r e b y in te n s ity s c a lin g s o th a t th e r e la tiv e b r ig h te d . Problem 4.43 T h e p r o b le m c a n b e s o lv e d b y c a r r y in g o u t th e fo llo w in g s te p s : 1 . P e r fo r m a m e d ia n fi lte r in g o p e r a tio n . 2 . F o llo w (1 ) b y h ig h - fr e q u e n c y e m p h a s is . 3 . H is to g r a m - e q u a liz e th is r e s u lt. 4 . C o m p u te th e a v e r a g e g r a y le v e l, K 0 . A d d th e q u a n tity (K − K 0 ) to a ll p ix e ls . 8 3 Output I I 1 Input r 2 F ig u r e P 4 .4 3 5 . P e r fo r m t h e t r a n s fo r m a t io n s s h o w n in F ig . P 4 .4 3 , w h e r e r is t h e in p u t g r a y le v e l, a n d R , G , a n d B a r e fe d in to a n R G B c o lo r m o n ito r. to to to to to to to to to p p p p p p p p p w w w w w w w w w h h h h h h h h h ite ite ite ite ite ite ite ite ite c h c h c h c h c h c h c h c h c h a r a r a r a r a r a r a r a r a r a c a c a c a c a c a c a c a c a c te te te te te te te te te r to r to r to r to r to r to r to r to r to fo fo fo fo fo fo fo fo fo rc rc rc rc rc rc rc rc rc e fi e fi e fi e fi e fi e fi e fi e fi e fi g u g u g u g u g u g u g u g u g u re re re re re re re re re to to to to to to to to to th th th th th th th th th e t e t e t e t e t e t e t e t e t o p o p o p o p o p o p o p o p o p w w w w w w w w w h h h h h h h h h it it it it it it it it it e c e c e c e c e c e c e c e c e c h h h h h h h h h a r a r a r a r a r a r a r a r a r a c a c a c a c a c a c a c a c a c te te te te te te te te te r t r t r t r t r t r t r t r t r t o o o o o o o o o fo fo fo fo fo fo fo fo fo rc rc rc rc rc rc rc rc rc e fi e fi e fi e fi e fi e fi e fi e fi e fi g u g u g u g u g u g u g u g u g u re re re re re re re re re to to to to to to to to to th th th th th th th th th e e e e e e e e e Chapter 5 Problem Solutions Problem 5.1 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .1 , fr o m le ft t o r ig h t . F ig u r e P 5 .1 Problem 5.2 T h e s o lu tio n s a r e s h o w n in th e fo llo w in g fi g u r e , fr o m le ft to r ig h t. F ig u r e P 5 .2 8 5 8 6 C H A P T E R 5 . P R O B L E M S O L U T IO N S Problem 5.3 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .3 , fr o m le ft t o r ig h t . F ig u r e P 5 .3 Problem 5.4 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .4 , fr o m le ft t o r ig h t . F ig u r e P 5 .4 Problem 5.5 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .5 , fr o m le ft t o r ig h t . F ig u r e P 5 .5 8 7 Problem 5.6 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .6 , fr o m le ft t o r ig h t . F ig u r e P 5 .6 Problem 5.7 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .7 , fr o m le ft t o r ig h t . F ig u r e P 5 .7 Problem 5.8 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .8 , fr o m le ft t o r ig h t . F ig u r e P 5 .8 C H A P T E R 5 . P R O B L E M S O L U T IO N S 8 8 F ig u r e P 5 .9 Problem 5.9 T h e s o lu t io n s a r e s h o w n in F ig . P 5 .9 , fr o m le ft t o r ig h t . Problem 5.10 (a ) T h e p ix e l is z p o in ts v th e a r ith k e y to e ro . D a lu e d m e tic th is p r o b le m is th a r a w a p r o fi le o f a n id 1 . T h e g e o m e tr ic m m e a n w ill g iv e in te r t th e g e o m e tr e a l e d g e w ith e a n w ill g iv e o m e d ia te v a lu e ic m e a n is z e r o w h e n e v e r a n y a fe w p o in ts v a lu e d 0 a n d a fe w n ly v a lu e s o f 0 a n d 1 , w h e r e a s s (b lu r ). ( b ) B la c k is 0 , s o th e g e o m e tr ic m e a n w ill r e tu r n v a lu e s o f 0 a s lo n g a s a t le a s t o n e p ix e l in th e w in d o w is b la c k . B e c a u s e th e c e n te r o f th e m a s k c a n b e o u ts id e th e o r ig in a l b la c k a r e a w h e n th is h a p p e n s , th e fi g u r e w ill b e th ic k e n e d . Problem 5.11 T h e k e y to u n d e r s ta n d in g th o f th e p ix e ls in th e n e ig h b o s ta n t, w ith th e im p u ls e n o is e th e n o is e s p ik e to b e v is ib le , o f its n e ig h b o r s . A ls o k e e p in p o w e r in th e d e n o m in a to r. e b e h a r h o o d p o in t its v a lu m in d v io r o f th e c o n tr a - h a r m s u r r o u n d in g a n o is e im b e in g in th e c e n te r o f th e m u s t b e c o n s id e r a b ly th a t th e p o w e r in th e n u ( a ) B y d e fi n itio n , p e p p e r n o is e is a lo w v a lu e (r e a s u r r o u n d e d b y lig h t v a lu e s . T h e c e n te r p ix e l (th e in fl u e n c e in th e s u m s . If th e a re a s p a n n e d b y th s ta n t, th e r a tio w ill a p p r o a c h th e v a lu e o f th e p ix e r e d u c in g th e e ffe c t o f th e lo w - v a lu e p ix e l. F o r e x a th e fi lte r fo r a d a r k p o in t o f v a lu e 1 in a 3 × 3 r e g io Q = 0 .5 , fi lt e r = 9 8 .7 8 ; fo r Q = 1 , fi lt e r = 9 9 .8 8 , fo Q = 5 , fi lt e r = 1 0 0 .0 0 . o n ic fi lte r is to th p u ls e a s b e in g c e n e ig h b o r h o o d . la r g e r th a n th e v a m e r a to r is 1 p lu s lly 0 ). It is m o s p e p p e r n o is e ), e fi lte r is a p p r o ls in th e n e ig h b m p le , h e r e a r e s n w ith p ix e ls o f r Q = 2 , fi lte r = t w x o o v 9 in o n F o lu th k r e e v is ib le w h e n ill h a v e little im a te ly c o n r h o o d — th u s m e v a lu e s o f a lu e 1 0 0 : F o r 9 .9 9 ; a n d fo r 8 9 (b ) T h e s m a ll. T n e g a tiv e th e n b e a s a th e p ix e ls in (c ) W h e n o is e w F o r s a lt n o is e — re v e rs e h a p p e n s h e c e n te r p ix e l w , s o th e s m a ll n u th o u g h t o f a c o n s a m e c o n s ta n t ra th e n e ig h b o r h o o n th e ill b e r n o is e th e im (d ) W h e n n u m b e r o n o m in a to e x a m p le , 9 / [1 / p 1 + T h u s , lo w If, fo r e x a re s p o n s e Q = f p ix r a re fo r a 1 / p 2 p ix e m p le w ill b w ro a is e th e a g e n g p o d to a im a g e w ill b w h e n t ill n o w m b e rs s ta n t ra is e d to d . S o th la r ity is p o s itiv e w ill b e c e c o m e d h e c e n te r p o in t is la r g e a b e th e la r g e s t. H o w e v e r, w ill d o m in a te th e r e s u lt. is e d to th e p o w e r Q + 1 a th e p o w e r Q . T h a t c o n s ta e r a tio is ju s t th a t v a lu e . n d its n e ig th e e x p o n e T h e n u m e n d th e d e n n t is th e v a h b o rs a re n t is n o w ra to r c a n o m in a to r lu e o f th e u s e d , th e la r g e n u m b e r s in th e c a s e o f th e s a lt p o w e r, th u s th e n o is e w ill o v e r p o w e r th e r e s u lt. o m e v e r y lig h t. T h e o p p o s ite is tr u e fo r p e p p e r a rk . − 1 , th e v a lu e o f th e n u m e r a to r a t a n y lo c a tio n is e q u a l to th e e ls in th e n e ig h b o r h o o d (m n ). T h e te r m s o f th e s u m in th e d e 1 d iv id e d b y in d iv id u a l p ix e l v a lu e s in th e n e ig h b o r h o o d . F o r 3 × 3 e n ig h b o r h o o o d , th e r e s p o n s e o f th e fi lte r w h e n Q = − 1 is : + · · · 1 / p 9 ] w h e r e t h e p ’s a r e t h e p i x e l v a l u e s i n t h e n e i g h b o r h o o d . l v a lu e s w ill te n d to p r o d u c e lo w fi lte r r e s p o n s e s , a n d v ic e v e r s a . , th e fi lte r is c e n te r e d o n a la r g e s p ik e s u r r o u n d e d b y z e r o s , th e e a lo w o u tp u t, th u s r e d u c in g th e e ffe c t o f th e s p ik e . ( e ) In a c o n s ta n t a r e a , th e fi lte r r e tu r n s th e v a lu e o f th e p ix e ls in th e a r e a , in d e p e n d e n tly o f th e v a lu e o f Q . Problem 5.12 A b a n d p a s s fi lte r is o b ta in e d b y s u b tr a c tin g th e c o r r e s p o n d in g b a n d r e je c t fi lte r fro m 1 : H (u ,v ) = 1 − H B P B R (u ,v ). T h e n : ( a ) Id e a l b a n d p a s s fi lte r : ⎧ ⎨ 0 H IB P (u ,v ) = ⎩ 1 0 i f D ( u , v ) < D 0 − W2 i f D 0 − W2 ≤ D ( u , v ) ≤ D D ( u , v ) > D 0 + W2 0 + W 2 . C H A P T E R 5 . P R O B L E M S O L U T IO N S 9 0 ( b ) B u tte r w o r th b a n d p a s s fi lte r : H (u ,v ) B B P = 1 − 1 & & D (u ,v )W 2 ( u ,v ) − D D = & 0 '2 0 n 2 n 2 D (u ,v )W D 2 (u ,v )− D 1 + '2 D (u ,v )W D 2 (u ,v )− D 1 + '2 0 . n 2 ( c ) G a u s s ia n b a n d p a s s fi lte r : ⎡ H G B P (u ,v ) ⎢ 1 − ⎣1 − e = = 2 e 2 D 2 (u ,v )− D 2 0 D (u ,v )W 1 − − ⎤ 2 D 2 (u ,v )− D 2 0 D (u ,v )W 1 ⎥ ⎦ 2 Problem 5.13 W e u s e h ig h p a s s fi lt e r s t o c o n s t r u c t n o t c h fi lt e r s , a s in d ic a t e d in E q . ( 4 .1 0 .2 ) . T h e id e a l n o tc h r e je c t fi tte r is g iv e n b y (3 H IN R (u ,v ) = H (u ,v )H k − k (u ,v ) k = 1 w h e re H k (u ,v ) = 0 if D if D 1 k k (u ,v ) ≤ D (u ,v ) > D 0 0 w ith D in w h ic h (u k ,v k k (u − M / 2 − u (u ,v ) = k )2 + (v − N / 2 − v k ) 2 ) a r e th e c e n te r s o f th e n o tc h e s . F o r th e G a u s s ia n fi lte r, H k (u ,v ) = 1 − e − D 2 k (u ,v )/ 2 D 0 2 a n d th e n o tc h r e je c t fi lte r is g iv e n b y (3 H G N R (u ,v ) = k = 1 $ 1 − e − D 2 k (u ,v )/ 2 D 0 2 %$ 1 − e − D 2 − k (u ,v )/ 2 D 0 2 % . 9 1 Problem 5.14 W e p r o c e e d a s fo llo w s : F (u ,v ) 1 = − 1 1 = − j 2 π (u x + v y ) f (x ,y )e A s in (u − j 2 π (u x + v y ) x + v 0 y )e 0 d x d y d x d y . − 1 U s in g th e e x p o n e n tia l d e fi n itio n o f th e s in e fu n c tio n , 1 s in θ = e j θ y ) − e 2 j − e − j θ g iv e s u s F (u ,v ) 1 − j A 2 = ⎡ − j A ⎣ 2 ⎡ j A ⎣ 2 = j (u e − 1 x + v 0 − j (u x + v 0 0 y ) − j 2 π (u x + v y ) e d x d y ⎤ 1 e 1 0 j 2 π (u 0 x / 2 π + v 0 y / 2 π ) e d x d y ⎦− − j 2 π (u x + v y ) − 1 e ⎤ − j 2 π (u 0 x / 2 π + v 0 y / 2 π ) e − j 2 π (u x + v y ) d x d y ⎦. − 1 T h e s e a re th e F o u r ie r tr a n s fo r m s o f th e fu n c tio n s j 2 π (u 1 × e x / 2 π + v 0 y / 2 π ) 0 a n d 1 × e r e s p e c tiv e ly . T h e F o u r ie r tr a n s f th e e x p o n e n tia ls s h ift th e o r ig in T a b le 4 .3 . T h u s , & − j A F (u ,v ) = δ u − 2 − j 2 π (u 0 x / 2 π + v 0 y / 2 π ) o r m o f th e 1 g iv e s a n im p u ls e a t th e o r ig in , a n d o f t h e im p u ls e , a s d is c u s s e d in S e c t io n 4 .6 .3 a n d u 2 π 0 ,v − v 2 π 0 ! − δ u + u 2 π 0 ,v + v 0 !' . 2 π Problem 5.15 F r o m E q . ( 5 .4 - 1 9 ) σ 2 = 1 (2 a + 1 ) (2 b + 1 ) g (γ ) − w η (γ ) − g − w η 2 C H A P T E R 5 . P R O B L E M S O L U T IO N S 9 2 w h e re “ γ ” in d ic a te s te r m s a ffe c te d b y th e s u m m a tio n s . L e ttin g K = 1 / (2 a + 1 )(2 b + 1 ), ta k in g th e p a r tia l d e r iv a tiv e o f σ 2 w ith re s p e c t to w a n d s e ttin g th e r e s u lt e q u a l to z e r o g iv e s @ σ @ w 2 = = g (γ ) − w η (γ ) − g + w η 2 K − g (γ )η (γ ) + g (γ )η + w η K 2 − η (γ ) + η (γ ) − w η (γ )η + g η (γ ) − g η − w η η (γ ) + w η = − g η + g η + w η = − g η + g η + w = 2 2 − w η " 2 η 2 − η = 0 2 + g η − g η − w η # 2 + w η 2 0 w h e r e , fo r e x a m p le , w e u s e d th e fa c t th a t 1 g (γ )η (γ ) = g η . (2 a + 1 ) (2 b + 1 ) S o lv in g fo r w g iv e s u s g η − g η w = η 2 − η 2 . F in a lly , in s e r tin g th e v a r ia b le s x a n d y , g (x ,y )η (x ,y ) − g (x ,y )η (x ,y ) w (x ,y ) = η 2 (x ,y ) − η 2 (x ,y ) w h ic h a g r e e s w it h E q . ( 5 .4 - 2 1 ) . Problem 5.16 F r o m E q . ( 5 .5 - 1 3 ) , 1 g (x ,y ) = f (α ,β )h (x − α ,y − β ) d α d β . − 1 It is g iv e n th a t f (x , y ) = δ (x − a ), s o f (α , β ) = δ (α − a ). T h e n , u s in g th e im p u ls e r e s p o n s e g iv e n in th e p r o b le m s ta te m e n t, g (x ,y ) = 1 − 1 δ (α − a )e − $ (x − α )2 + ( y − β ) 2 % d α d β 9 3 $ 1 = 1 = δ (α − a )e = e 2 (x − α ) ] e ( − [ 2 (x − a ) [ − δ (α − a )e 2 e ( − y − β 2 ) d α d β $ 1 ] d α $ 1 ] (x − α ) % 2 ) y − β − 1 − 1 − [ − ( − e y − β ) 2 % d β − 1 % d β − 1 w h e r e w e u s e d th e fa c t th a t th e in te g r a l o f th e im p u ls e is n o n z e r o o n ly w h e n α = a . N e x t, w e n o te th a t $ 1 ( − e ) y − β 2 % d β = − 1 $ 1 e ( − ) β − y 2 % d β − 1 w h ic h is in th e fo r m o f a c o n s ta n t tim e s a G a u s s ia n d e n s ity w ith v a r ia n c e σ p 1 / 2 o r s ta n d a rd d e v ia tio n σ = 1 / 2 . In o th e r w o rd s , $ e − ( β − y ) 2 ⎡ % 2 π (1 / 2 ) ⎣ = 1 − (1 / 2 ) e ( β − y ) 2 (1 / 2 ) 2 = ⎤ ⎦. 2 π (1 / 2 ) T h e in te g r a l fr o m m in u s to p lu s in fi n ity o f th e q u a n tity in s id e th e b r a c k e ts is 1 , s o p 2 π e − [ (x − a ) ] g (x ,y ) = w h ic h is a b lu r r e d v e r s io n o f th e o r ig in a l im a g e . Problem 5.17 F o llo w in g th e im a g e c o o r d in a te c o n v e n tio n in th e b o o k , v e r tic a l m o tio n is in th e x - d ire c tio n a n d h o r iz o n ta l m o tio n is in th e y - d ire c tio n . T h e n , th e c o m p o n e n ts o f m o tio n a r e a s fo llo w s : x 0 a t T 1 (t ) = a 0 ≤ t ≤ T 1 T 1 < t ≤ T 1 + T 2 a n d y 0 (t ) = 0 b (t − T 1 ) T 1 0 ≤ t ≤ T 1 T 1 < t ≤ T 1 + T 2 . C H A P T E R 5 . P R O B L E M S O L U T IO N S 9 4 T h e n , s u b s t it u t in g t h e s e c o m p o n e n t s o f m o t io n in t o E q . ( 5 .6 - 8 ) y ie ld s T H (u ,v ) T 1 + T 1 = − j 2 π [u a t / T 1 ] e e 0 T 1 π u a T − j π u a s in (π u a )e 2 − j 2 π u a + e e T 1 d t 1 2 d t 2 − j 2 π u a + e − j 2 π v b (t − T 1 )/ T 1 T T = − j π u a s in (π u a )e π u a = − j 2 π [u a + v b (t − T 1 )/ T 2 ) T 1 + T T = 2 d t + − j 2 π v b τ / T e 2 d τ 0 1 − j π u a s in (π u a )e π u a T − j 2 π u a + e 2 π v b s in (π v b )e − j π v b w h e r e in th e th ir d lin e w e m a d e th e c h a n g e o f v a r ia b le s τ = t − T 1 . T h e b lu r r e d im a g e is th e n g (x ,y ) = = − 1 [H (u ,v )F (u ,v )] w h e re F (u ,v ) is th e F o u r ie r tr a n s fo r m o f th e in p u t im a g e . Problem 5.18 F o llo w in g t h e p r o c e d u r e in S e c t io n 5 .6 .3 , T H (u ,v ) e − j 2 π u x e − j 2 π u e − j π u a t = (t ) 0 d t 0 T = [ (1 / 2 )a t 2 ]d t 0 T = 2 d t 0 T c o s (π u a t 2 ) − j s in (π u a t 2 ) d t = ) = 0 T 2 2 π u a T w h e re * C (z ) = a n d * S (z ) = p C ( 2 z 2 π T 2 π π u a T ) − j S ( c o s t 2 d t 0 z 0 s in t 2 d t . p π u a T ) 9 5 T h e s e a r e F r e s n e l c o s in e a n d s in e in te g r a ls . T h e y c a n b e fo u n d , fo r e x a m p le , th e H a n d b o o k o f M a th e m a tic a l F u n c tio n s , b y A b r a m o w itz , o r o th e r s im ila r r e fe re n c e . Problem 5.19 A b a s ic a p p r o a c h fo r re s to r in g a r o a g e fr o m r e c ta n g u la r to p o la r c o o d im e n s io n a l u n ifo r m m o tio n b lu r c u s s e d in th is c h a p te r fo r h a n d lin g b e a p p lie d to th e p r o b le m . T h e im o rd in a te s a fte r re s to r a tio n . T h e m w ith r e c ta n g u la r c o o r d in a te s (x , y ) c o o rd in a te s (r ,θ ), w h e re ta tio n a lly b lu r r e d im a g e is to c o n v e r t th e r d in a te s . T h e b lu r w ill th e n a p p e a r a s o a lo n g th e θ - a x is . A n y o f th e te c h n iq u e s u n ifo r m b lu r a lo n g o n e d im e n s io n c a n t a g e is th e n c o n v e r te d b a c k to r e c ta n g u la r a th e m a tic a l s o lu tio n is s im p le . F o r a n y p w e g e n e r a te a c o r re s p o n d in g p ix e l w ith p r = x 2 a n d θ = ta n A a B w w S d is p la y x is a n d e c a u s e e c a n u ith x = e c tio n s o f th e r e s u ltin g im a g w o u ld , in a d d itio n , a th e e x te n t o f th e ro t s e th e s a m e s o lu tio n θ a n d y = r to o b t 5 .7 t h r o u g h 5 .9 t h e n e w p p e a tio w e a in b e c − 1 + y im n e d is h e n c o ix e l o la r 2 ! y x . o u ld s h o w a n im a g e th a a r d is to r te d d u e to th e n a l b lu r is k n o w n (it is u s e d fo r u n ifo r m lin e a r th e tr a n s fe r fu n c tio n . o m e a p p lic a b le . t is b c o o r g iv e m o t A n y lu r r e d d in a te n a s π io n (S e o f th e a lo n g c o n v / 8 ra c tio n m e th th e θ e r s io n . d ia n s ), 5 .6 .3 ) , o d s in Problem 5.20 M e a s u r e th e a v e r a g e v a lu e o f th e b a c k g r o u n d . S e t a ll p ix e ls in th e im a g e , e x c e p t th e c r o s s h a ir s , to th a t in te n s ity v a lu e . D e n o te th e F o u r ie r tr a n s fo r m o f th is im a g e b y G (u ,v ). B e c a u s e th e c h a r a c te r is tic s o f th e c r o s s h a ir s a re g iv e n w ith a h ig h d e g re e o f a c c u r a c y , w e c a n c o n s tr u c t a n im a g e o f th e b a c k g r o u n d (o f th e s a m e s iz e ) u s in g th e b a c k g r o u n d in te n s ity le v e ls d e te r m in e d p r e v io u s ly . W e th e n c o n s tr u c t a m o d e l o f th e c r o s s h a ir s in th e c o r r e c t lo c a tio n (d e te r m in e d fr o m th e g iv e n im a g e ) u s in g th e d im e n s io n s p r o v id e d a n d in te n s ity le v e l o f th e c r o s s h a ir s . D e n o te b y F (u ,v ) th e F o u r ie r tr a n s fo r m o f th is n e w im a g e . T h e r a tio G (u , v )/ F (u , v ) is a n e s tim a te o f th e b lu r r in g fu n c tio n H (u , v ). In th e lik e ly e v e n t o f v a n is h in g v a lu e s in F (u , v ), w e c a n c o n s tr u c t a r a d ia lly - lim ite d fi lte r u s in g t h e m e t h o d d is c u s s e d in c o n n e c t io n w it h F ig . 5 .2 7 . B e c a u s e w e k n o w F (u , v ) a n d G (u , v ), a n d a n e s tim a te o f H (u , v ), w e c a n r e fi n e o u r e s tim a te o f th e b lu r r in g fu n c t io n b y s u b s t it u t in g G a n d H in E q . ( 5 .8 - 3 ) a n d a d ju s t in g K t o g e t a s C H A P T E R 5 . P R O B L E M S O L U T IO N S 9 6 c lo s e a s p o s s ib le to a g o o d r e s u lt fo r F (u , v ) (th e r e s u lt c a n b e e v a lu a te d v is u a lly b y ta k in g th e in v e r s e F o u r ie r tr a n s fo r m ). T h e r e s u ltin g fi lte r in e ith e r c a s e c a n th e n b e u s e d to d e b lu r th e im a g e o f th e h e a r t, if d e s ir e d . Problem 5.21 T h e k e y to s o lv in g th is p r o b le m is to r e c o g n iz e th a t th e g iv e n fu n c tio n , x h (x ,y ) = 2 2 + y 2 − 2 σ 4 σ x 2 + y 2 2 σ 2 − e is t h e t h e s e c o n d d e r iv a t iv e ( L a p la c ia n ) o f t h e fu n c t io n ( s e e S e c t io n 3 .6 .2 r e g a r d in g th e L a p la c ia n ) x 2 + y 2 2 σ 2 − s (x ,y ) = e . T h a t is , r 2 [s (x ,y )] 2 @ = 2 x = @ 2 s (x ,y ) s (x ,y ) + 2 @ x @ y 2 + y 2 − 2 σ 2 − x 2 + 2y 2 2 σ e . σ 4 ( T h is r e s u lt is d e r iv e d in S e c t io n 1 0 .2 .6 ) . S o , it fo llo w s t h a t H (u ,v ) = = h (x ,y ) = = 2 r s (x ,y ) . B u t, w e k n o w fr o m th e s ta te m e n t o f P r o b le m 4 .2 6 (a ) th a t = r 2 s (x ,y ) 2 = − 4 π 2 (u 2 + v )F (u ,v ) w h e re F (u ,v ) = = T h a G g iv a re e re a u e n th fo re s s ia in e e re , w e n fu n n tr y v e rs e h a v e c tio n 1 3 o f o f th re . T e d u c e d t F ro m th a b le 4 .3 e n tr y in = e − h e e b (n th p ro a s ic o te e ta x 2 + y 2 2 σ 2 = s (x ,y ) = e b le m to fo r m o f th a t (x ,y b le ), w e = 2 π σ 2 e − c o th ) h a x 2 + y 2 2 σ 2 . m p u tin g th e F o u r ie r tr a n s fo r m o f e G a u s s ia n F o u r ie r tr a n s fo r m p a ir a n d (u , v ) in th e p r e s e n t p r o b le m v e − 2 π 2 σ 2 (u 2 + v 2 ) 9 7 s o w e h a v e th e fi n a l r e s u lt H (u ,v ) 2 − 4 π = 3 − 8 π = 2 + v 2 (u 2 σ 2 (u − 4 π = 2 (u )F (u ,v ) 2 + v 2 2 + v 2 2 π σ ) 2 − 2 π )e 2 σ 2 − 2 π e 2 (u 2 σ 2 + v 2 (u 2 + v ) ) a s d e s ire d . K e e p in m in d th a t th e p re c e d in g d e r iv a tio n s a re b a s e d o n a s s u m in g c o n tin u o u s v a r ia b le s . A d is c r e te fi lte r is o b ta in e d b y s a m p lin g th e c o n tin u o u s fu n c tio n . Problem 5.22 T h is is a s im p le p lu g in p r o b le m . Its p u r p o s e is to g a in fa m ilia r ity w ith th e v a r io u s t e r m s o f t h e W ie n e r fi lt e r. F r o m E q . ( 5 .8 - 3 ) , jH ( u , v ) j2 1 H W (u ,v ) = H ( u , v ) jH ( u , v ) j2 + K w h e re jH (u , v )j2 = = ∗ (u ,v )H (u ,v ) H 2 (u ,v ) 6 6 4 π = T h e n , H ⎡ H W (u ,v ) = − ⎣ 3 − 8 π 6 6 4 π 2 + v 2 (u 2 (u 2 (u 2 σ 4 σ 4 σ + v 2 + v 2 )2 e − 2 π )e 2 − 4 π )2 e 2 − 4 π 2 σ 2 (u 2 2 (u 2 + v σ 2 σ 2 (u 2 + v 2 + v 2 ) . ⎤ ) ) + K ⎦. Problem 5.23 T h is a ls o is a s im p le p lu g in p r o b le m , w h o s e p u r p o s e is th e s a m e a s th e p r e v io u s p r o b le m . F r o m E q . ( 5 .9 - 4 ) H C (u ,v ) ∗ H = (u ,v ) jH (u , v )j + γ jP (u , v )j2 = 2 − 2 8 π 6 4 π 4 σ 4 (u 2 2 (u 2 + v 2 )2 e σ w h e re P (u ,v ) is th e F o u r ie r tr a n s fo r m o f th T h is is a s fa r a s w e c a n r e a s o n a b ly c a r r y th is o u t to s tu d e n ts th a t a fi lte r in th e fr e q u e n c y is d is c u s s e d in S e c t io n 4 .9 .4 [s e e E q . ( 4 .9 - 5 ) ]. fo r P (u , v ) h e r e w o u ld o n ly in c r e a s e th e n u m n o t h e lp in s im p lify in g th e e x p r e s s io n . + v − 4 π 2 − 2 π σ 2 )e σ 2 (u 2 + v 2 2 (u ) 2 + v 2 ) + γ jP ( u , v ) j2 e L a p la c ia n o p e r a to r [E q . (5 p r o b le m . It is w o r th w h ile p o d o m a in fo r th e L a p la c ia n o p H o w e v e r, s u b s titu tin g th a t s o b e r o f te r m s in th e fi lte r a n d .9 - 5 ) ]. in tin g e ra to r lu tio n w o u ld C H A P T E R 5 . P R O B L E M S O L U T IO N S 9 8 Problem 5.24 B e c a u (5 .5 - 1 o f th e a n d n th e c o s e th e s 7 ) h o ld s s y s te m o is e a re m p le te y s te . F u fi rs t u n c re s p m is r th e to F o rre o n s a s s u m e d r m o re , w e (u ,v ) a n d la te d . T h e e . F ir s t, u s G 1 lin e a c a n th e n s u m in g o r a n d p u s e s u p to N (u o f th e n ly F (u o s e r ,v tw ,v itio p o s ) b e o in ), n in v a itio n a c a u s e d iv id u r ia n d w e a l n t, o b k n re s it fo llo w s ta in th e r o w th a t th p o n s e s th th a t E e s p o n e im a e n g iv q . s e g e e s (u ,v ) = H (u ,v )F (u ,v ) a n d jG 1 (u , v )j2 = jH (u , v )j2 jF (u , v )j2 . T h e n , u s in g o n ly N (u , v ), G (u ,v ) = N (u ,v ) 2 a n d , jG 2 ( u , v ) j2 = jN ( u , v ) j2 s o th a t, jG ( u , v ) j2 jG = = 1 ( u , v ) j 2 + jG 2 (u , v )j2 jH ( u , v ) j2 jF ( u , v ) j2 + jN ( u , v ) j2 . Problem 5.25 (a ) It is g iv e n th a t F^ ( u , v ) 2 = jR ( u , v ) j2 jG ( u , v ) j2 . F r o m P r o b le m 5 .2 4 ( r e c a ll t h a t t h e im a g e a n d n o is e a r e a s s u m e d t o b e u n c o r r e la te d ), 2 F^ ( u , v ) = j R ( u , v ) j 2 j H ( u , v ) j 2 j F ( u , v ) j 2 + j N ( u , v ) j 2 . F o rc in g F^ ( u , v ) 2 t o e q u a l jF (u , v )j2 g iv e s R (u ,v ) = jF (u , v )j2 1 / 2 . jH ( u , v ) j2 jF ( u , v ) j2 + jN ( u , v ) j2 (b ) F^ ( u , v ) = R (u , v )G (u , v ) jF (u , v )j2 = = jH ( u , v ) j2 jF ( u , v ) j2 + jN ( u , v ) j2 ⎤1 / 2 ⎡ 1 ⎥ ⎢ ⎦ G (u ,v ) ⎣ jN ( u ,v ) j2 2 j H ( u , v ) j + jF ( u ,v ) j2 1 / 2 G (u ,v ) 9 9 a n d , b e c a u s e jF (u , v )j2 = S f (u , v ) a n d jN (u , v )j2 = S η ⎤1 / 2 ⎡ ⎢ F^ ( u , v ) = ⎣ 1 jH ( u , v ) j2 + S η S f (u ,v ) (u ,v ) ⎥ ⎦ (u ,v ), G (u ,v ). Problem 5.26 O n a b a s a s (4 ) e p lu r s m c lo U s o s s ib le s o lu tio n : (1 ) P e r fo re d im a g e o f a b r ig h t, s in g a ll a s p o s s ib le in th e fi e ld s e ly a s p o s s ib le . (3 ) T h e F e a W ie n e r fi lte r a n d v a r y r le o o K m im a g e a v e s ta r to s im u f v ie w o f th e u r ie r tr a n s fo u n til th e s h r a g in g la te a n te le s c r m o f a rp e s t to re d u c e n o is im p u ls e (th e s o p e to s im u la t th is im a g e w ill im a g e p o s s ib le e . (2 ta r s e a n g iv e is o ) O b ta in h o u ld b e im p u ls e H (u ,v ). b ta in e d . Problem 5.27 T h e b a s ic id e a b e h in d th is p r o b le m is to u s e th e c a m e r a a n d r e p r e s e n ta tiv e c o in s to m o d e l th e d e g r a d a tio n p r o c e s s a n d th e n u tiliz e th e r e s u lts in a n in v e r s e fi lte r o p e r a tio n . T h e p r in c ip a l s te p s a r e a s fo llo w s : 1 . S e le c t c o in s a s c lo s e a s p o s s ib le in s iz e a n d c o n te n t a s th e lo s t c o in s . S e le c t a b a c k g r o u n d th a t a p p r o x im a te s th e te x tu re a n d b r ig h tn e s s o f th e p h o to s o f th e lo s t c o in s . 2 . S e t u p th e m u s e u m p h o to g r a p h ic c a m e r a in b le to g iv e im a g e s th a t r e s e m b le th e im a g e s p a y in g a tte n tio n to illu m in a tio n ). O b ta in a e x p e r im e n ta tio n , o b ta in a T V c a m e r a c a p a s e m b le th e te s t p h o to s . T h is c a n b e d o n e a n im a g e p r o c e s s in g s y s te m a n d g e n e r a tin g u s e d in th e e x p e r im e n t. a g e o m e tr y a s c lo s e a s p o s s io f th e lo s t c o in s (th is in c lu d e s fe w te s t p h o to s . T o s im p lify b le o f g iv in g im a g e s th a t r e b y c o n n e c tin g th e c a m e r a to d ig ita l im a g e s , w h ic h w ill b e 3 . O b ta in s e ts o f im a g e s o f e a c h c o in w ith d iffe r e n t le n s s e ttin g s . T h e r e s u ltin g im a g e s s h o u ld a p p r o x im a te th e a s p e c t a n g le , s iz e (in r e la tio n to th e a r e a o c c u p ie d b y th e b a c k g r o u n d ), a n d b lu r o f th e p h o to s o f th e lo s t c o in s . 4 . T h e le fo r th e th e c o u n ifo r n s s e c o rr in a n m b a ttin e s p d b c k g g fo r e a c h o n d in g im a c k g ro u n d ro u n d , o r im a g e a n o th a g o d e r e in f a lo r e p la m e c (3 ) s t c c e h a n is a m o o in . F o th e m w is m to d e l r e a ith a p p o f th e b c h s u c h a s m a ll, r o x im a t lu r r in g p r o c e s e ttin g , re m o b r ig h t d o t o n e a n im p u ls e s s v e a o f C H A P T E R 5 . P R O B L E M S O L U T IO N S 1 0 0 (a) (b) (c) F ig u r e P 5 .2 8 lig h t. D ig itiz e th e im p u ls e . Its F o u r ie r tr a n s fo r m is th e tr a n s fe r fu n c tio n o f th e b lu r r in g p r o c e s s . 5 . D ig itiz e e a c h (b lu r r e d ) p h o to o f a lo s t c o in , a n d o b ta in its F o u r ie r tr a n s fo r m . A t th is p o in t, w e h a v e H (u ,v ) a n d G (u ,v ) fo r e a c h c o in . 6 . O b ta in a n a p p r o x im a tio n to F (u , v ) b y u s in g a W ie n e r fi lte r. E q u a tio n (5 .8 - 3 ) is p a r tic u la r ly a ttr a c tiv e b e c a u s e it g iv e s a n a d d itio n a l d e g r e e o f fre e d o m (K ) fo r e x p e r im e n tin g . 7 . T s b o h e in v e r s e to re d im a g a s ic s te p s b ta in a c c e F o u e fo w ith p ta b r ie r a v a le r tra n c o in . r io u s r e s u lt s fo r m In g e d iffe r s in a o f e a c h a p p ro n e r a l, s e v e r a l e n t s e ttin g s a n p r o b le m s u c h x im e x p d p a s t a t i o n F^ ( u , v ) g i v e s t h e r e e r im e n ta l p a s s e s o f th e s e a r a m e te r s a re re q u ire d to h is . Problem 5.28 T h a x 1 8 1 3 e is 0 ◦ 5 ◦ s o lu is ρ . In . T h tio n s a re s h o w n in th e a n d th e v e r tic a l a x is is (b ) th e fa t lo b e s o c c u r e in te n s ity a t th a t p o in t fo θ a t is llo w in g , w ith 4 5 ◦ a n d o u b le θ fi g u re s . In e a c = 0 ◦ a t th e b d th e s in g le p o th e in te n s ity o h o t in f a fi g u to m t o f ll o t re th a n d in te r h e r p e h o r iz o n ta l g o in g u p to s e c tio n is a t o in ts . Problem 5.29 B e c a u s e f (x , y ) is r o ta tio n a lly s y m m e tr ic , its p r o je c tio n s a r e th e s a m e fo r a ll a n g le s , s o a ll w e h a v e t o d o is o b t a in t h e p r o je c t io n fo r θ = 0 ◦ . E q u a t io n ( 5 .1 1 - 3 ) 1 0 1 th e n b e c o m e s < = g (ρ ,θ ) f (x ,y ) 1 1 − 1 1 − 1 = = f (ρ ,y )d y − 1 = f (x ,y )δ (x − ρ )d x d y 1 A e − 1 = A e − y 1 2 − ρ 2 (− ρ 2 ) − y e 2 d y d y . − 1 B e c a u s e 1 1 2 2 π σ it fo llo w s b y le ttin g σ 2 2 − z e 2 / 2 σ d z = 1 − 1 = 1 / 2 in th is e q u a tio n th a t, p T h e n , 1 1 2 − z e π d z = 1 . − 1 1 e − y 2 d y = p π − 1 a n d g (ρ ,θ ) = A p π e − ρ 2 . Problem 5.30 ( a ) F r o m E q . ( 5 .1 1 - 3 ) , < f (x ,y ) = g (ρ ,θ ) = = = = 1 1 − 1 1 − 1 1 − 1 1 − 1 1 − 1 − 1 1 0 f (x ,y )δ (x c o s θ + y s in θ − ρ )d x d y δ (x ,y )δ (x c o s θ + y s in θ − ρ )d x d y 1 × δ (0 − ρ )d x d y if ρ = 0 o th e r w is e . C H A P T E R 5 . P R O B L E M S O L U T IO N S 1 0 2 w h e r e th e th ir d s te p fo llo w s fr o m th e fa c t th a t δ (x , y ) is z e r o if x a n d / o r y a r e n o t z e ro . ( b ) S im ila r ly , s u b s t it u t in g in t o E q . ( 5 .1 1 - 3 ) , < = g (ρ ,θ ) f (x ,y ) 1 1 − 1 1 − 1 1 − 1 1 − 1 1 − 1 − 1 = = = f (x ,y )δ (x c o s θ + y s in θ − ρ )d x d y δ (x − x 1 × δ (x 0 0 ,y − y 0 )δ (x c o s θ + y s in θ − ρ )d x d y c o s θ + y 0 s in θ − ρ )d x d y . F r o m th e d e fi n itio n o f th e im p u ls e , th is r e s u lt is 0 u n le s s ρ = x c o s θ + y 0 0 s in θ w h ic h is th e e q u a tio n o f a s in u s o id a l c u r v e in th e ρ θ - p la n e . Problem 5.31 ( a ) F r o m S e c tio n 2 .6 , w e k n o w th a t a n o p e r a to r, O , is lin e a r if O (a f 1 + b f 2 ) = a O ( f 1 ) + b O ( f 2 ). F r o m t h e d e fi n it io n o f t h e R a d o n t r a n s fo r m in E q . ( 5 .1 1 - 3 ) , O (a f + b f 2 ) 1 = = 1 1 − 1 − 1 1 (a f 1 a − 1 1 f 1 δ (x c o s θ + y s in θ − ρ )d x d y − 1 + b = + b f 2 )δ (x c o s θ + y s in θ − ρ )d x d y 1 1 − 1 − 1 a O ( f 1 ) + b O ( f 2 ) f 2 δ (x c o s θ + y s in θ − ρ )d x d y th u s s h o w in g th a t th e R a d o n tr a n s fo r m is a lin e a r o p e r a tio n . ( b ) L e t p = x − x 0 a n d q = y − y 0 . T h e n d p = d x a n d d q = d y . F r o m E q . ( 5 .1 1 - 3 ) , th e R a d o n tr a n s fo r m o f f (x − x 0 ,y − y 0 ) is g (ρ ,θ ) = = = = 1 1 − 1 1 − 1 1 − 1 1 − 1 1 − 1 − 1 g (ρ − x 0 f (x − x 0 ,y − y 0 )δ (x c o s θ + y s in θ − ρ )d x d y f (p ,q ) δ (p + x f (p ,q ) δ p c o s θ + q s in θ − (ρ − x c o s θ − y 0 0 ) c o s θ + (q + y 0 ) s in θ − ρ ) d p d q s in θ ,θ ). 0 c o s θ − y 0 s in θ ) d p d q 1 0 3 ( c ) F r o m C h a p t e r 4 ( P r o b le m 4 .1 1 ) , w e k n o w t h a t t h e c o n v o lu t io n o f t w o fu n c tio n f a n d h is d e fi n e d a s c (x ,y ) = f (x ,y ) = h (x ,y ) 1 1 − 1 − 1 f (α ,β )h (x − α ,y − β )d α d β . W e w a n t to s h o w th a t < f c g = < f < f h g ,w h e r e < d e n o t e s t h e R a d o n t r a n s fo r m . W e d o t h is b y s u b s t it u t in g t h e c o n v o lu t io n e x p r e s s io n in t o E q . ( 5 .1 1 - 3 ) . T h a t is , ⎤ ⎡ 1 1 1 1 < f c g f (α ,β )h (x − α ,y − β )d α d β ⎦ ⎣ = − 1 − 1 − 1 − 1 × δ (x c o s θ + y s in θ − ρ )d x d y f (α ,β ) = α β ⎡ ⎤ × ⎣ w h e re w e u s e d a n d th e ir v a r ia b in g w ith th e in t ++ h (x x +y + = x 0 y 0h h (x − α ,y − β )δ (x c o s θ + y s in θ − ρ )d x d y ⎦d α d β x y th e s u b s c r ip ts in th e in te g r a ls fo r c la r ity b e tw e e n th e in te g r a ls le s . A ll in te g r a ls a r e u n d e r s to o d to b e b e tw e e n − 1 a n d 1 . W o r k e g r a ls in s id e th e b r a c k e ts w ith x 0 = x − α a n d y 0 = y − β w e h a v e − α ,y − β )δ (x c o s θ + y s in θ − ρ )d x d y (x 0,y 0)δ (x 0 c o s θ + y 0 s in θ − [ρ − α c o s θ − β s in θ ])d x 0d y 0 = < f h g (ρ − α c o s θ − β s in θ ,θ ). W e r b e in T h e fu n c e c o g n iz e g w ith re n o ta tio n tio n o f ρ < f c g th e s p e c in th − α c s e c o n t to ρ e la s t o s θ − d in te g a n d θ lin e is β s in θ ra l , it u s e a n a s th e is a fu d to in d θ .” T R a d o n tr a n s fo r m o f h , b u t in s te a d o f n c tio n o f ρ − α c o s θ − β s in θ a n d θ . d ic a te “ th e R a d o n tr a n s fo r m o f h a s a h e n , f (α ,β ) = α β ⎡ × ⎣ = α β ⎤ h (x − α ,y − β )δ (x c o s θ + y s in θ − ρ )d x d y ⎦d α d β x y f (α , β )< f h g (ρ − ρ 0, θ )d α d β C H A P T E R 5 . P R O B L E M S O L U T IO N S 1 0 4 w h e re ρ 0 = c a n w r ite α c o s θ + β s in θ . T h e n , b a s e d o n th e p r o p e r tie s o f th e im p u ls e , w e < f h g (ρ − ρ 0, θ ) = < f h g (ρ − ρ 0, θ )δ (α c o s θ + β s in θ − ρ 0)d ρ 0. 0 ρ T h e n , < f c g = β f (α ,β ) = α β ⎡ × ⎣ ⎤ < f h g (ρ − ρ ,θ )δ (α c o s θ + β s in θ − ρ )d ρ ⎦d α d β 0 ρ 0 0 < f h g (ρ − ρ ,θ ) ⎣ ρ 0 ρ 0 < ⎤ f (α ,β )δ (α c o s θ + β s in θ − ρ )d α d β ⎦d ρ 0 α < f h g (ρ − ρ 0, θ )< = 0 ⎡ 0 = = α f (α , β ) < f h g (ρ − ρ 0, θ ) d α d β 0 β (ρ 0, θ )d ρ f 0 < f h g f w h e r e th e fo u r th s te p fo llo w s fr o m th e d e fi n itio n o f th e R a d o n tr a n s fo r m a n d th e fi fth s te p fo llo w s fr o m th e d e fi n itio n o f c o n v o lu tio n . T h is c o m p le te s th e p r o o f. Problem 5.32 T h e s o lu tio n is a s fo llo w s : 1 2 π f (x ,y ) = 0 G (! ,θ )e j 2 π ! (x c o s θ + y s in θ ) ! d ! d θ 0 1 π = 0 G (! ,θ )e j 2 π ! (x c o s θ + y s in θ ) ! d ! d θ 0 1 π + 0 G (! ,θ )e j 2 π ! (x c o s [θ + 1 8 0 ◦ ]+ y s in [θ + 1 8 0 ◦ ) ! d ! d θ . 0 B u t G (θ + 1 8 0 ◦ ,θ ) = G (− ! ,θ ), s o th e p re c e d in g e q u a tio n c a n b e e x p re s s e d a s π f (x ,y ) = 0 1 − 1 w h ic h a g r e e s w it h E q . ( 5 .1 1 - 1 5 ) . j! j G ( ! , θ ) e j 2 π ! (x c o s θ + y s in θ ) d ! d θ 1 0 5 Problem 5.33 T h e a r g u m e n t o f fu n c t io n s in E q .( 5 .1 1 - 2 4 ) m a y b e w r it t e n a s : r c o s (β + α − ' ) − D s in α = r c o s (β − ' ) c o s α − [r s in (β − ' ) + D ] s in α . F r o m F ig . 5 .4 7 , R c o s α 0 = R + r s in (β − ' ) R s in α 0 = r c o s (β − ' ). T h e n , s u b s titu tin g in th e e a r lie r e x p r e s s io n , r c o s (β + α − ' ) − R s in α R s in α 0 c o s α − R c o s α 0 s in α = = = R (s in α 0 c o s α − c o s α 0 s in α ) 0 R s in (α − α ) w h ic h a g r e e s w it h E q . ( 5 .1 1 - 2 5 ) . Problem 5.34 F r o m t h e e x p la n a t io n o f E q . ( 5 .1 1 - 1 8 ) , 1 s (ρ ) = j! j e − 1 j 2 π ! ρ d ! . L e t ρ = R s in α , a n d k e e p in m in d th a t α / R s in α is a lw a y s p o s itiv e . T h e n , 1 s (R s in α ) = − 1 j! j e j 2 π ! R s in α d ! . N e x t, d e fi n e th e tr a n s fo r m a tio n ! 0 ! R s in α . α = T h e n , α d ! R s in α d ! = 0 a n d w e c a n w r ite & s (R s in α ) = = a s d e s ire d . α '2 1 R s in α − 1 '2 & α s (α ) R s in α ! 0 e j 2 π ! 0α d ! 0 Chapter 6 Problem Solutions Problem 6.1 F r o m F ig . 6 .5 in t h e b o o k , x = 0 .4 3 a n d y = 0 .4 . S z = 0 .1 7 . T h e s e a r e t h e t r ic h r o m a t ic c o e ffi c ie n t s . v a lu e s X , Y , a n d Z , w h ic h a r e r e la te d to th e tr (6 .1 - 1 ) th r o u g h (6 .1 - 3 ). N o te h o w e v e r, th a t a ll d iv id e d b y th e s a m e c o n s ta n t, s o th e ir p e rc e n ta c o e ffi c ie n ts a re th e s a m e a s th o s e o f th e c o e ffi c X = 0 .4 3 , Y = 0 .4 0 , a n d Z = 0 .1 7 . in c e x + y + z = 1 , it fo llo w s th a t W e a r e in te r e s te d in tr is tim u lu s ic h r o m a tic c o e ffi c ie n ts b y E q s . th e tr is tim u lu s c o e ffi c ie n ts a r e g e s r e la tiv e to th e tr ic h r o m a tic ie n ts . T h e re fo re , th e a n s w e r is Problem 6.2 D e n o te b y c th e g iv e n c o lo r, a n d le t its c o o r d in a te s b e d e n o te d b y (x d is ta n c e b e tw e e n c a n d c 1 is d (c ,c 1 ) = S im ila r ly th e d is ta n c e b e tw e e n c d (c 1 ,c 2 ) = T h e p e rc e n ta g e p 1 o f c 1 e n ta x a m 0 % . lu e s 0 1 a n d c (x 1 − x )2 + 1 − x y − y 0 1 / 2 2 1 ,y 0 ). T h e . 2 2 )2 + y 1 − y 2 2 1 / 2 . in c is p T h e p e rc s e e , fo r e a n d p 2 = 1 0 0 % . V a (x 0 1 = g e p 2 o f c 2 is s im p le , th a t w h e n c = S im ila r ly , w h e n d in b e tw e e n a re e d (c 1 ,c 2 ) − d (c ,c 1 ) × 1 0 0 . d (c 1 ,c 2 ) p ly p 2 = 1 0 0 c 1 , th e n d (c (c ,c 1 ) = d (c a s ily s e e n to 1 0 7 − p 1 . In ,c 1 ) = 0 a 1 , c 2 ) , it f o fo llo w fr o th e p re c e d in g e n d it fo llo w s th a llo w s th a t p 1 = 0 m th e s e s im p le q u a t p 1 % a r e la tio n w e = 1 0 0 % n d p 2 = tio n s . C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 0 8 F ig u r e P 6 .3 Problem 6.3 C o n s id e r F tr ia n g le a n b o u n d a r y . b o rd e r o f t th e lin e s e g b y th e c o lo ig . P 6 .3 , in w h ic h c 1 , c 2 , a n d c 3 a r e t h e g iv e n v e d c is a n a r b itr a r y c o lo r p o in t c o n ta in e d w ith in th T h e k e y to s o lv in g th is p r o b le m is to r e a liz e th a h e tr ia n g le is m a d e u p o f p r o p o r tio n s fr o m th e tw m e n t th a t c o n ta in s th e p o in t. T h e c o n tr ib u tio n to r v e r te x o p p o s ite th is lin e is 0 % . r tic e s o f t e tr ia n g le t a n y c o lo o v e r tic e s a p o in t o n h e c o lo r o r o n its r o n th e d e fi n in g th e lin e T h e lin e s e g m e n t c o n n e c tin g p o in ts c 3 a n d c is s h o w n e x te n d e d (d a s h e d s e g m e n t) u n til it in te r s e c ts th e lin e s e g m e n t c o n n e c tin g c 1 a n d c 2 . T h e p o in t o f in te r s e c tio n is d e n o te d c 0 . B e c a u s e w e h a v e th e v a lu e s o f c 1 a n d c 2 , if w e k n e w c 0 , w e c o u ld c o m p u te th e p e r c e n ta g e s o f c 1 a n d c 2 c o n ta in e d in c 0 b y u s in g th e m e t h o d d e s c r ib e d in P r o b le m 6 .2 . L e t t h e r a t io o f t h e c o n t e n t o f c 1 a n d c 2 in c 0 b e d e n o t e d b y R 1 2 . If w e n o w a d d c o lo r c 3 t o c 0 , w e k n o w fr o m P r o b le m 6 .2 t h a t th e p o in t w ill s ta r t to m o v e to w a r d c 3 a lo n g th e lin e s h o w n . F o r a n y p o s itio n o f a p o in t a lo n g th is lin e w e c o u ld d e te r m in e th e p e r c e n ta g e o f c 3 a n d c 0 , a g a in , b y u s in g t h e m e t h o d d e s c r ib e d in P r o b le m 6 .2 . W h a t is im p o r t a n t t o k e e p in m in d th a t th e r a tio R 1 2 w ill r e m a in th e s a m e fo r a n y p o in t a lo n g th e s e g m e n t c o n n e c tin g c 3 a n d c 0 . T h e c o lo r o f th e p o in ts a lo n g th is lin e is d iffe r e n t fo r e a c h p o s itio n , b u t th e r a tio o f c 1 to c 2 w ill r e m a in c o n s ta n t. S o , if w e c a n o b ta in c 0 , w e c a n th e n d e te r m in e th e r a tio R 1 2 , a n d th e p e rc e n ta g e o f c 3 , in c o lo r c . T h e p o in t c 0 is n o t d iffi c u lt to o b ta in . L e t y = a 1 2 x + b 1 2 b e 1 0 9 th e s tr a ig h t lin e c o n ta in in g p o in ts c 1 a n d c 2 , a n d y = a 3 c x + b 3 c th e lin e c o n ta in in g c 3 a n d c . T h e in te r s e c tio n o f th e s e tw o lin e s g iv e s th e c o o r d in a te s o f c 0 . T h e lin e s c a n b e d e te r m in e d u n iq u e ly b e c a u s e w e k n o w th e c o o r d in a te s o f th e tw o p o in t p a ir s n e e d e d to d e te r m in e th e lin e c o e ffi c ie n ts . S o lv in g fo r th e in te r s e c tio n in te r m s o f th e s e c o o rd in a te s is s tr a ig h tfo r w a rd , b u t te d io u s . O u r in te re s t h e r e is in th e fu n d a m e n ta l m e th o d , n o t th e m e c h a n ic s o f m a n ip u la tin g s im p le e q u a tio n s s o w e d o n o t g iv e th e d e ta ils . A t th is ju n c tu r e w e h a v e th e p e r c e n ta g e o f c 3 a n d th e r a tio b e tw e e n c 1 a n d c 2 . L e t th e p e r c e n ta g e s o f th e s e th r e e c o lo r s c o m p o s in g c b e d e n o te d b y p 1 , p 2 , a n d p 3 r e s p e c tiv e ly . W e k n o w th a t p 1 + p 2 = 1 0 0 − p 3 , a n d th a t p 1 / p 2 = R 1 2 , s o w e c a n s o lv e fo r p 1 a n d p 2 . F in a lly , n o te th a t th is p r o b le m c o u ld h a v e b e e n s o lv e d th e s a m e w a y b y in te r s e c tin g o n e o f th e o th e r tw o s id e s o f th e tr ia n g le . G o in g to a n o th e r s id e w o u ld b e n e c e s s a r y , fo r e x a m p le , if th e lin e w e u s e d in th e p r e c e d in g d is c u s s io n h a d a n in fi n ite s lo p e . A s im p le te s t to d e te r m in e if th e c o lo r o f c is e q u a l to a n y o f th e v e r tic e s s h o u ld b e th e fi r s t s te p in th e p r o c e d u r e ; in th is c a s e n o a d d itio n a l c a lc u la tio n s w o u ld b e r e q u ir e d . Problem 6.4 U s e c o lo r fi lte r s th a t th r e e o b je c ts . W ith a re s p o n d s to th a t w a v c h ro m e c a m e ra . A m fro m a c o m p u te r. If fi lte r s w ill b e a p p r o x re s p o n s e o f th e th re e a r e s h a r p ly tu n e d to th e w a v e le n g th s s p e c ifi c fi lte r in p la c e , o n ly th e o b je c e le n g th w ill p r o d u c e a s ig n ifi c a n t r e s p o to r iz e d fi lte r w h e e l c a n b e u s e d to c o o n e o f th e c o lo r s is w h ite , th e n th e r e im a te ly e q u a l a n d h ig h . If o n e o f th e fi lte r s w ill b e a p p r o x im a te ly e q u a l a n d o f th e ts w h o o n s e o n tro l fi s p o n s e c o lo r s lo w . c o lo r s o f th e s e c o lo r c o r n th e m o n o lte r p o s itio n o f th e th re e is b la c k , th e Problem 6.5 A t th e c e n te r p o in t w e h a v e 1 2 R + 2 1 B + G = 1 2 (R + G + B ) + 1 2 G = m id g r a y + 2 1 G w h ic h lo o k s to a v ie w e r lik e p u r e g r e e n w ith a b o o s t in in te n s ity d u e to th e a d d itiv e g r a y c o m p o n e n t. C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 1 0 C o lo r B la c k R e d Y e llo w G re e n C y a n B lu e M a g e n ta W h ite R 1 1 G ra y 0 .5 0 .5 G 0 0 1 0 1 0 1 1 0 1 0 0 1 0 T a b le P B M o 0 0 2 0 2 0 1 1 1 2 1 2 0 .5 6 .6 n o R 0 5 5 5 5 0 0 0 5 5 5 5 1 2 8 M o n o G 0 0 2 5 5 2 5 5 2 5 5 0 0 2 5 5 M o n o B 0 0 0 0 2 5 5 2 5 5 2 5 5 2 5 5 1 2 8 1 2 8 Problem 6.6 F o r th e im a g e g th a t th e R G B c o 2 5 5 re p re s e n tin d is p la y s s h o w n iv e n , t m p o n g b la c in F ig h e m a x im u m in te n s ity a n d s a tu r a tio n re q u ire m e n t m e a n s e n t v a lu e s a r e 0 o r 1 . W e c a n c r e a t e T a b le P 6 .6 w it h 0 a n d k a n d w h ite , r e s p e c tiv e ly . T h u s , w e g e t th e m o n o c h r o m e . P 6 .6 . Problem 6.7 T h e r e a r e 2 8 = 2 5 6 p o s s ib le v a lu e s in e a c h 8 - b it im a g e . F o r a c o lo r to b e g r a y , a ll R G B c o m p o n e n ts h a v e to b e e q u a l, s o th e r e a r e 2 5 6 s h a d e s o f g r a y . Problem 6.8 ( a ) A ll p ix e l v a lu e s in th e R e d im a g e a r e 2 5 5 . In th e G r e e n im a g e , th e fi r s t c o lu m n i s a l l 0 ’s ; t h e s e c o n d c o l u m n a l l 1 ’s ; a n d s o o n u n t i l t h e l a s t c o l u m n , w h i c h i s F ig u r e P 6 .6 1 1 1 c o m p o s e d o f a l l 2 5 5 ’s . I n t h e B l u e i m a g e , t h e fi r s t r o w i s a l l 2 5 5 ’s ; t h e s e c o n d r o w a l l 2 5 4 ’s , a n d s o o n u n t i l t h e l a s t r o w w h i c h i s c o m p o s e d o f a l l 0 ’s . ( b ) L e t t h e a x is n u m b e r in g b e t h e s a m e a s in F ig . 6 .7 in t h e b o o k . T h e n : (0 , 0 , 0 ) = w h ite , (1 , 1 , 1 , ) = b la c k , (1 , 0 , 0 ) = c y a n , (1 , 1 , 0 ) = b lu e , (1 , 0 , 1 ) = g r e e n , (0 , 1 , 1 ) = r e d , (0 , 0 , 1 ) = y e llo w , (0 , 1 , 0 ) = m a g e n ta . ( c ) T h e o n e s th a t d o n o t c o n ta in th e b la c k o r w h ite p o in t a r e fu lly s a tu r a te d . T h e o th e r s d e c r e a s e in s a tu r a tio n fr o m th e c o r n e r s to w a r d th e b la c k o r w h ite p o in t. C o lo r B la c k R e d Y e llo w G re e n C y a n B lu e M a g e n ta W h ite R 1 G ra y 0 .5 G C 1 B 0 0 0 0 1 1 1 1 0 .5 0 .5 0 .5 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0 0 1 1 1 0 0 T a b le P 6 .9 M Y 1 1 1 1 0 1 0 1 0 0 1 0 1 0 0 0 0 .5 0 .5 M o n 2 5 0 0 2 5 2 5 2 5 o C 0 M o n o M 2 5 5 2 5 5 0 0 0 2 5 5 2 5 5 0 1 2 8 1 2 8 5 5 5 5 0 M o n 2 5 2 5 2 5 2 5 o Y 5 5 5 5 0 0 0 0 1 2 8 Problem 6.9 (a ) F o r th e im a g e g iv e n , th e m a x im u m in te n s ity a n d s a tu r a tio n re q u ire m e n t m e a n s t h a t t h e R G B c o m p o n e n t v a lu e s a r e 0 o r 1 . W e c a n c r e a t e T a b le P 6 .9 u s in g E q . ( 6 .2 - 1 ) . T h u s , w e g e t t h e m o n o c h r o m e d is p la y s s h o w n in F ig . P 6 .9 ( a ) . ( b ) T h e r e s u ltin g d is p la y is th e c o m p le m e n t o f th e s ta r tin g R G B im a g e . F r o m le ft t o r ig h t , t h e c o lo r b a r s a r e ( in a c c o r d a n c e w it h F ig . 6 .3 2 ) w h it e , c y a n , b lu e , m a g e n ta , r e d , y e llo w , g r e e n , a n d b la c k . T h e m id d le g r a y b a c k g r o u n d is u n c h a n g e d . F ig u r e P 6 .9 C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 1 2 Problem 6.10 E q u a tio n ( 6 .2 a s in g le c o m p G , a n d Y o f B F r o m E q . ( 6 .5 -1 o . -6 ) re n e n F o r ), w v e a ls th t o f th e c la r ity , e k n o w a t c o w th e a c h c o m p o n e n t o f th e C M Y im a g e is a fu n c tio n o f r re s p o n d in g R G B im a g e — C is a fu n c tio n o f R , M o f e w ill u s e a p r im e to d e n o te th e C M Y c o m p o n e n ts . a t s i = k r i fo r i = 1 , 2 , 3 ( fo r t h e R , G , a n d B c o m p o n e n t s ) . A n d fr o m E q . ( 6 .2 - 1 ) , w e k n o w th a t th e C M Y c o m p o n e n ts c o r re s p o n d in g to th e r i a n d s i (w h ic h w e a re d e n o tin g w ith p r im e s ) a re r i 0 = 1 − r i a n d s i 0 = 1 − s i. T h u s , r i = 1 − r i 0 a n d s i 0 = 1 − s = 1 − k r i = 1 − k i 1 − r i 0 s o th a t s i 0 = k r i0 + ( 1 − k ) . Problem 6.11 ( a ) T h e p u r e s t g r e e n is 0 0 F F 0 0 , w h ic h c o r r e s p o n d s to c e ll (7 , 1 8 ). ( b ) T h e p u r e s t b lu e is 0 0 0 0 F F , w h ic h c o r r e s p o n d s to c e ll (1 2 , 1 3 ). Problem 6.12 U s in g E q s th a t, in a c c o s − 1 (0 / 0 ( 6 .2 - 3 ) y ie d is p la y s h . ( 6 .2 c o rd ). In ld s S o w n -2 a n a d = in ) t h r o u g h ( 6 .2 - 4 ) , w e c e w it h E q . ( 6 .2 - 2 ) , h d itio n , s a tu r a tio n is 1 − 3 m in (0 ) / (3 × 0 ) F ig . P 6 .1 2 . g e u e u n = 1 t th e r e s u lts is u n d e fi n e d e fi n e d w h − (0 / 0 ). T h s h d w e n u s , o w n h e n R = w e g in R G e t T a b = G = B th e le P 6 .1 2 . = B s in c = 0 s in c m o n o c h N o te e θ = e E q . ro m e 1 1 3 C o lo r B la c k R e d Y e llo w G re e n C y a n B lu e M a g e n ta W h ite R 1 1 1 H – 0 0 .1 7 0 .3 3 0 .5 0 .6 7 0 .8 3 – G ra y 0 .5 0 .5 0 .5 – G 0 B 0 0 0 1 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 T a b le P 6 .1 2 S I 0 0 1 0 .3 3 1 0 .6 7 1 0 .3 3 1 0 .6 7 1 0 .3 3 1 0 .6 7 0 1 0 0 .5 M o n o H – 0 4 3 8 5 1 2 8 1 7 0 2 1 3 – – M o n – 2 5 2 5 2 5 2 5 2 5 2 5 0 0 o S 5 5 5 5 5 5 M o n o I 0 8 5 1 7 0 8 5 1 7 0 8 5 1 7 0 2 5 5 1 2 8 Problem 6.13 W it h r e fe r e n c e t o t h e H S I c o lo r c ir c le in F ig . 6 .1 4 ( b ) , d e e p p u r p le is fo u n d a t a p p r o x im a te ly 2 7 0 ◦ . T o g e n e r a te a c o lo r r e c ta n g le w ith th e p r o p e r tie s r e q u ir e d in th e p r o b le m s ta te m e n t, w e c h o o s e a fi x e d in te n s ity I , a n d m a x im u m s a tu r a tio n (th e s e a r e s p e c tr u m c o lo r s , w h ic h a r e s u p p o s e d to b e fu lly s a tu r a te d ), S . T h e fi r s t c o lu m n in th e r e c ta n g le u s e s th e s e tw o v a lu e s a n d a h u e o f 2 7 0 ◦ . T h e n e x t c o lu m n (a n d a ll s u b s e q u e n t c o lu m n s ) w o u ld u s e th e s a m e v a lu e s o f I a n d S , b u t th e h u e w o u ld b e d e c r e a s e d to 2 6 9 ◦ , a n d s o o n a ll th e w a y d o w n to a h u e o f 0 ◦ , w h ic h c o r r e s p o n d s to r e d . If th e im a g e is lim ite d to 8 b its , th e n w e c a n o n ly h a v e 2 5 6 v a r ia tio n s in h u e in th e r a n g e fr o m 2 7 0 ◦ d o w n to 0 ◦ , w h ic h w ill r e q u ir e a d iffe r e n t u n ifo r m s p a c in g th a n o n e d e g r e e in c r e m e n ts o r, a lte r n a tiv e ly , s ta r tin g a t a 2 5 5 ◦ a n d p r o c e e d in in c r e m e n ts o f 1 , b u t th is w o u ld le a v e o u t m o s t o f th e p u r p le . If w e h a v e m o r e th a n e ig h t b its , th e n th e in c r e m e n ts c a n b e s m a lle r. L o n g e r s tr ip s a ls o c a n b e m a d e b y d u p lic a tin g c o lu m n v a lu e s . F ig u r e P 6 .1 2 1 1 4 C H A P T E R 6 . P R O B L E M S O L U T IO N S Problem 6.14 T h e re a re tw o im p o r ta n t a s p H S I s p a c e a n d th e o th e r is to v a lu e s g r o w a s a fu n c tio n o f a e v e r im a g e a re a is u s e d . T h e a r a d iu s w h e n th e a n g le is 0 b y , s a y , o n e d e g r e e , a n d a ll th V a lu e s o f th e s a tu r a tio n im a g o r ig in . T h e in te n s ity im a g e m in d it is n o t d iffi c u lt to w r it e c ts to th is p r o b le m . O n e is to a p p r o a c h it in th e u s e p o la r c o o r d in a te s to c r e a te a h u e im a g e w h o s e n g le . T h e c e n te r o f th e im a g e is th e m id d le o f w h a tn , fo r e x a m p le , th e v a lu e s o f th e h u e im a g e a lo n g ◦ w o u l d b e a l l 0 ’s . T h e n t h e a n g l e i s i n c r e m e n t e d e v a l u e s a l o n g t h a t r a d i u s w o u l d b e 1 ’s , a n d s o o n . e d e c r e a s e lin e a r ly in a ll r a d ia l d ir e c tio n s fr o m th e is ju s t a s p e c ifi e d c o n s ta n t. W ith th e s e b a s ic s in e a p r o g r a m th a t g e n e r a te s th e d e s ir e d r e s u lt. Problem 6.15 T h e h u e , s a t u r a t io n , a n d in t e n s it y im a g e s a r e s h o w n in F ig . P 6 .1 5 , fr o m le ft t o r ig h t. Problem 6.16 ( a ) It is g iv e n t h a t t h e c o lo r s in F ig . 6 .1 6 ( a ) a r e p g iv e n th a t th e g r a y - le v e l im a g e s in th e p r o b le m la tte r c o n d itio n m e a n s th a t h u e (a n g le ) c a n o n u m b e r o f 2 5 6 v a lu e s . B e c a u s e h u e v a lu e s a r e 0 ◦ to 3 6 0 ◦ th is m e a n s th a t fo r a n 8 - b it im a g e th e h u e v a lu e s a r e n o w 3 6 0 / 2 5 5 . A n o th e r w a y o f lo 3 6 0 ] h u e s c a le is c o m p r e s s e d to th e r a n g e [0 , (th e fi r s t p r im a r y c o lo r w e e n c o u n te r ), w h ic h is in te g e r ) in th e in te g e r s c a le o f th e 8 - b it im a g e s S im ila r ly , g r e e n , w h ic h is 1 2 0 ◦ b e c o m e s 8 5 in c o m p u te th e v a lu e s o f th e o th e r tw o r e g io n s a s F ig u r e P 6 .1 5 r im a r y s p e c tr u m c o lo r s . It a ls o is s ta te m e n t a re 8 - b it im a g e s . T h e n ly b e d iv id e d in to a m a x im u m re p re s e n te d in th e in te r v a l fr o m in c re m e n ts b e tw e e n c o n tig u o u s o k in g a t th is is th a t th e e n tire [0 , 2 5 5 ]. T h u s , fo r e x a m p le , y e llo w 6 0 ◦ n o w b e c o m e s 4 3 (th e c lo s e s t h o w n in th e p r o b le m s ta te m e n t. th is im a g e . F r o m th is w e e a s ily b e in g 1 7 0 a n d 2 1 3 . T h e re g io n in 1 1 5 t h e m id d le is p u r e w h it e [e q u a l p r o p o r t io n s o f r e d g r e e n a n d b lu e in F ig . 6 .6 1 ( a ) ] s o its h u e b y d e fi n itio n is 0 . T h is a ls o is tr u e o f th e b la c k b a c k g r o u n d . ( b ) T h e c o lo r s a r e s p e c tr u m c o lo r s , s o th e y a r e fu lly s a tu r a te d . T h e r e fo r e , th e v a lu e s 2 5 5 s h o w n a p p ly ‘ to a ll c ir c le r e g io n s . T h e r e g io n in th e c e n te r o f th e c o lo r im a g e is w h ite , s o its s a tu r a tio n is 0 . ( c ) T h e k e y to g e ttin g th e v a lu e s in th is fi g u r e is to r e a liz e th a t th e c e n te r p o r tio n o f th e c o lo r im a g e is w h ite , w h ic h m e a n s e q u a l in te n s itie s o f fu lly s a tu r a te d r e d , g r e e n , a n d b lu e . T h e r e fo r e , th e v a lu e o f b o th d a r k e r g r a y r e g io n s in th e in t e n s it y im a g e h a v e v a lu e 8 5 ( i.e ., t h e s a m e v a lu e a s t h e o t h e r c o r r e s p o n d in g r e g io n ). S im ila r ly , e q u a l p r o p o r tio n s o f th e s e c o n d a r ie s y e llo w , c y a n , a n d m a g e n ta p r o d u c e w h ite , s o th e tw o lig h te r g r a y r e g io n s h a v e th e s a m e v a lu e (1 7 0 ) a s th e r e g io n s h o w n in th e fi g u r e . T h e c e n te r o f th e im a g e is w h ite , s o its v a lu e is 2 5 5 . Problem 6.17 ( a ) B e c a u s e th e in fr a r e d im a g e w h ic h w a s u s e d in p la c e o f th e r e d c o m p o n e n t im a g e h a s v e r y h ig h g r a y - le v e l v a lu e s . (b ) T h r s h o s h a T e w d h e w a te r s h o ld th e n in F ig . e o f b lu e a p p e a rs a s s im a g e w ith P 6 .1 7 . It is p re s e n ts n o (c ) N o te th a t th e W e a lr e a d y k n o w a c tu a lly r e m o v e s th e o th e r m a n -m m o v a l o f th e re d c a n b e d o n e b y u o lid a th c le a d iffi b la c k re s h o r th a t c u ltie p re d o m in a n t c h o w to ta k e o th e “ b a c k g ro u a d e s tr u c tu re s [a n d th e b la c k s in g th e te c h n ( 0 ) in t h e n e a r in fr a r e d im a g e [F ig . 6 .2 7 ( d ) ]. ld v a lu e s lig h tly la r g e r th a n 0 . T h e r e s u lt is c o lo r in g a ll th e b la c k p o in ts in th e d e s ir e d s . o lo r o f n a tu r a l te r r a in is in u t th e w a te r fro m (b ). T h e n d ” o f r e d a n d b la c k w o u ld , w h ic h a p p e a r m o s tly in a if y o u d o n o t w a n t to u s e iq u e d is c u s s e d in S e c tio n 6 v a r io u re fo re le a v e b lu is h th e m .7 .2 . s s h a d e s o f re d . , a m e th o d th a t p r e d o m in a n tly lig h t c o lo r. R e e th o d a s in (b )] Problem 6.18 U s h a p u is , o f in g E q . ( 6 .2 - 3 ) , w e s e e t h a t t h e b a s ic p r o b le m is t h a t m a n y v e th e s a m e s a tu r a tio n v a lu e . T h is w a s d e m o n s tr a te d in P r o b r e r e d , y e llo w , g r e e n , c y a n , b lu e , a n d m a g e n ta a ll h a d a s a tu r a s lo n g a s a n y o n e o f t h e R G B c o m p o n e n t s is 0 , E q . ( 6 .2 - 3 ) y ie 1 . C o n s id e r R G B c o lo r s (1 , 0 , 0 ) a n d (0 , 0 .5 9 , 0 ), w h ic h r e p r e s e n a n d g r e e n . T h e H S I t r ip le t s fo r t h e s e c o lo r s [p e r E q . ( 6 .4 - 2 ) t h r o (0 , 1 , 0 .3 3 ) a n d (0 .3 3 , 1 , 0 .2 ), r e s p e c t iv e ly . N o w , t h e c o m p le m e n d iff le m a tio ld s e re n t 6 .1 2 , n o f 1 a s a tu c o lo r s w h e re . T h a t r a tio n t s h a d e s o f re d u g h ( 6 .4 - 4 ) ] a r e ts o f th e b e g in - C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 1 6 F ig u r e P 6 .1 7 n in g R G B v a lu c o r re s p o n d in g t h r o u g h ( 6 .4 - 4 re d , a s ta r tin g 1 , w h ile fo r th m e n te d ” s a tu r d iffe re n t “c o m tio n to c o m p u e s ( s e e S e c t io n 6 .5 .2 ) a r e (0 , 1 , 1 ) a n d (1 , 0 .4 1 , 1 ), r e s p e c t c o lo r s a r e c y a n a n d m a g e n ta . T h e ir H S I v a lu e s [p e r E q ) ] a r e (0 .5 , 1 , 0 .6 6 ) a n d (0 .8 3 , 0 .4 8 , 0 .8 ), r e s p e c t iv e ly . T h u s a tu r a tio n o f 1 y ie ld e d th e c y a n “ c o m p le m e n te d ” s a tu e g r e e n , a s ta r tin g s a tu r a tio n o f 1 y ie ld e d th e m a g e n ta a t io n o f 0 .4 8 . T h a t is , t h e s a m e s t a r t in g s a t u r a t io n r e s u lt p le m e n te d ” s a tu r a tio n s . S a tu r a tio n a lo n e is n o t e n o u g h te th e s a tu r a tio n o f th e c o m p le m e n te d c o lo r. iv e ly ; th e s . ( 6 .4 - 2 ) s , fo r th e r a tio n o f “ c o m p le e d in tw o in fo r m a - Problem 6.19 T h 6 .3 n o 0 .5 h a e c o 2 . T r m a ), th lf o f m p h e liz e e h th e le m h u e d b y u e o c irc e n t o f a c o lo r is th c o m p o n e n t is th e a 3 6 0 d e g re e s . F o r a f th e c o m p le m e n ta le ( i.e ., fo r 0 .5 ≤ H ≤ e c o lo r n g le fr o c o lo r o n r y c o lo r 1 ), th e o p m th is h u p o s ite re d in e to p H + 0 e o f th it o a c o h a lf .5 . F e c o n th e c o lo r c ir c le u n te r c lo c k w is e d ir o f t h e c ir c le ( i.e ., 0 o r a c o lo r o n th e b m p le m e n t is H − 0 o f F ig . e c tio n ≤ H ≤ o tto m .5 . Problem 6.20 T h e R G B t r a n s fo r m a t io n s fo r a c o m p le m e n t [fr o m F ig . 6 .3 3 ( b ) ] a r e : s i = 1 − r i w h e re i = 1 ,2 ,3 (fo r th e R , G , a n d B c o m p o n e n ts ). B u t fr o m th e d e fi n itio n o f th e C M Y s p a c e in E q . ( 6 .2 - 1 ) , w e k n o w t h a t t h e C M Y c o m p o n e n t s c o r r e s p o n d in g t o r i a n d s i , w h ic h w e w ill d e n o te u s in g p r im e s , a r e r 0 s i i 0 = 1 − r i = 1 − s i. 1 1 7 F ig u r e P 6 .2 1 T h u s , r i = 1 − r i 0 a n d s i 0 = 1 − s i = 1 − (1 − r i) = 1 − 1 − 1 − r i 0 s o th a t s 0 = 1 − r i0 . Problem 6.21 T h e R G B tra n a re a s , e ffe c tiv a n d b lu e c o m s o th a t th e c o s h o w n in F ig . s fo r m a tio n s h o e ly c o m p r e s s in p o n e n ts s h o u ld lo r s d o n o t c h a P 6 .2 1 . u ld d g a ll b e t n g e . a rk e n v a lu e s ra n s fo T h e g th to r m e n e h w a e d e ra ig rd w l h lig h ts a n d lig h te th e m id to n e s . T ith th e s a m e m a p s h a p e o f th e c u r v n th e s h h e re d , g p in g fu n e w o u ld a d re c t b e o w e n , io n a s Problem 6.22 B a s e d o n t h e d is c u s s io n is S e c t io n 6 .5 .4 a n d w it h r e fe r e n c e t o t h e c o lo r w h e e l in F ig . 6 .3 2 , w e c a n d e c r e a s e t h e p r o p o r t io n o f y e llo w b y ( 1 ) d e c r e a s in g y e llo w , (2 ) in c r e a s in g b lu e , (3 ) in c r e a s in g c y a n a n d m a g e n ta , o r (4 ) d e c r e a s in g r e d a n d g re e n . Problem 6.23 T h e L ∗ a ∗ b ∗ c o m p o n e n t s a r e c o m p u te d u s in g E q s . ( 6 .5 - 9 ) t h r o u g h ( 6 .5 - 1 2 ) . R e fe re n c e w h ite is R = G = B = 1 . T h e c o m p u ta tio n s a re b e s t d o n e in a s p re a d s h e e t, a s s h o w n in T a b le P 6 .2 3 . C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 1 8 Problem 6.24 T h e s im p le c o lo r s p a c e o n th e in te r e s u ltin g in b a c k to th e s t a p p ro a c h c o n c e p tu a , p e r fo r m h is to g r a m s p n s ity (I ) c o m p o n e n t o te n s ity c o m p o n e n t w it s ta r tin g c o lo r s p a c e . lly is e c ifi n ly ( h th e to tra n s fo r c a tio n p e r le a v in g H o r ig in a l h m th a n u e e v e r y e d is c d S a a n d s in p u u s s io lo n e ) a tu ra t im a n in , a n d tio n g e S e c c o to th c tio n o n v e m p o e H S I 3 .3 .2 r t th e n e n ts Problem 6.25 T h e g iv e n c o lo r im a g e is s h o w n in F ig . P 6 .2 5 ( a ) . A s s u m e t h a t t h e c o m p o n e n t im a g e v a lu e s o f th e H S I im a g e a r e in th e r a n g e [0 , 1 ]. C a ll th e c o m p o n e n t im a g e s H (h u e ), S (s a tu r a tio n ), a n d I (in te n s ity ). ( a ) It is g iv e n th a t th e im a g e is fu lly s a tu r a te d , s o im a g e H w ill b e c o n s ta n t w ith v a lu e 1 . S im ila r ly , a ll t h e s q u a r e s a r e a t t h e ir m a x im u m v a lu e s o , fr o m E q . ( 6 .2 4 ), th e in te n s ity im a g e a ls o w ill b e c o n s ta n t, w ith v a lu e 1 / 3 [th e m a x im u m v a lu e o f a n y (n o r m a liz e d ) p ix e l in th e R G B im a g e is 1 , a n d it is g iv e n th a t n o n e o f th e s q u a r e s o v e r la p ]. T h e h u e c o m p o n e n t im a g e , H , is s h o w n in F ig . P 6 .2 5 ( b ) . R e c a ll fr o m F ig . 6 .1 4 t h a t t h e v a lu e o f h u e is a n a n g le . B e c a u s e t h e r a n g e o f v a lu e s o f H is n o r m a liz e d to [0 , 1 ], w e s e e fr o m th a t fi g u r e , fo r e x a m p le , th a t a s w e g o a r o u n d th e c ir c le in th e c o u n te r c lo c k w is e d ir e c tio n a h u e v a lu e o f 0 c o r r e s p o n d s to r e d , a v a lu e o f 1 / 3 to g r e e n , a n d a v a lu e o f 2 / 3 to b lu e . T h u s , th e im p o r ta n t p o in t to b e m a d e in F ig . P 6 .2 5 (b ) is th a t th e g r a y v a lu e in th e im a g e c o r r e s p o n d in g to th e r e d s q u a r e s h o u ld b e b la c k , th e v a lu e c o r r e s p o n d in g to th e g r e e n g r e e n s q u a r e s h o u ld b e lo w e r - m id g r a y , a n d th e v a lu e o f th e th e s q u a r e c o r r e s p o n d in g to b lu e s h o u ld b e a lig h te r s h a d e o f g r a y th a n th e s q u a r e c o r r e s p o n d in g to g r e e n . A s y o u c a n s e e , t h is in d e e d is th e c a s e fo r th e s q u a r e s in F ig . P 6 .2 5 ( b ) . F o r th e s h a d e s o f r e d , g r e e n , a n d b lu e in F ig . P 6 .2 5 ( a ) , t h e e x a c t v a lu e s a r e H = 0 , H = 0 .3 3 , a n d H = 0 .6 7 , r e s p e c t iv e ly . 1 1 9 F ig u r e P 6 .2 5 ( b ) T h e s a tu r a tio n im a g e is c o n s ta n t, s o s m o o th in g it w ill p r o d u c e th e s a m e c o n s ta n t v a lu e . ( c ) F ig u r e P 6 .2 5 ( c ) s h o w s t h e r e s u lt o f b lu r r in g th e h u e im a g e . W h e n t h e a v e r a g in g m a s k is fu lly c o n ta in e d in a s q u a r e , th e r e is n o b lu r r in g b e c a u s e th e v a lu e o f e a c h s q u a re is c o n s ta n t. W h e n th e m a s k c o n ta in s p o r tio n s o f tw o o r m o re s q u a r e s th e v a lu e p r o d u c e d a t th e c e n te r o f th e m a s k w ill b e b e tw e e n th e v a lu e s o f th e tw o s q u a r e s , a n d w ill d e p e n d th e r e la tiv e p r o p o r tio n s o f th e s q u a r e s o c c u p ie d b y th e m a s k . T o s e e e x a c tly w h a t th e v a lu e s a r e , c o n s id e r a p o in t in th e c e n t e r o f r e d m a s k in F ig . P 6 .2 5 ( c ) a n d a p o in t in t h e c e n t e r o f t h e g r e e n m a s k o n th e to p le ft. W e k n o w fr o m (a ) a b o v e th a t th e v a lu e o f th e r e d p o in t is 0 a n d th e v a lu e o f th e g r e e n p o in t is 0 .3 3 . T h u s , th e v a lu e s in th e b lu r r e d b a n d b e t w e e n r e d a n d g r e e n v a r y fr o m 0 t o 0 .3 3 b e c a u s e a v e r a g in g is a lin e a r o p e r a tio n . F ig u r e P 6 .2 5 (d ) s h o w s th e r e s u lt o f g e n e r a tin g a n R G B im a g e w ith th e b lu r r e d C H A P T E R 6 . P R O B L E M S O L U T IO N S 1 2 0 h u e c o m p o n e n t im a g e s a n d th e o r ig in a l s a tu r a tio n a n d in te n s ity v a lu e s a lo n g th e lin e ju s t d is c u s s e d a r e tr a n s itio n s fr o m g r e e n to r 6 .1 4 w e s e e t h a t t h o s e t r a n s it io n s e n c o m p a s s t h e s p e c t r u m fr o m th a t in c lu d e s c o lo r s s u c h a s y e llo w [a ll th o s e c o lo r s a r e p r e s e n t in a lth o u g h th e y a r e s o m e w h a t d iffi c u lt to s e e ]. T h e r e a s o n fo r th e d lin e in th is fi g u r e is th a t th e a v e r a g e v a lu e s a lo n g th a t r e g io n a r e n b e t w e e n r e d a n d b lu e , w h ic h w e k n o w fr o m fr o m F ig . 6 .1 4 is g r e e n im a g e s . T h e e d . F r o m F ig . g re e n to re d F ig . P 6 .2 5 ( d ) , ia g o n a l g re e n e a r ly m id w a y . Problem 6.26 T h is is a s im p le p r o b le m to e n c o u r a g e th e s tu d e n t to th in k a b o u t th e m e a n in g o f t h e e le m e n t s in E q . ( 6 .7 - 2 ) . W h e n C = I , it fo llo w s t h a t C − 1 = I a n d E q . ( 6 .7 - 2 ) b e c o m e s 1 / 2 D (z ,a ) = (z − a )T (z − a ) . B u t th e te r m in s id e th e b r a c k e ts is re c o g n iz e d a s th e in n e r p r o d u c t o f th e v e c to r (z − a ) w it h it s e lf, w h ic h , b y d e fi n it io n , is e q u a l t o t h e r ig h t s id e o f E q . ( 6 .7 - 1 ) . Problem 6.27 ( a ) T h e c u b e is c o m p o s e d o f s ix in te r s e c tin g p la n e s in R G B s p a c e . T h e g e n e r a l e q u a tio n fo r s u c h p la n e s is a z R + b z G + c z B + d = 0 w h e r e a , b , c , a n d d a r e p a r a m e t e r s a n d t h e z ’s a r e t h e c o m p o n e n t s o f a n y p o i n t (v e c to r ) z in R G B s p a c e ly in g o n th e p la n e . If a n R G B p o in t z d o e s n o t lie o n th e p la n e , a n d its c o o r d in a te s a r e s u b s titu te d in th e p r e c e d in g e q u a tio n , th e e q u a tio n w ill g iv e e ith e r a p o s itiv e o r a n e g a tiv e v a lu e ; it w ill n o t y ie ld z e r o . W e s a y th a t z lie s o n th e p o s itiv e o r n e g a tiv e s id e o f th e p la n e , d e p e n d in g o n w h e th e r th e r e s u lt is p o s itiv e o r n e g a tiv e . W e c a n c h a n g e th e p o s itiv e s id e o f a p la n e b y m u ltip ly in g its c o e ffi c ie n ts (e x c e p t d ) b y − 1 . S u p p o s e th a t w e te s t th e p o in t a g iv e n in th e p r o b le m s ta te m e n t to s e e w h e th e r it is o n th e p o s itiv e o r n e g a tiv e s id e e a c h o f th e s ix p la n e s c o m p o s in g th e b o x , a n d c h a n g e th e c o e ffi c ie n ts o f a n y p la n e fo r w h ic h th e r e s u lt is n e g a tiv e . T h e n , a w ill lie o n th e p o s itiv e s id e o f a ll p la n e s c o m p o s in g th e b o u n d in g b o x . In fa c t a ll p o in ts in s id e th e b o u n d in g b o x w ill y ie ld p o s itiv e v a lu e s w h e n th e ir c o o r d in a te s a r e s u b s titu te d in th e e q u a tio n s o f th e p la n e s . P o in ts o u ts id e th e b o x w ill g iv e a t le a s t o n e n e g a tiv e (o r z e r o if it is o n a p la n e ) v a lu e . T h u s , th e m e th o d c o n s is ts o f s u b s titu tin g a n u n k n o w n c o lo r p o in t in th e e q u a tio n s o f a ll s ix p la n e s . If a ll th e r e s u lts a r e p o s itiv e , th e p o in t is in s id e th e b o x ; o th e r w is e it is o u ts id e th e b o x . A fl o w d ia g r a m is a s k e d 1 2 1 F ig u r e P 6 .2 9 f o r i n t h e p r o b l e m s t a t e m e n t t o m a k e i t s i m p l e r t o e v a l u a t e t h e s t u d e n t ’s l i n e o f re a s o n in g . ( b ) If th e b o x is lin e d u p w ith th e R G B c o o r d in a te a x e s , th e n th e p la n e s in te r s e c t th e R G B c o o r d in a te p la n e s p e r p e n d ic u la r ly . T h e in te r s e c tio n s o f p a ir s o f p a r a lle l p la n e s e s ta b lis h a r a n g e o f v a lu e s a lo n g e a c h o f th e R G B a x is th a t m u s t b e c h e c k e d to s e e if th e if a n u n k n o w n p o in t lie s in s id e th e b o x o r n o t. T h is c a n b e d o n e o n a n im a g e p e r im a g e b a s is ( i.e ., t h e t h r e e c o m p o n e n t im a g e s o f a n R G B im a g e ), d e s ig n a tin g b y 1 a c o o rd in a te th a t is w ith in its c o r re s p o n d in g r a n g e a n d 0 o th e r w is e . T h e s e w ill p r o d u c e th r e e b in a r y im a g e s w h ic h , w h e n A N D e d , w ill g iv e a ll th e p o in ts in s id e th e b o x . Problem 6.28 T h e s k e tc h is a n e lo n g a te d e llip s o id a l fi g u r e in w h ic h th e le n g th lin e d u p w ith th e R e d (R ) a x is is 8 tim e s lo n g e r th a t th e o th e r tw o d im e n s io n s . In o th e r w o r d s , th e fi g u r e lo o k s lik e a b lim p a lig n e d w ith th e R - a x is . Problem 6.29 S e t o n e o f th e th r e e p r im a r y im a g e s to a c o n s ta n t v a lu e (s a y , 0 ), th e n c o n s id e r t h e t w o im a g e s s h o w n in F ig . P 6 .2 9 . If w e fo r m e d a n R G B c o m p o s it e im a g e b y 1 2 2 C H A P T E R 6 . P R O B L E M S O L U T IO N S le ttin g th e im a g e o n th e le ft b e th e r e d c o m p o n e n t a n d th e im a g e o n th e r ig h t th e g r e e n c o m p o n e n t, th e n th e r e s u lt w o u ld b e a n im a g e w ith a g r e e n r e g io n o n th e le ft s e p a r a te d b y a v e r tic a l e d g e fr o m a r e d r e g io n o n th e r ig h t. T o c o m p u te th e g r a d ie n t o f e a c h c o m p o n e n t im a g e w e ta k e s e c o n d - o rd e r p a r tia l d e r iv a tiv e s . In th is c a s e , o n ly th e c o m p o n e n t o f th e d e r iv a tiv e in th e h o r iz o n ta l d ir e c tio n is n o n z e r o . If w e m o d e l th e e d g e a s a r a m p e d g e th e n a p r o fi le o f th e d e r iv a tiv e im a g e w o u ld a p p e a r a s s h o w n in F ig . P 6 .2 9 ( s e e S e c t io n 1 0 .2 .4 fo r m o r e d e t a il o n th e p r o fi le o f e d g e s ). T h e m a g n ifi e d v ie w s h o w s c le a r ly th a t th e d e r iv a tiv e s o f th e tw o im a g e s a re m ir r o r s o f e a c h o th e r. T h u s , if w e c o m p u te d th e g r a d ie n t v e c to r o f e a c h im a g e a n d a d d e d th e r e s u lts a s s u g g e s te d in th e p r o b le m s ta te m e n t, th e c o m p o n e n ts o f th e g r a d ie n t w o u ld c a n c e l o u t, g iv in g a z e r o g r a d ie n t fo r a c o lo r im a g e th a t h a s a c le a r ly d e fi n e d e d g e b e tw e e n tw o d iffe r e n t c o lo r r e g io n s . T h is s im p le e x a m p le illu s tr a te s th a t th e g r a d ie n t v e c to r o f a c o lo r im a g e is n o t e q u iv a le n t to th e r e s u lt o f fo r m in g a c o lo r g r a d ie n t v e c to r fr o m th e s u m o f th e g r a d ie n t v e c to r s o f th e in d iv id u a l c o m p o n e n t im a g e s . Chapter 7 Problem Solutions Problem 7.1 F o llo w in g th e e x p la n a tio n in E x a m p le 7 .1 , th e d e c o d e r is a s s h o w n in F ig . P 7 .1 . Problem 7.2 A m e a n a p th e s ta r tin m e a n a p p a v e ra g e s o p r o x im a tio g im a g e is r o x im a tio n v e r f x ,y n p y ra m o f s iz e 4 p y r a m id a n d s u b id × . T s a is 4 h m c re a , J = e le v p lin te d b y fo r m in g 2 × 2 b lo c k a v e r a g e s . S in c e 2 a n d f x , y is p la c e d in le v e l 2 o f th e e l 1 a p p r o x im a tio n is (b y ta k in g 2 × 2 b lo c k g ) 3 .5 1 1 .5 5 .5 1 3 .5 Level j-1 approximation 2 Upsampler Interpolation filter Prediction Level j prediction residual + F ig u r e P 7 .1 1 2 3 Level j approximation C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 2 4 a n d t h e le v e l 0 a p p r o x im a t io n is s im ila r ly [8 .5 ]. T h e c o m p le t e d m e a n a p p r o x im a tio n p y r a m id is ⎡ ⎤ 1 2 3 4 ⎢ ⎥ 6 7 8 ⎥ 3 .5 5 .5 ⎢ 5 [8 .5 ] . ⎢ ⎥ 1 0 1 1 1 2 ⎦ 1 1 .5 1 3 .5 ⎣ 9 1 3 1 4 1 5 1 6 P ix e u a l tio n p lin tio n l r e p lic a tio n is u s p y r a m id . L e v e l a p p r o x im a tio n , g th e le v e l 1 a p p (o r ig in a l im a g e ) ⎡ 1 2 ⎢ 6 ⎢ 5 ⎢ 9 1 0 ⎣ 1 3 1 4 e d in th e g 0 o f th e p [8 .5 ]. T h e r o x im a tio . T h u s , w e 3 4 7 8 1 1 1 5 1 2 1 6 e n e r a tio n re d ic tio n le v e l 2 p r e n a n d s u b g e t ⎤ ⎡ 3 .5 ⎥ ⎢ ⎥ ⎢ 3 .5 ⎥− ⎢ ⎦ ⎣ 1 1 .5 1 1 .5 ⎡ − 2 .5 ⎢ ⎢ 1 .5 ⎢ ⎣ − 2 .5 1 .5 o f th e c re s id u a d ic tio n tr a c tin g 3 .5 3 .5 1 1 .5 1 1 .5 o m p le m e n l p y r a m id re s id u a l is it fr o m th − 1 .5 2 .5 − 1 .5 2 .5 5 .5 5 .5 1 3 .5 1 3 .5 ta r y p re is th e lo o b ta in e e le v e l 2 tio n s t re y u p p ro x re s id s o lu s a m im a - ⎤ 5 .5 5 .5 1 3 .5 1 3 .5 − 2 .5 1 .5 − 2 .5 1 .5 d ic w e d b a p ⎥ ⎥ ⎥ ⎦ = ⎤ − 1 .5 2 .5 − 1 .5 2 .5 ⎥ ⎥ ⎥. ⎦ S im ila r ly , th e le v e l 1 p r e d ic tio n r e s id u a l is o b ta in e d b y u p s a m p lin g th e le v e l 0 a p p r o x im a tio n a n d s u b tr a c tin g it fr o m th e le v e l 1 a p p r o x im a tio n to y ie ld 3 .5 1 1 .5 5 .5 1 3 .5 − 8 .5 8 .5 8 .5 8 .5 T h e p re d ic tio n re s id u a l p y r a m id is th e re fo r ⎡ − 2 .5 − 1 .5 − 2 .5 − 1 .5 ⎢ 2 .5 1 .5 2 .5 ⎢ 1 .5 ⎢ − 1 .5 − 2 .5 − 1 .5 ⎣ − 2 .5 1 .5 2 .5 1 .5 2 .5 − 5 3 = − 3 5 . e ⎤ ⎥ ⎥ ⎥ ⎦ − 5 3 − 3 5 [8 .5 ] . Problem 7.3 T h e n u m b e r o f e le m e n ts in a J + 1 le v e l p y r a m id w h e r e N = 2 4 N 2 o r 43 2 J = 43 2 2 J ( s e e S e c t i o n 7 . 1 . 1 ) : 3 , 1 4 2 J 1 1 2 J 1 + ≤ 2 + + ... + 2 1 2 J 3 (4 ) (4 ) (4 ) 2 J is b o u n d e d b y 1 2 5 fo r J > 0 . W e c a n g e n e r a te th e fo llo w in g ta b le : P y r a m id E le m e n ts 1 5 2 1 8 5 .. . J 0 1 2 3 .. . 1 C o m p re s s 1 5 / 4 = 2 1 / 1 6 = 8 5 / 6 4 = io n R a tio 1 .2 5 1 .3 1 2 5 1 .3 2 8 .. . 4 / 3 = 1 .3 3 A ll b u t th e tr iv ia l c a s e , J = 0 , a r e e x p a n s io n s . T h e e x p a n s io n fa c to r is a fu n c tio n o f J a n d b o u n d e d b y 4 / 3 o r 1 .3 3 . Problem 7.4 F i r s t c h e c k f o r o r t h o n o r m a l i t y . I f t h e fi l t e r s a r e o r t h o n o r m a l ., t h e y a r /e b i o r t h o g o p1 , p1 n a l b y d e fi n itio n . B e c a u s e K e v e n = 2 , n = 0 ,1 , a n d g 0 (n ) = fo r n = 0 ,1 , 2 2 E q . ( 7 .1 - 1 4 ) y ie ld s : . / p 1 , p− 1 (− 1 )n g 0 (1 − n ) = (− 1 )n g 0 (1 − n ) = g 0 (0 ) ,− g 0 (1 ) = = g 1 (n ) 2 2 . / 1p 1p g 0 (1 − n ) = , 2 = h 0 (n ) . 2 / p− 1 , p 1 = h 1 (n ) . g 1 (1 − n ) = 2 2 T h u s , t h e fi lt e r s a r e o r t h o n o r m a l a n d w ill a ls o s a t is fy E q . ( 7 .1 - 1 3 ) . In a d d it io n , t h e y w ill s a t is fy t h e b io r t h o g o n a lit y c o n d it io n s s t a t e d in E q s . ( 7 .1 - 1 2 ) a n d ( 7 .1 1 1 ) , b u t n o t ( 7 .1 - 1 0 ) . T h e fi lt e r s a r e b o t h o r t h o n o r m a l a n d b io r t h o g o n a l. Problem 7.5 (a ) f (b ) f (c ) f f (− n ) = f 1 , 0 .2 5 , 0 .5 , 0 g . (n ) = b (n ) = (− 1 ) c (d ) f (e ) f (n ) = − f (n ) = f 0 , − 0 .5 , − 0 .2 5 , − 1 g . a e d (n ) = f c e f (n ) = f 0 , − 0 .5 , 0 .2 5 , − 1 g . (− n ) = f − 1 , 0 .2 5 , − 0 .5 , 0 g . (n ) = (− 1 ) ( f ) F ilte r f n n f b (n ) = f 1 , − 0 .2 5 , 0 .5 , 0 g . (n ) in ( e ) c o r r e s p o n d s t o E q . ( 7 .1 - 9 ) . Problem 7.6 T a b le 7 .1 in t h e b o o k d e fi n e s g 0 (n ) fo r n = 0 , 1 , 2 , ..., 7 t o b e a b o u t { 0 .2 3 , 0 .7 2 , 0 .6 3 , - 0 .0 3 , - 0 .1 9 , 0 .0 3 , 0 .0 3 , - 0 .0 1 } . U s in g E q , ( 7 .1 - 1 4 ) w it h K e v e n = 8 , w e c a n C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 2 6 w r ite g n (n ) = (− 1 ) 1 g 0 (7 − n ) . T h u s g 1 (n ) is a n o r d e r - r e v e r s e d a n d m o d u la te d c o p y o f g - 0 .0 3 , 0 .0 3 , 0 .1 9 , - 0 .0 3 , - 0 .6 3 , 0 .7 2 , - 0 .2 3 } . 0 (n )— t h a t is , { – 0 .0 1 , T o n u m e r ic a lly p r o v e t h e o r t h o n o r m a lit y o f t h e fi lt e r s , le t m = 0 in E q . ( 7 .1 1 3 ): 0 g (n ) g i j (n ) 1 = δ fo r i , j = f 0 ,1 g . i − j Ite r a tin g o v e r i a n d j , w e g e t 2 g 2n 2 g 0 2 (n ) = 0 n (n ) g 1 g 1 2 (n ) = 1 (n ) = 0 . n S u b s titu tio n o f th e fi lte r c o e ffi c ie n t v a lu e s in to th e s e e q u a tio n s y ie ld s : g 0 (n ) g (n ) 1 = (0 .2 3 ) (− 0 .0 1 ) + (0 .7 2 ) (− 0 .0 3 ) + (0 .6 3 ) (0 .0 3 ) n + (− 0 .0 3 ) (0 .1 9 ) + (− 0 .1 9 ) (− 0 .0 3 ) + (0 .0 3 ) (− 0 .6 3 ) + (0 .0 3 ) (0 .7 2 ) + (− 0 .0 1 ) (− 0 .2 3 ) = g 2 0 (n ) 0 = g n 2 1 (n ) n = (± 0 .2 3 ) 2 + (0 .7 2 ) 2 + (± 0 .6 3 )2 + (− 0 .0 3 ) 2 + (± 0 .1 9 )2 + (0 .0 3 ) 2 + (± 0 .0 3 )2 + (− 0 .0 1 ) = 2 1 . Problem 7.7 R e c o n s tr u c tio n is p e r fo r m e d b y re v e r s in g th e d e c o m p o s itio n p r o c e s s — th a t is , b y r e p la c in g th e d o w n s a m p le r s w ith u p s a m p le r s a n d th e a n a ly s is fi lte r s b y th e ir s y n t h e s is fi lt e r c o u n t e r p a r t s , a s F ig . P 7 .7 s h o w s . 1 2 7 g0(n) 2 a(m,n) Columns (along n) dV(m,n) g0(m) 2 Rows (along m) g1(n) 2 Columns dH(m,n) f(m,n) g0(n) 2 Columns g1(m) 2 Rows dD(m,n) g1(n) 2 Columns F ig u r e P 7 .7 Problem 7.8 T h e H a a r tr a n s fo r m m a tr ix fo r N = 8 is ⎡ 1 1 1 1 ⎢ 1 1 1 ⎢ p1 p p p ⎢ 2 2 − 2 − 2 ⎢ ⎢ 1 ⎢ 0 0 0 0 H 8 = p ⎢ − 2 0 0 8 ⎢ 2 ⎢ 0 2 − 2 ⎢ 0 ⎢ 0 0 0 ⎣ 0 0 0 0 0 ⎤ 1 1 1 1 − 1 0 p − 1 0 p − 1 0 p − 1 0 p 2 0 0 0 − 2 0 0 − 2 − 0 0 2 2 ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥. ⎥ ⎥ ⎥ ⎥ ⎦ 2 0 0 0 0 0 − 2 2 Problem 7.9 ( a ) E q u a tio n ( 7 .1 - 1 8 ) d e fi n e s th e 2 × 2 H a a r t r a n s fo r m a t io n m a t r ix a s H = 2 p 1 2 1 1 1 − 1 . T h u s , u s in g E q . ( 7 .1 - 1 7 ) , w e g e t T = H F H = 5 − 3 T p = 4 0 2 1 2 1 1 1 − 1 6 3 − 1 2 1 1 1 − 1 . C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 2 8 (b ) F ir s t, c o m p u te − 1 H a = 2 b d c s u c h th a t a b d c 1 p 1 1 − 1 1 2 = 1 0 0 1 . S o lv in g th is m a tr ix e q u a tio n y ie ld s − 1 H p = 2 1 1 1 − 1 1 2 = H 2 T = H 2 . T h u s , F = H T T H 2 1 p = 1 − 1 1 2 3 = 1 − 1 2 6 5 − 3 4 1 0 1 − 1 1 . Problem 7.10 (a ) T h e b a s is is o r th o n o r m a l a n d th e c o e ffi c ie n ts a re c o m p u te d b y th e v e c to r e q u iv a le n t o f E q . ( 7 .2 - 5 ) : α p1 = 0 5 = α 1 p p1 2 3 2 2 2 2 p1 = = p p1 − 2 3 2 2 2 2 s o , 5 p 2 2 ' 0 + p 2 2 ' 1 = 5 p p1 2 p1 = 2 2 3 . 2 2 + p p1 2 2 − 2 p1 2 1 2 9 (b ) T h e b a s is is b io r th o n o r m a l a n d th e c o e ffi c ie n ts a re c o m p u te d b y th e v e c to r e q u iv a le n t o f E q . ( 7 .2 - 3 ) : α 1 − 1 0 1 = 0 3 2 = 1 α 1 = 3 2 = 2 s o , ' + 2 ' 0 1 = 1 3 = 1 + 2 0 1 . 2 ( c ) T h e b a s is is o v e r c o m p le te a n d th e c o e ffi c ie n ts a r e c o m p u te d b y th e v e c to r e q u iv a le n t o f E q . ( 7 .2 - 3 ) : α 2 = 0 = 2 $ α 2 p 1 = − 1 3 0 3 3 2 p = − = − 1 − 3 3 $ 2 2 3 = − 1 + α % 3 3 1 p − 3 2 p 3 3 3 3 % 3 2 C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 3 0 F ig u r e P 7 .1 1 s o , 2 ' 0 + − 1 + 2 p 3 3 ' 1 + − 1 − 2 p 3 3 ' 2 1 = 2 p 2 − 1 + 2 − 1 − = + 0 3 p 3 2 3 2 + 2 3 3 3 1 −p − − 1 p2 3 2 . Problem 7.11 A s c a n b e s e e n i n F i g . P 7 . 1 1 , s c a l i n g f u n c t i o n ' 0 ,0 ( x ) c a n n o t b e w r i t t e n a s a s u m o f d o u b l e r e s o l u t i o n c o p i e s o f i t s e l f . N o t e t h e g a p b e t w e e n ' 1 ,0 ( x ) a n d ' 1 ,1 ( x ) . 1 3 1 F ig u r e P 7 .1 2 Problem 7.12 S u b s t it u t in g j = 3 in t o E q . ( 7 .2 - 1 3 ) , w e g e t ' = S p a n V 3 k 3 ,k (x ) 3 / 3 2 2 ' 2 3 x − k k 4 3 p = S p a n 2 2 ' (8 x − k ) . . V 3 = S p a n V k U s in g t h e H a a r s c a lin g fu n c t io n [E q . ( 7 .2 - 1 4 ) ], w e t h e n g e t t h e r e s u lt s h o w n in F ig . P 7 .1 2 . Problem 7.13 F r o m E q . ( 7 .2 - 1 9 ) , w e fi n d t h a t 3 ,3 (x ) = 2 = 2 a n in E q 1 / d u s in F ig . P . ( 7 .2 p 2 a n g th e H a 7 .1 3 . T o 2 8 ) a n d t d h (1 ) = a r w a v e le t fu n c e x p re s s 3 ,3 ( x h e H a a r w a v e le p − 1 / 2 . T h u s tio ) a t v w e 3 / 2 p (2 3 x − 3 ) (8 x − 3 ) 2 n d e fi n it io n fr o m E q . ( 7 .2 - 3 0 ) , o b t a in t h e p lo t s a fu n c tio n o f s c a lin g fu n c tio n s , w e e m p lo y e c t o r d e fi n e d in E x a m p le 7 .6 — t h a t is , h (0 ) = g e t (x ) = h (n ) p 2 ' (2 x − n ) n s o th a t (8 x − 3 ) = (n ) h p 2 ' (2 [8 x − 3 ] − n ) n = p p 1 2 2 ' (1 6 x − 6 ) + − 1 p p 2 = ' (1 6 x − 6 ) − ' (1 6 x − 7 ). 2 ' (1 6 x − 7 ) C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 3 2 T h e n , s in c e 3 ,3 (x ) = 2 p 3 ,3 (8 x − 3 ) fr o m a b o v e , s u b s titu tio n g iv e s 2 = 2 = 2 p (8 x − 3 ) 2 p p 2 ' (1 6 x − 6 ) − 2 2 ' (1 6 x − 7 ). Problem 7.14 U s in g E q . ( 7 .2 - 2 2 ) , V 3 = V 2 ⊕ W 2 = V 1 ⊕ W 1 ⊕ W 2 = V 0 ⊕ W 0 ⊕ W 1 ⊕ W 2 T h e s c a lin g a n d w a v e le t fu n c t io n s a r e p lo t t e d in F ig . P 7 .1 4 . Problem 7.15 W ith j 0 = 1 th e a p p r o x im a tio n c o e ffi c ie n ts a re c 1 (0 ) a n d c 1 (1 ): 1 / 2 x 2 c 1 (0 ) = x p 2 2 d x = p 2 2 4 0 1 c 1 (1 ) = p 2 d x = 7 p 2 4 2 . 1 / 2 ψ3, 3(x) =2 2 ψ(8x-3) 22 0 -2 2 0 3/8 F ig u r e P 7 .1 3 1 1 3 3 V0 V1 V2 V3 W0 W1 W2 F ig u r e P 7 .1 4 T h e re fo re , th e V 1 a p p r o x im a tio n is p 2 2 4 ' 1 ,0 (x ) + 7 p 2 4 2 ' 1 ,1 (x ) w h ic h , w h e n p lo t t e d , is id e n t ic a l t o t h e V 1 a p p r o x im a t io n in F ig . 7 .1 5 ( d ) . T h e la s t tw o c o e ffi c ie n ts a r e d 1 (0 ) a n d d 1 (1 ), w h ic h a r e c o m p u te d a s in th e e x a m p le . T h u s , th e e x p a n s io n is y = p 2 4 2 ' 1 ,0 (x ) + 7 p 2 4 2 ' 1 ,1 (x ) + − p 3 2 2 1 ,0 (x ) − 3 p 3 2 2 1 ,1 (x ) + ··· Problem 7.16 ( a ) B e c a u s e M = 4 , J = 2 , a n d j 0 = 1 , t h e s u m m a t io n s in E q s . ( 7 .3 - 5 ) t h r o u g h ( 7 .3 - 7 ) a r e p e r fo r m e d o v e r n = 0 , 1 , 2 , 3 , j = 1 , a n d k = 0 , 1 . U s in g H a a r fu n c t io n s a n d a s s u m in g th a t th e y a re d is tr ib u te d o v e r th e r a n g e o f th e in p u t s e q u e n c e , w e C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 3 4 g e t W ' 1 (1 ,0 ) = 1 = W ' 1 (1 ,1 ) = 1 1 1 (1 )( 2 = 2 ) + (4 )( 1 ,1 f (0 ) 2 1 (1 ,1 ) = p f (1 )' (0 ) + p p f (0 ) 2 1 2 s o th a t th e D W T is f 5 (0 ) + f (1 ) 2 ) + (4 )(− p (0 ) + f (1 ) 1 ,0 1 ,1 (1 ) + 1 ,1 p 1 ,0 = 1 ,1 (2 ) + p 2 ) = (1 ) + f (2 ) 1 ,0 1 ,1 (1 ) + p 2 / 2 ,− 3 2 / 2 ,− 3 p f (2 ) 2 ) + (0 )(− p 1 ,1 p f (3 )' p 5 2 2 1 ,0 (3 ) f (3 )' p − 3 2 2 1 ,1 (3 ) (2 ) + 2 ) + (− 3 )(0 ) + (0 )(0 ) p p (2 ) + 1 ,0 f (2 )' 2 ) + (0 )( (1 )(0 ) + (4 )(0 ) + (− 3 )( 2 / 2 ,− 3 f (2 )' 2 ) + (− 3 )(0 ) + (0 )(0 ) f (1 )' (0 ) + (1 ) + 1 ,0 (1 )(0 ) + (4 )(0 ) + (− 3 )( 2 (1 ,0 ) = 1 ,0 f (0 )' 2 = W (1 )( 2 = W f (0 )' 2 = (2 ) + 2 ) = f (3 ) p − 3 2 2 1 ,0 (3 ) f (3 ) p − 3 2 2 1 ,1 (3 ) 2 / 2 g . ( b ) U s in g E q . ( 7 .3 - 7 ) , f (n ) = W 2 1 [W ' (1 ,0 ) (1 ,0 )' 1 ,0 1 ,0 (n ) + W (n ) + W ' (1 ,1 ) (1 ,1 )' 1 ,1 1 ,1 (n )+ (n )] w h ic h , w ith n = 1 , b e c o m e s p p p 2 f (1 ) = (5 )( 2 ) + (− 3 )(0 ) + (− 3 )( 2 ) + (− 3 )(0 ) 4 p 2 ( 2 )2 = 1 . = 4 Problem 7.17 In in W fu ila a c is tu itiv e ly , th e c o n tin u o u s w a v e le t tr a n s fo r m (C d e x ” b e tw e e n th e s ig n a l a n d th e w a v e le t a t v h e n th e in d e x is la r g e , th e r e s e m b la n c e is s tr n c tio n is s im ila r to its e lf a t d iffe r e n t s c a le s , th e r a t d iffe r e n t s c a le s . T h e C W T c o e ffi c ie n t v a lu te r is tic p a tte r n . A s a r e s u lt, w e c a n s a y th a t th e s e lf- s im ila r — lik e a fr a c ta l s ig n a l. W T ) c a lc u la te s a “ r e s e m b la n c e a r io u s s c a le s a n d tr a n s la tio n s . o n g ; e ls e it is w e a k . T h u s , if a r e s e m b la n c e in d e x w ill b e s im e s (th e in d e x ) w ill h a v e a c h a r fu n c tio n w h o s e C W T is s h o w n 1 3 5 {-1/ 2 , -3/ 2, 7/ 2, -3/ 2, 0} {-1/ 2, 1/ 2} 2 Wψ(1, n) = {-3/ 2, -3/ 2} {1/ 2, 1/ 2} 2 Wϕ(1, n) = {5/ 2, -3/ 2} Wϕ(2, n) = f(n) = {1, 4, -3, 0} {1/ 2 , 5/ 2, 1/ 2, -3/ 2, 0} F ig u r e P 7 .1 9 Problem 7.18 ( a ) T h e s c a le a n d tr a n s la tio n p a r a m e te r s a r e c o n tin u o u s , w h ic h le a d s to th e o v e r c o m p le te n e s s o f th e tr a n s fo r m . (b is o f o f ) T h e D W T is a s u ffi c ie n t fo r te n e a s ie r to in th e fu n c tio n o b re te r e t c o rp im te r c h o ic e w h e n s tr u c tio n o f re t b e c a u s e th a g e . F o r e x a m n w e n e e d th e o r ig in a e b u ilt- in r e p le , s e e th e a s p a c l fu n c d u n d s e lf- s e s a v tio n a n c y im ila in g re o r im te n d s r ity o p r a g to f P e s e . re ro e n ta t T h e in fo r b le m io n th a t C W T is c e tr a its 7 .1 7 . Problem 7.19 T h e fi lt e r b a n k is t h e fi r s t b a n k in F ig . 7 .1 9 , a s s h o w n in F ig . P 7 .1 9 : Problem 7.20 T h e c o m p le x ity is d e te r m in e d b y th e n u m b e r o f c o e ffi c ie n ts in th e s c a lin g a n d w a v e le t v e c t o r s — t h a t is , b y n in E q s . ( 7 .2 - 1 8 ) a n d ( 7 .2 - 2 8 ) . T h is d e fi n e s t h e n u m b e r o f ta p s in fi lte r s h (− n ), h ' (− n ), h (n ), a n d h ' (n ). Problem 7.21 ( a ) I n p u t ' ( n ) = f 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 g = ' 0 ,0 ( n ) f o r a t h r e e - s c a l e w a v e l e t t r a n s f o r m w ith H a a r s c a lin g a n d w a v e le t fu n c tio n s . S in c e w a v e le t tr a n s fo r m c o e ffi c ie n ts m e a s u r e th e s im ila r ity o f th e in p u t to th e b a s is fu n c tio n s , th e r e s u ltin g tr a n s fo r m is f W ' (0 ,0 ),W (0 ,0 ),W W (1 ,0 ),W (2 ,3 )g = f 2 (1 ,1 ),W p (2 ,0 ),W 2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 g . (2 ,1 ),W (2 ,2 ) C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 3 6 = k = 0 . p (b ) U s in g th e s a m e re a s o n in g a s in p a r t (a ), th e tr a n s fo r m is f 0 ,2 2 ,0 ,0 ,0 ,0 ,0 ,0 g . T h e W ' (0 , 0 ) t e r m c a n b e c o m p u t e d u s in g E q . ( 7 .3 - 5 ) w it h j 0 ( c ) F o r th e g iv e n tr a n s fo r m , W (2 , 2 ) = B a n d a ll o th e r tr a n s fo r m c o e ffi c ie n ts a r e 0 . T h u s , th e in p u t m u s t b e p r o p o r tio n a l to 2 ,2 ( x ) . T h e i n p u t s e q u e n c e m u s t b e o f t h e fo r m f 0 , 0 , 0 , 0 , C , − C , 0 , 0 g fo r s o m e C . T o d e t e r m in e C , u s e E q . ( 7 .3 - 6 ) t o w r ite W (2 ,2 ) = 1 p f f (0 ) 8 f (4 ) = 2 ,2 p 1 (4 ) + 2 ,2 (0 ) + f (5 ) p 2 ,2 (5 ) + 2 ,2 (1 ) + f (6 ) f (2 ) 2 ,2 (6 ) + 2 ,2 (2 ) + f (7 ) f (3 ) 2 ,2 2 ,2 (3 )+ (7 )g f (0 )(0 ) + (0 )(0 ) + (0 )(0 ) + (0 )(0 ) + (C )(2 ) + (− C )(− 2 )+ 8 (0 )(0 ) + (0 )(0 )g = f (1 ) 1 8 f 2 C + 2 C g = 4 C p 8 = p 2 C . p B e c a u s e th is c o e ffi c ie n t is k n o w n to h a v e th e v a lu e B , w e h a v e th a t 2 C = B o r p 2 B . C = 2 p p T h u s , th e in p u t s e q u e n c e is f 0 ,0 ,0 ,0 , 2 B / 2 ,− 2 B / 2 , 0 , 0 g . T o c h e c k th e r e s u lt s u b s t it u t e t h e s e v a lu e s in t o E q . ( 7 .3 - 6 ) : p 1 2 W (2 ,2 ) = p f (0 )(0 ) + (0 )(0 ) + (0 )(0 ) + (0 )(0 ) + ( B )(2 )+ 2 8 p 2 B )(− 2 ) + (0 )(0 ) + (0 )(0 )g (− 2 p 1 p 2 B g = p f 2 B + 8 = B . Problem 7.22 T h e y a re b r e s o lu tio n F W T , th e s e m id , th e y a T o c o n s in F ig . 7 .1 0 p la c e th e 6 o th m u lti- r e s o lu tio n r e p r e s e n ta tio n s th a t e m p lo a p p r o x im a tio n im a g e a n d a s e r ie s o f “d iffe re n c “d iffe re n c e ” im a g e s a re th e tr a n s fo r m d e ta il c o e ffi r e th e p r e d ic tio n r e s id u a ls . tr u c t th e a p p r o x im a tio n p y r a m id th a t c o r re s p o n (a ), w e w ill u s e th e F W T − 1 2 - d s y n th e s is b a n k o 4 × 6 4 a p p r o x im a t io n “ c o e ffi c ie n t s ” fr o m F ig . 7 .1 0 y a s in g le r e d u c e d e ” im a g e s . F o r th e c ie n ts ; fo r th e p y r a d s to th e tra n s fo r m f F ig . 7 .2 4 ( c ) . F ir s t , (a ) a t th e to p o f th e 1 3 7 D 22 22 {-1/ 2, 1/ 2} 2 Each Row Columns (along n) Wϕ(1, m, n) = 3 -1 62 2 42 {1/ 2, 1/ 2} 2 Wψ(0, 0, 0) =[0] {-1/ 2, 1/ 2} 2 Each Column Rows (along m) {1/ 2, 1/ 2} 2 Each Column Rows {-1/ 2, 1/ 2} 2 Each Column Rows {1/ 2, 1/ 2} 2 Each Column Rows V Wψ(0, 0, 0) =[4] 5 -3 40 H Wψ(0, 0, 0) =[-3] Each Row Columns Ordered per Fig. 7.24(b) Wϕ(0, 0, 0) =[5] F ig u r e P 7 .2 3 p y r a m id b e in g c o n s tr u c te d . T h e n u s e it, a lo n g w ith 6 4 × 6 4 h o r iz o n ta l, a n d d ia g o n a l d e t a il c o e ffi c ie n t s fr o m t h e u p p e r - le ft o f F ig . 7 .1 0 ( a ) , t o d fi lt e r b a n k in p u t s in F ig . 7 .2 4 ( c ) . T h e o u t p u t w ill b e a 1 2 8 × 1 2 8 a p p r o x o f th e o r ig in a l im a g e a n d s h o u ld b e u s e d a s th e n e x t le v e l o f th e a p p r o x p y r a m id . T h e 1 2 8 × 1 2 8 a p p r o x im a tio n is th e n u s e d w ith th e th re e 1 2 8 × t a il c o e ffi c ie n t im a g e s in t h e u p p e r 1 / 4 o f t h e t r a n s fo r m in F ig . 7 .1 0 ( a ) t h e s y n t h e s is fi lt e r b a n k in F ig . 7 .2 4 ( c ) a s e c o n d t im e — p r o d u c in g a 2 5 6 × p r o x im a tio n th a t is p la c e d a s th e n e x t le v e l o f th e a p p r o x im a tio n p y r a m p r o c e s s is th e n re p e a te d a th ird tim e to re c o v e r th e 5 1 2 × 5 1 2 o r ig in a w h ic h is p la c e d a t th e b o tto m o f th e a p p r o x im a tio n p y r a m id . T h u s , th e im a tio n p y r a m id w o u ld h a v e 4 le v e ls . v e r tic a l, r iv e th e im a tio n im a tio n 1 2 8 d e to d r iv e 2 5 6 a p id . T h is l im a g e , a p p ro x - Problem 7.23 O n e p a s s t h r o u g h t h e F W T 2 - d fi lt e r b a n k o f F ig . 7 .2 4 ( a ) is a ll t h a t is r e q u ir e d ( s e e F ig . P 7 .2 3 ) . Problem 7.24 A s c a n b e in v a r ia n t. in th e p r o c o m p u ta t s e e n If th e b le m io n p in t in p a re ro c e h e s e q u e n c e o u t is s h ifte d , th 1 2 8 × 1 2 8 , th e s s . T h e fi lte r b f im a g e s t e tra n s fo r y b e c o m e a n k o f F ig h a m th . 7 t a re c h a n e W ' .2 4 ( a s h o w g e s . S (7 ,m ) c a n n , th e in c e a ,n ) in b e u s D W T is ll o r ig in p u ts fo r e d w ith n o t a l im th e j + 1 s h ift a g e s F W T = 7 . C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 3 8 F o r a s in g le s c a le tr a n s fo r m , tr a n s fo r m c o e ffi c ie n ts W ' (6 , m , n ) a n d W i (6 , m , n ) fo r i = H , V , D a r e g e n e r a te d . W ith H a a r w a v e le ts , th e tr a n s fo r m a tio n p r o c e s s s u b d iv id e s th e im a g e in to n o n - o v e r la p p in g 2 × 2 b lo c k s a n d c o m p u te s 2 - p o in t a v e r a g e s a n d d iffe r e n c e s (p e r th e s c a lin g a n d w a v e le t v e c to r s ). T h u s , th e r e a r e n o h o r iz o n ta l, v e r tic a l, o r d ia g o n a l d e ta il c o e ffi c ie n ts in th e fi r s t tw o tr a n s fo r m s s h o w n ; th e in p u t im a g e s a r e c o n s ta n t in a ll 2 × 2 b lo c k s (s o a ll d iffe r e n c e s a r e 0 ). If th e o r ig in a l im a g e is s h ifte d b y o n e p ix e l, d e ta il c o e ffi c ie n ts a r e g e n e r a te d s in c e th e re a re th e n 2 × 2 a re a s th a t a re n o t c o n s ta n t. T h is is th e c a s e in th e th ird tra n s fo r m s h o w n . Problem 7.25 T h e t a b le is c o m p le t e d a s s h o w n in F ig . P 7 .2 5 . T h e fu n c t io n s a r e d e t e r m in e d u s in g E q s . ( 7 .2 - 1 8 ) a n d ( 7 .2 - 2 8 ) w it h t h e H a a r s c a lin g a n d w a v e le t v e c t o r s fr o m E x a m p le s 7 .5 a n d 7 .6 : ' (x ) = ' (2 x ) + ' (2 x − 1 ) (x ) = ' (2 x ) − ' (2 x − 1 ). T o o r d e r th e w a v e le t fu n c tio n s in fr e q u e n c y , c o u n t th e n u m b e r th a t a r e m a d e b y e a c h fu n c tio n . F o r e x a m p le , V 0 h a s th e fe w e s t tr a 2 ) a n d lo w e s t fr e q u e n c y c o n te n t, w h ile W 2 ,A A h a s th e m o s t (9 ) tr c o r r e s p o n d in g ly h ig h e s t fr e q u e n c y c o n te n t. F r o m to p to b o tto m th e r e a r e 2 , 3 , 5 , 4 , 9 , 8 , 6 , a n d 7 tr a n s itio n s , r e s p e c tiv e ly . T h e r e fo r e , o r d e r e d s u b s p a c e s a r e (fr o m lo w to h ig h fr e q u e n c y ) V 0 , W 0 , W 1 ,D W 2 ,D D , W 2 ,A D , a n d W 2 ,A A . o f tr a n s itio n s n s itio n s (o n ly a n s itio n s a n d in th e fi g u re , th e fre q u e n c y , W 1 ,A , W 2 ,D A , Problem 7.26 ( a ) T h e a n a ly s is t r e e is s h o w n in F ig . P 7 .2 6 ( a ) . ( b ) T h e c o r r e s p o n d in g fr e q u e n c y s p e c t r u m is s h o w n in F ig . P 7 .2 6 ( b ) . Problem 7.27 F ir s t u s e th e e n tr o p y m e a s u r e to fi n d th e s ta r tin g v a lu e fo r th e in p u t s e q u e n c e , w h ic h is 7 E f f (n )g = f 2 (n ) ln f 2 (n ) = 2 .7 7 2 6 . n = 0 T h e n p e r fo r m a n ite r a tio n o f th e F W T a n d c o m p u te th e e n tr o p y o f th e g e n e r a te d a p p r o x im a t io n a n d d e t a il c o e ffi c ie n t s . T h e y a r e 2 .0 7 9 4 a n d 0 , r e s p e c t iv e ly . S in c e 1 3 9 V0 V1 W0 W1,A V2 W1,D W1 W2,AA W2,A W2,AD W2,DA V3 W2 W2,DD W2,D F ig u r e P 7 .2 5 t h e ir s u m is le s s t h a n t h e s t a r t in g e n t r o p y o f 2 .7 7 2 6 , w e w ill u s e t h e d e c o m p o s itio n . B e c ra n te d it s h o u d e c o m a u . T ld p o s e h u b e s it th s , d io e d e ta w e p e e c o m n s a re il e n tr r fo r m p o s e d c a lle d o p a n a g fo y is o th a in r. T 0 , n o f e r F W . T h is h e re s u r th e r d e c o m T ite r a tio n o n p r o c e s s is th e u ltin g o p tim a p o s itio th e a p n re p e l tre e is n o p ro a te s h f th e x im d u n o w n d e ta il is a tio n to til n o fu in F ig . P VJ H VJ -1 VJ -2 H WJ -2 V WJ -2 WJ -1 V WJ -1 D WJ -1 D D D D D WJ -1,A WJ -1,H WJ -1,V WJ -1,D WJ -2 D D D D WJ -1,HA WJ -1,HH WJ -1,HV WJ -1,HD F ig u r e P 7 .2 6 ( a ) w a s e e r th 7 .2 rif e r 7 . C H A P T E R 7 . P R O B L E M S O L U T IO N S 1 4 0 ωVERT a = VJ -2 π w z o n ml x w n o x l m WJ -1 c d H b =WJ -2 z V c =WJV-2 D d =WJ -2 d D x =WJ -1,A H −π WJ -1 a b d w z WJ -1 π d c ml o n x H b z = WJD-1,V D w =WJ -1,D D V WJ -1 x l m n o z w l = WJ -1,HA D m =WJ -1,HH D n =WJ -1,HV −π D o =WJ -1,HD F ig u r e P 7 .2 6 ( b ) 2.7726 2.0794 1.3863 0.6931 0 ωHORIZ 0 0 F ig u r e P 7 .2 7 D u m m y w h it e t e x t t o m o v e fi g u r e .. 0 0 Chapter 8 Problem Solutions Problem 8.1 ( a ) A h is to g r a m e q u a liz e d im a g e (in th e o r y ) h a s a n in te n s ity d is tr ib u tio n w h ic h is u n ifo r m . T h a t is , a ll in t e n s it ie s a r e e q u a lly p r o b a b le . E q . ( 8 .1 - 4 ) t h u s b e c o m e s L w h e re a re e q fe w e r to c o v 1 / 2 n is t u a lly p r o b its th a n e r th e 2 n h e p b a b a n y le v e ro b a b le , th e o th e r ls . T h a v g ility o f re is n o . T h u s , is , o f c o L o c c a d w e u rs a v g 2 n 2 1 = − 1 l (r k ) n k = 0 u r re n c e o f a n y in te n v a n ta g e to a s s ig n in g a s s ig n e a c h th e fe w e e is n b its a n d L a v g 2 1 = = S in c p a r t s s ib m e s e a ll in ic u la r le b its n b its te n s itie s in te n s ity re q u ire d a ls o : − 1 (n ) n 2 = n s ity . a n y s t p o b e c o k = 0 1 2 n 2 n n n . (b ) S in c e s p a tia l re d u n d a n c y is a s s o c ia te d w ith th e g e o m e tr ic a r r a n g e m e n t o f th e in te n s ite s s in th e im a g e , it is p o s s ib le fo r a h is to g r a m e q u a liz e d im a g e to c o n ta in a h ig h le v e l o f s p a tia l r e d u n d a n c y - o r n o n e a t a ll. Problem 8.2 ( a ) A s in g le lin e o f r a w d a ta c o n ta in s n 1 = 2 n b its . T h e m a x im u m r u n le n g th w o u ld b e 2 n a n d th u s r e q u ir e n b its fo r r e p r e s e n ta tio n . T h e s ta r tin g c o o r d in a te 1 4 1 C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 4 2 o f e a c h p ix e l lin u s e d to lin e . T h r u n a e . S in s ig n a u s , th ls o c e l th e to re q u ire s n a r u n le n g e s ta r t o f e ta l n u m b e b its s in c th o f 0 c a a c h n e w r o f b its r n = 2 e it n n lin e e q u m a y o t o c - a n ire d 2 n + N = a v g 1 + N 2 n b e c u a d to a r b itr a r a n d th d itio n a c o d e a n r ily lo c a te e r u n - le n l 2 n b its a y s c a n lin d w ith in th e 2 n g th p a ir (0 ,0 ) is re re q u ire d p e r e is (n + n ) a v g w h e r e N a v g is th e a v e r a g e n u m b e r o f r u n - le n g th p a ir s o n a lin e . T o a c h ie v e s o m e le v e l o f c o m p r e s s io n , C m u s t b e g r e a te r th a n 1 . S o , n n = C 1 2 1 + N 2 n a n d N (b ) F o r n = 1 0 , N n 2 = a v g < 2 > 1 a v g n − 1 − 1 . n m u s t b e le s s t h a n 5 0 .2 r u n - le n g t h p a ir s p e r lin e . a v g Problem 8.3 T h e o r ig e n c e s b e m u s t b e s ig n a l- to in a l p ix e l in t tw e e n th e m m u ltip lie d b - n o is e c a lc u f B a s e 1 0 1 0 8 1 3 9 1 3 5 2 4 4 1 7 2 1 7 3 5 6 9 9 e n s itie a re s h o y 1 6 to la tio n s s , th e ir 4 - b it q u a n tiz e d c o u n te r p a r ts , a n d th e d iffe rw n in T a b le P 8 .3 . N o t e t h a t t h e q u a n t iz e d in t e n s it ie s d e c o d e o r d e c o m p re s s th e m fo r th e r m s e rro r a n d . x ,y 0 1 1 1 1 1 0 0 B a s e 1 1 0 1 0 0 0 1 0 0 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 0 2 1 0 0 0 1 1 1 1 1 1 0 0 1 0 0 1 0 1 0 0 0 0 1 1 T a b le P f^ x , y B a s e 2 B 0 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 0 8 .3 a s e 1 0 6 8 8 1 5 1 0 1 0 3 6 1 6 f^ x , y − f B a s e 1 0 -1 2 -1 1 -7 -4 -1 2 -1 3 -8 -3 x ,y 1 4 3 U s in g E q . ( 8 .1 - 1 0 ) , t h e r m s e r r o r is e 5 6 6 1 7 = r m s 8 * 1 8 * = 7 1 6 f^ x , y f − x ,y 2 x = 0 y = 0 (− 1 2 )2 + (− 1 1 )2 + (− 7 )2 + (− 4 )2 + (− 1 2 )2 + (− 1 3 )2 + (− 8 )2 + (− 3 ) = = 0 1 8 2 (7 1 6 ) 9 .4 6 o r a b o u t 9 .5 in t e n s it y le v e ls . F r o m E q . ( 8 .1 - 1 1 ) , t h e s ig n a l- t o - n o is e r a t io is 2 S N R = 2 m s 9 6 = = ' 0 x = 0 2 + 0 x = 0 2 7 1 2 y = 0 8 2 + 2 7 1 6 f^ x , y 1 2 8 2 1 6 f^ x , y y = 0 2 + 2 4 0 f − 2 2 x ,y + 1 6 0 7 1 6 2 + 1 6 0 2 + 4 8 2 + 9 6 2 1 6 2 3 0 4 7 1 6 2 2 7 . Problem 8.4 (a u s d e d e ) T a b e d in c im a c o d e le P 8 .4 s e a c h s t l e q u iv a d IG S in h o w s th e e p , th e 4 le n t o f th te n s itie s s ta r b it I e IG a n d tin G S S c th g in te n s ity v a lu e s , c o d e a n d its e q u iv o d e m u ltip lie d b y e in p u t v a lu e s , a n d th e ir 8 - b it c o a le n t d e c o d e 1 6 ), th e e rro r th e s q u a re d d e s , th e IG S s u m d v a lu e (th e b e tw e e n th e e rro r. ( b ) U s in g E q . ( 8 .1 - 1 0 ) a n d t h e s q u a r e d e r r o r v a lu e s fr o m T a b le P 8 .4 , t h e r m s e r r o r is * 1 e r m s = (1 4 4 + 2 5 + 4 9 + 1 6 + 1 6 + 1 6 9 + 6 4 + 9 ) 8 * 1 (4 9 2 ) = 8 = 7 .8 4 C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 4 4 o r a b o u t 7 .8 in t e n s it y le v e ls . F r o m E q . ( 8 .1 - 1 1 ) , t h e s ig n a l- t o - n o is e r a t io is S N R 9 6 = m s ' 1 0 8 1 3 9 1 3 5 2 4 4 1 7 2 1 7 3 5 6 9 9 8 - b it C o d e 0 1 1 0 1 0 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 1 0 1 1 1 0 2 + 1 4 4 + 1 2 8 2 + 2 4 0 2 + 1 7 6 4 9 2 2 + 1 6 0 2 + 6 4 2 + 9 6 2 1 7 3 8 2 4 4 9 2 3 5 3 . = In te n s ity 2 1 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 1 S u 0 0 1 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 m 0 0 1 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 T a b le P 8 .4 IG S C o d e D e c o d e d IG S E rro r S q u a re E rro r -1 2 5 -7 -4 4 -1 3 8 -3 1 4 4 2 5 4 9 1 6 1 6 1 6 9 6 4 9 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 9 6 1 4 4 1 2 8 2 4 0 1 7 6 1 6 0 6 4 9 6 Problem 8.5 (a ) T h e m a x im u m c o m p re s s io n w ith H u ffm a n c o d in g is C = (b ) N o , p e r in te a tim e . (c ) O n e m a n e n a n d H u 8 5 .3 = 1 .5 0 9 . b u t H u ffm a n c o d in g d o e s p r o v id e th e s m a lle s t p o s s ib le n u m b e r o f b its n s ity v a lu e s u b je c t to th e c o n s tr a in t th a t th e in te n s itie s a r e c o d e d o n e a t p o s s ib ility is to e lim in a te s p a tia l r e d u n d a n c ie s in th e im a g e b e fo r e H u ffc o d in g . F o r in s ta n c e , c o m p u te th e d iffe r e n c e s b e tw e e n a d ja c e n t p ix e ls ffm a n c o d e th e m . Problem 8.6 T h e c o n v e r s io n fa c to r s a r e c o m p u te d u s in g th e lo g a r ith m ic r e la tio n s h ip lo g a x = 1 lo g b a lo g b x . T h u s , 1 H a r t le y = 3 .3 2 1 9 b it s a n d 1 n a t = 1 .4 4 2 7 b it s . 1 4 5 Problem 8.7 3 4 L e t t h e s e t o f s o u r c e s y m b o ls b e a 1 , a 2 , ..., a q w it h p r o b a b ilit ie s P (a 1 ) , P (a T h e n , u s in g E q . ( 8 .1 - 6 ) a n d t h e fa c t t h a t t h e s u m o f a ll P (a i ) is 1 , w e g e t ⎤ ⎡ q ⎢ lo g q ⎣ = lo g q − H P a j ) , ..., P q ⎥ ⎦+ P j = 1 a j lo g P a j j = 1 q = 2 q P lo g q + a j P j = 1 a lo g P j a j j = 1 q = P a lo g q P j a j . j = 1 U s in g t h e lo g r e la t io n s h ip fr o m P r o b le m 8 .6 , t h is b e c o m e s q = lo g e P a j ln q P a j . j = 1 T h e n , m u ltip ly in g th e in e q u a lity ln x ≤ x − 1 b y - 1 to g e t ln 1 / x ≥ p ly in g it to th is la s t r e s u lt, ⎡ ⎤ q 1 ⎦ P a j ⎣1 − lo g q − H ≥ lo g e q P a j i j = 1 ⎤ ⎡ q q P a 1 j ⎥ ⎢ ≥ lo g e ⎣ P a j − ⎦ q a j j = 1 j = 1 P ≥ lo g e [1 − 1 ] ≥ 0 1 − x a n d a p - s o th a t lo g q ≥ H . T h e re fo r e q u a lity p o in t in 1 / q fo r a e , H is a lw a y s le s s th a n , o r e q u a l to , lo g q . F u r th e r m o r e , in v ie w o f th e c o n d itio n (x = 1 ) fo r ln 1 / x ≥ 1 − x , w h ic h w a s in tr o d u c e d a t o n ly o n e th e a b o v e d e r iv a tio n , w e w ill h a v e s tr ic t e q u a lity if a n d o n ly if P (a j ) = ll j . Problem 8.8 (a ) T h e re a re tw o u n iq u e c o d e s . a T q . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 4 6 21 243 95 169 3/8 3/8 1/8 1/8 3/8 3/8 2/8 5/8 3/8 21 243 95 169 1 00 000 001 1 00 01 0 1 Code assignments Source reductions F ig u r e P 8 .9 ( b ) T h e c o d e s a r e : (1 ) 0 , 1 1 , 1 0 a n d (2 ) 1 , 0 0 , 0 1 . T h e c o d e s a r e c o m p le m e n ts o f o n e a n o th e r. T h e y a r e c o n s tr u c te d b y fo llo w in g th e H u ffm a n p r o c e d u r e fo r th r e e s y m b o ls o f a r b itr a r y p r o b a b ility . Problem 8.9 ( a ) T h e e n t r o p y o f t h e im a g e is e s t im a t e d u s in g E q . ( 8 .1 - 7 ) t o b e 2 5 5 H˜ = p − r (r k ) lo g 2 p r (r k ) k = 0 = − = = 4 4 1 2 1 2 4 4 lo g 2 + lo g 2 + lo g 2 + 3 2 3 2 3 2 3 2 3 2 3 2 − [− 0 .5 3 0 6 − 0 .3 7 5 − 0 .3 7 5 − 0 .5 3 0 6 ] 1 2 lo g 3 2 1 2 2 3 2 1 .8 1 1 b it s / p ix e l. T h e p r o b a b ilit ie s u s e d in t h e c o m p u t a t io n a r e g iv e n in T a b le P 8 .9 - 1 . In te n s ity 2 1 9 5 1 6 9 2 4 3 T a b le P 8 .9 - 1 C o u n t P ro b 1 2 3 4 1 4 1 1 2 3 a b ility / 8 / 8 / 8 / 8 ( b ) F ig u r e P 8 .9 s h o w s o n e p o s s ib le H u ffm a n s o u r c e r e d u c t io n a n d c o d e a s s ig n m e n t . U s e t h e p r o c e d u r e s d e s c r ib e d in S e c t io n 8 .2 .1 . T h e in t e n s it ie s a r e fi r s t a r r a n g e d in o r d e r o f p r o b a b ility fr o m th e to p to th e b o tto m (a t th e le ft o f th e s o u r c e r e d u c tio n d ia g r a m ). T h e le a s t p r o b a b le s y m b o ls a r e th e m c o m b in e d to c r e a te a r e d u c e d s o u r c e a n d th e p r o c e s s is r e p e a te d fr o m le ft to r ig h t in th e d ia g r a m . C o d e w o r d s a r e th e n a s s ig n e d to th e r e d u c e d s o u r c e s y m b o ls fr o m r ig h t to le ft. T h e c o d e s a s s ig n e d to e a c h in te n s ity v a lu e a r e r e a d fr o m th e le ft s id e o f th e c o d e a s s ig n m e n t d ia g r a m . 1 4 7 ( c ) U s in g E q . ( 8 .1 - 4 ) , t h e a v e r a g e n u m b e r o f b it s r e q u ir e d t o r e p r e s e n t e a c h p ix e l in th e H u ffm a n c o d e d im a g e (ig n o r in g th e s to r a g e o f th e c o d e its e lf ) is L a v g 3 = 1 3 8 + 2 1 + 3 8 1 + 3 8 = 8 1 5 = 1 .8 7 5 b it s / p ix e l. 8 T h u s , th e c o m p re s s io n a c h ie v e d is 8 C = B e c a u s e th c o d in g re d 4 .2 7 × 1 0 0 4 .4 1 7 re m o v a l o f e t u n o r c o h d 9 d 1 .8 7 5 e o re tic a l c o m p re s s io a n c y i s 1 . 88 1 1 = 4 . 4 1 7 , 6 .6 7 % o f t h e m a x im u in g r e d u n d a n c y a lo n = 4 .2 7 . n r e s u ltin g fr o m th e e lim in a tio n o f a ll th e H u ffm a n c o d e d im a g e a c h ie v e s m c o m p r e s s io n p o s s ib le th r o u g h th e e . ( d ) W e c a n c o m p u te th e r e la tiv e fr e q u e n c y o f p a ir s o f p ix e ls b y a s s u m in g th a t th e im a g e is c o n n e c te d fr o m lin e to lin e a n d e n d to b e g in n in g . T h e r e s u ltin g p r o b a b ilit ie s a r e lis t e d in T a b le P 8 .9 - 2 . T a b le In te n s ity p a ir C (2 1 , 2 1 ) (2 1 , 9 5 ) (9 5 , 1 6 9 ) (1 6 9 , 2 4 3 ) (2 4 3 , 2 4 3 ) (2 4 3 , 2 1 ) P 8 .9 - 2 o u n t P ro b a 8 1 / 4 1 / 4 1 / 4 1 / 8 1 / 4 1 / b ility 4 8 8 8 4 8 T h e e n t r o p y o f t h e in t e n s it y p a ir s is e s t im a t e d u s in g E q . ( 8 .1 - 7 ) a n d d iv id in g b y 2 (b e c a u s e th e p ix e ls a r e c o n s id e r e d in p a ir s ): 1 2 H˜ = − = = 1 1 lo g 1 2 + 1 2 4 4 8 2 .5 2 1 .2 5 b it s / p ix e l. lo g 1 2 8 + 1 8 lo g 1 2 8 + 1 8 lo g 1 2 8 + 1 4 lo g 1 2 4 + 1 8 lo g 1 2 8 T h e d iffe r e n c e b e tw e e n th is v a lu e a n d th e e n tr o p y in (a ) te lls u s th a t a m a p p in g c a n b e c r e a t e d t o e lim in a t e (1 .8 1 1 − 1 .2 5 ) = 0 .5 6 b it s / p ix e l o f s p a t ia l re d u n d a n c y . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 4 8 ( e ) C o n s tr u c t a d iffe r e n c e im a g e b y r e p lic a tin g th e fi r s t c o lu m n o f th e o r ig in a l im a g e a n d u s in g th e a r ith m e tic d iffe r e n c e b e tw e e n a d ja c e n t c o lu m n s fo r th e r e m a in in g e le m e n ts . T h e d iffe r e n c e im a g e is 2 1 0 0 7 4 7 4 7 4 0 0 2 1 0 0 7 4 7 4 7 4 0 0 2 1 0 0 7 4 7 4 7 4 0 0 2 1 0 0 7 4 7 4 7 4 0 0 T h e p r o b a b ilitie s o f its v a r io u s e le m e n ts a r e g iv e n in T a b le 8 .9 - 3 . T a b le P 8 .9 - 3 In te n s ity d iffe re n c e C o u n t 2 1 4 0 1 6 7 4 1 2 P ro b a 1 / 1 / 3 / b ility 8 2 8 T h e e n t r o p y o f t h e d iffe r e n c e im a g e is e s t im a t e d u s in g E q . ( 8 .1 - 7 ) t o b e H˜ = − 1 8 lo g 1 2 1 + 8 1 lo g 2 ( f ) T h e e n tr o p y c a lc u la te d in (a ) is d e p e n d e n t p ix e ls . T h e e n tr o p y (o s m a lle r th a t th e v a lu e fo u n d in (a in d e p e n d e n t . T h e r e is a t le a s t (1 .8 d a n c y in th e im a g e . T h e d iffe re n c e th a t s p a tia l r e d u n d a n c y , le a v in g o n 2 3 + 2 3 lo g 8 2 = 1 .4 1 b it s / p ix e l. 8 b a s e d o n th e a s s u m p tio n f th e p ix e l p a ir s ) c o m p u te ), r e v e a ls th a t th e p ix e ls a 1 1 − 1 .2 5 ) = 0 .5 6 b it s / p ix e im a g e m a p p in g u s e d in (e ly (1 .4 1 − 1 .2 5 ) = 0 .1 6 b it s / o f s ta tis tic a lly in d in (d ), w h ic h is r e n o t s ta tis tic a lly l o f s p a tia l re d u n ) re m o v e s m o s t o f p ix e l. Problem 8.10 T h e d e c o d e d m e s s a g e is a 3 a 6 a 6 a 2 a 5 a 2 a 2 a 2 a 4 . Problem 8.11 T h e G o lo m b c o d e is s h o w n in T a b le P 8 .1 1 . It is c o m p u t e d b y t h e p r o c e d u r e o u t lin e d in S e c t io n 8 .2 .2 in c o n ju n c t io n w it h E q . ( 8 .2 - 1 ) . 1 4 9 In te g e r n U n a r y c o d e o f 0 8n 9 m T a b le P 8 .1 1 T r u n c a te d n m o d m 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 0 5 1 0 1 1 6 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 G o lo m b c o d e G 0 1 0 1 1 0 3 (n ) 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 0 Problem 8.12 T o d e c o d e G m (n ), le t k = : lo g 2 m ; a n d c = 2 k − m . T h e n : 1 . C o u n t th e n u m b e r o f 1 s in a le ft- to - r ig h t s c a n o f a c o n c a te n a te d G m (n ) b it s e q u e n c e b e fo r e r e a c h in g th e fi r s t 0 , a n d m u ltip ly th e n u m b e r o f 1 s b y m . 2 . If th e d e c im a l e q u iv a le n t o f th e n e x t k − 1 b its is le s s th a n c , a d d it to r e s u lt fr o m s te p 1 ; e ls e a d d th e d e c im a l e q u iv a le n t o f th e n e x t k b its a n d s u b tr a c t c . F o r e x a m p le , to d e c o d e th e fi r s t G 3 (n ) c o d e : ; 1 1 1 1 0 1 0 0 1 1 ..., le t k = lo g 2 3 = 2 , c = 2 2 − in a le ft- to - r ig h t s c a n o f th e b it s tr e a m b e fo th e n u m b e r o f 1 s b y 3 y ie ld s 1 2 (th e r e s u lt id e n tifi e d in s te p 1 is a 1 , w h o s e d e c im a l e q u S o a d d th e d e c im a l e q u iv a le n t o f th e 2 b its a n d s u b tr a c t 1 . T h u s , th e fi r s t in te g e r is 1 2 + th e n e x t c o d e w o rd , w h ic h b e g in s w ith b its 0 in th e G o lo m b c o d e d b it s e q u e n c e 3 = 1 , a n d n o te th a t th e re a re 4 1 s r e r e a c h in g th e fi r s t 0 . M u ltip ly in g o f s te p 1 ). T h e b it fo llo w in g th e 0 iv a le n t is n o t le s s t h a n c , i.e ., 1 ≮ 1 . fo llo w in g th e 0 id e n tifi e d in s te p 1 2 − 1 = 1 3 . R e p e a t th e p ro c e s s fo r 1 1 ... C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 5 0 Problem 8.13 T h e p r o b a b ilit y m a s s fu n c t io n d e fi n e d b y E q . ( 8 .2 - 2 ) is fo r a n in fi n it e s e t o f in te g e r s . It is n o t p o s s ib le to lis t a n in fi n ite s e t o f s o u r c e s y m b o ls a n d p e r fo r m th e s o u r c e r e d u c t i o n s r e q u i r e d b y H u f f m a n ’s a p p r o a c h . Problem 8.14 T h e e x p o n e n tia l G o lo m b c o d e is s h o w n in T a b le P 8 .1 4 . It is c o m p u te d b y th e p r o c e d u r e o u t lin e d in S e c t io n 8 .2 .2 in c o n ju n c t io n w it h E q s . ( 8 .2 - 5 ) a n d ( 8 .2 - 6 ) . In te g e r n T a b le P 8 .1 4 P a ra m e te r i G o lo m b c o d e G 0 0 1 0 2 0 3 0 4 1 5 1 6 1 7 1 8 1 9 1 1 0 1 1 1 1 1 2 2 1 3 2 1 4 2 1 5 2 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 2 e x p (n ) 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 Problem 8.15 T o d e c o d e G k e x p (n ): 1 . C o u n t t h e n u m b e r o f 1 s i n a l e f t - t o - r i g h t s c a n o f a c o n c a t e n a t e d G ek x p ( n ) b it s e q u e n c e b e fo r e r e a c h in g th e fi r s t 0 , a n d le t i b e th e n u m b e r o f 1 s c o u n te d . 2 . G e t th e k + i b its fo llo w in g th e 0 id e n tifi e d in s te p 1 a n d le t d b e its d e c im a l e q u iv a le n t. 1 5 1 70 60 50 40 m Equation (8.2-3) 30 20 10 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ρ F ig u r e P 8 .1 6 3 . T h e d e c o d e d in te g e r is th e n i − 1 d + 2 j + k . j = 0 F o r e x a m p l e , t o d e c o d e t h e fi r s t G e2 x p ( n ) c o d e i n t h e b i t s t r e a m 1 0 1 1 1 0 1 1 . . . , l e t i = 1 , th e n u m b e r o f 1 s in a le ft- to - r ig h t s c a n o f th e b it s tr e a m b e fo r e fi n d in g th e fi r s t 0 . G e t th e 2 + 1 = 3 b its fo llo w in g th e 0 , th a t is , 1 1 1 s o d = 7 . T h e d e c o d e d in te g e r is th e n 1 − 1 7 + 2 j + 2 = 7 + 2 2 = 1 1 . j = 0 R e p e a t th e p r o c e s s fo r th e n e x t c o d e w o rd , w h ic h b e g in s w ith th e b it s e q u e n c e 0 1 1 ... Problem 8.16 T h e g r a p h s h o w n in F ig u r e P 8 .1 6 w a s o b t a in e d u s in g M A T L A B . N o t e t h a t t h e fu n c tio n is n o t d e fi n e d fo r ρ = f 0 ,1 g . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 5 2 Encoding sequence b b a c 0.156 0.156 d d d d d 0.3 0.5 1 d 0.15536 c c c c c 0.1544 a 0 0.14 b a a a 0.1 b b b b a 0.1528 0.14 F ig u r e P 8 .1 7 Problem 8.17 F ig u r e P 8 .1 7 s h o w s t h e a r it h m e t ic c o d in g p r o c e s s a s d e s c r ib e d in S e c t io n 8 .2 .3 . A n y v a lu e in t h e in t e r v a l [0 .1 5 4 4 , 0 .1 5 5 3 6 ) a t t h e r ig h t s id e o f t h e fi g u r e c a n b e u s e d t o c o d e t h e s e q u e n c e . F o r e x a m p le , t h e v a lu e 0 .1 5 5 . Problem 8.18 T h e a r ith m e tic d e c o d in g p r o c e s s is th e re v e r s e o f th e e n c o d in g p b y d iv id in g th e [0 , 1 ) in te r v a l a c c o rd in g to th e s y m b o l p r o b a b s h o w n in T a b le P 8 .1 8 . T h e d e c o d e r im m e d ia t e ly k n o w s t h e m b e g in s w ith a n “ e ”, s in c e th e c o d e d m e s s a g e lie s in th e in te r v a l m a k e s it c le a r th a t th e s e c o n d s y m b o l is a n “ a ”, w h ic h n a r r o w s [0 .2 , 0 .2 6 ) . T o fu r t h e r s e e t h is , d iv id e t h e in t e r v a l [0 .2 , 0 .5 ) a c c o r d b o l p r o b a b ilitie s . P r o c e e d in g lik e th is , w h ic h is th e s a m e p r o c e d u t h e m e s s a g e , w e g e t “ e a ii!” . S y m b o l a e i o u ! T a b le P 8 .1 8 P r o b a b ility 0 .2 0 .3 0 .1 0 .2 0 .1 0 .1 [0 [0 [0 [0 [0 [0 R a .0 .2 .5 .6 .8 .9 n g , 0 , 0 , 0 , 0 , 0 , 1 e .2 .5 .6 .8 .9 .0 ) ) ) ) ) ) ro c e d u re . S ta r t ilitie s . T h is is e s s a g e 0 .2 3 3 5 5 [0 .2 , 0 .5 ) . T h is th e in te r v a l to in g to th e s y m re u s e d to c o d e 1 5 3 Problem 8.19 A s y o c a T a s u m e u a s s u s e , th e b le P 8 th a t th e fi rs t 2 5 6 c o d m e 7 - b it A S C II, th e A S C II ” a ” c o rre s p o n .1 9 . T h e e n c o d e d o u e s in th e s ta r tin g d ic tio n a r y a re th e A S C II c o d e s . If fi r s t 1 2 8 lo c a tio n s a r e a ll th a t a r e n e e d e d . In e ith e r d s to lo c a tio n 9 7 . T h e c o d in g p r o c e e d s a s s h o w n in tp u t is 9 7 2 5 6 2 5 7 2 5 8 9 7 . R e c o g n iz e d a a a a a a a a a a a a a a a a a a a a a C h a ra c te r a a a a a a a a a a a T a b le P 8 .1 9 O u tp u t D ic t. A d d re s s D ic t. E n tr y 9 7 2 5 6 a a 2 5 6 2 5 7 a a a 2 5 7 2 5 8 a a a a 2 5 8 9 7 2 5 9 a a a a a Problem 8.20 T h e in p u t t o t h e L Z W d e c o d in g a lg o r it h m in E x a m p le 8 .7 is 3 9 3 9 1 2 6 1 2 6 2 5 6 2 5 8 2 6 0 2 5 9 2 5 7 1 2 6 T h e s ta r tin g d ic tio n a r y , to b e c o n s is te n t w ith th e c o d in g its e lf, c lo c a tio n s – w ith th e fi r s t 2 5 6 c o r r e s p o n d in g to in te n s ity v a lu e s 0 t T h e d e c o d in g a lg o r ith m b e g in s b y g e ttin g th e fi r s t e n c o d e d v a lu e , o u c o r r e s p o n d in g v a lu e fr o m th e d ic tio n a r y , a n d s e ttin g th e “ r e c o g n iz e to th e fi r s t v a lu e . F o r e a c h a d d itio n a l e n c o d e d v a lu e , w e (1 ) o u tp u n a r y e n tr y fo r th e p ix e l v a lu e (s ), (2 ) a d d a n e w d ic tio n a r y e n tr y w h is th e “ r e c o g n iz e d s e q u e n c e ” p lu s th e fi r s t e le m e n t o f th e e n c o d e d p r o c e s s e d , a n d (3 ) s e t th e “ re c o g n iz e d s e q u e n c e ” to th e e n c o d e d p r o c e s s e d . F o r t h e e n c o d e d o u t p u t in E x a m p le 8 .1 2 , t h e s e q u e n c e o is a s s h o w n in T a b le P 8 .2 0 . N o te , fo r e x a m p le , in r o w 5 o f th e ta b le th a t th e n e w d ic tio n a r y c a tio n 2 5 9 is 1 2 6 - 3 9 , th e c o n c a te n a tio n o f th e c u r r e n tly r e c o g n iz e o n ta in s 5 1 2 h ro u g h 2 5 5 . tp u ttin g th e d s e q u e n c e ” t th e d ic tio o s e c o n te n t v a lu e b e in g v a lu e b e in g f o p e r a tio n s e n tr y fo r lo d s e q u e n c e , C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 5 4 1 2 6 , a n d th e fi r s t e le m e n t o f th e e n c o d e d v a lu e b e in g p r o c e s s e d – th e 3 9 fr o m th e 3 9 - 3 9 e n tr y in d ic tio n a r y lo c a tio n 2 5 6 . T h e o u tp u t is th e n r e a d fr o m th e th ir d c o lu m n o f th e ta b le to y ie ld 3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9 1 2 6 1 2 6 1 2 6 1 2 6 1 2 6 1 2 6 1 2 6 1 2 6 w h e re it is a s s u m e d th a t th e d e c o d e r k n o w s o r is g iv e n th e s iz e o f th e im a g e th a t w a s re c e iv e d . N o te th a t th e d ic tio n a r y is g e n e r a te d a s th e d e c o d in g is c a r r ie d o u t. R e c o g n iz e d 3 9 3 9 1 2 6 1 2 6 2 5 6 2 5 8 2 6 0 2 5 9 2 5 7 E n c o d e d V a lu e 3 9 3 9 1 2 6 1 2 6 2 5 6 2 5 8 2 6 0 2 5 9 2 5 7 1 2 6 T a b le P 8 .2 0 P ix e ls 3 9 3 9 1 2 6 1 2 6 3 9 -3 9 1 2 6 -1 2 6 3 9 -3 9 -1 2 6 1 2 6 -3 9 3 9 -1 2 6 1 2 6 D ic t. A d d re s s D ic t. E n tr y 2 5 6 2 5 7 2 5 8 2 5 9 2 6 0 2 6 1 2 6 2 2 6 3 2 6 4 3 9 -3 9 3 9 -1 2 6 1 2 6 -1 2 6 1 2 6 -3 9 3 9 -3 9 -1 2 6 1 2 6 -1 2 6 -3 9 3 9 -3 9 -1 2 6 -1 2 6 1 2 6 -3 9 -3 9 3 9 -1 2 6 -1 2 6 Problem 8.21 U s in g t h e B M P s p e c ifi c a t io n g iv e n in E x a m p le 8 .8 o f S e c t io n 8 .2 .5 , t h e fi r s t t w o b y te s in d ic a te th a t th e u n c o m p r e s s e d d a ta b e g in s w ith a r u n o f 4 s w ith le n g th 3 . In a s im ila r m a n n e r, th e s e c o n d tw o b y te s c a ll fo r a r u n o f 6 s w ith le n g th 5 . T h e fi rs t fo u r b y te s o f th e B M P e n c o d e d s e q u e n c e a re e n c o d e d m o d e . B e c a u s e th e 5 th b y te is 0 a n d th e 6 th b y te is 3 , a b s o lu te m o d e is e n te r e d a n d th e n e x t th r e e v a lu e s a r e ta k e n a s u n c o m p r e s s e d d a ta . B e c a u s e th e to ta l n u m b e r o f b y te s in a b s o lu te m o d e m u s t b e a lig n e d o n a 1 6 - b it w o r d b o u n d a r y , th e 0 in th e 1 0 th b y te o f th e e n c o d e d s e q u e n c e is p a d d in g a n d s h o u ld b e ig n o r e d . T h e fi n a l tw o b y te s s p e c ify a n e n c o d e d m o d e r u n o f 4 7 s w ith le n g th 2 . T h u s , th e c o m p le te u n c o m p re s s e d s e q u e n c e is { 4 , 4 , 4 , 6 , 6 , 6 , 6 , 6 , 1 0 3 , 1 2 5 , 6 7 , 4 7 , 4 7 } . 1 5 5 Problem 8.22 ( a ) U s in g E q . ( 8 .2 - 9 ) , fo r m T a b le P 8 .2 2 . B in 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 a r y 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 G ra y 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 T a b le P 8 .2 2 C o d e B in 0 0 1 0 1 0 0 1 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 0 a r y 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 G ra y 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 C 0 0 1 1 1 1 0 0 o d e 0 1 1 0 0 1 1 0 ( b ) T h e p r o c e d u r e is to w o r k fr o m th e m o s t s ig n ifi c a n t b it to th e le a s t s ig n ifi c a n t b it u s in g th e e q u a tio n s : a a = g m = g i ⊕ a m − 1 − 1 i i + 1 0 ≤ i ≤ m − 2 . T h e d e c o d e d b in a r y v a lu e is th u s 0 1 0 1 1 0 0 1 1 1 0 1 0 . Problem 8.23 F o llo w in g th e p r o c e d u r e in th e fl o w c h a r t o f F ig . 8 .1 4 in th e b o o k , th e p r o p e r c o d e is 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 1 w h e r e th e s p a c e s h a v e b e e n in s e r te d fo r r e a d a b ility a lo n e . T h e c o d in g m o d e s e q u e n c e is p a s s , v e r tic a l (1 le ft), v e r tic a l (d ir e c tly b e lo w ), h o r iz o n ta l (d is ta n c e s 3 a n d 4 ), a n d p a s s . Problem 8.24 ( a ) - ( b ) F o llo w in g th e p r o c e d u r e o u t lin e d in S e c t io n 8 .2 .8 , w e o b ta in t h e r e s u lt s s h o w n in T a b le P 8 .2 4 . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 5 6 D C C o e ffi c ie n t D iffe re n c e -7 -6 -5 -4 4 5 6 7 T a b le P 8 .2 4 T w o ’s C o m p l e 1 ...1 0 1 ...1 0 1 ...1 0 1 ...1 1 0 ...0 1 0 ...0 1 0 ...0 1 0 ...0 1 m e n t V a lu e 0 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 C o 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 d e 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 Problem 8.25 In g e n e r a l, th e n u m b e r o f M A D c o m p u ta tio n s fo r s in g le - p ix e l p r e c is io n a n d d is p la c e m e n ts ± d x a n d ± d y is (2 d x + 1 ) 2 d y + 1 . W ith b o th d x a n d d y e q u a l to ± 8 , th e n u m b e r o f M A D c o m p u ta tio n s fo r th is p r o b le m is 1 7 2 o r 2 8 9 p e r m a c r o b lo c k . W ith 8 × 8 m a c r o b lo c k s , e a c h M A D c o m p u ta tio n in v o lv e s 8 2 (3 ) = 1 9 2 o p e r a tio n s (6 4 s u b tr a c tio n s , a b s o lu te v a lu e s , a n d a d d itio n s ). S o , th e to ta l n u m b e r o f m a th o p e r a tio n s fo r 8 × 8 m a c r o b lo c k s a n d s in g le p ix e l d is p la c e m e n ts d x = d y = 8 is 2 8 9 × 1 9 2 = 5 5 ,4 8 8 . F o r 14 p i x e l p r e c i s i o n , t h e n u m b e r o f M A D c o m p u t a t i o n s i s m u l t i p l i e d b y 1 6 , y ie ld in g 1 6 × 2 8 9 = 4 , 6 2 4 M A D c o m p u ta tio n s p e r m a c r o b lo c k . T h e n u m b e r o f m a th o p e r a tio n s fo r e a c h M A D c o m p u ta tio n is in c re a s e d fr o m 1 9 2 to 1 9 2 + 8 2 (4 ) = 4 4 8 , w h e r e th e a d d itio n a l o p e r a tio n s a r e fo r b ilin e a r in te r p o la tio n . S o , t h e t o t a l n u m b e r o f m a t h o p e r a t i o n s f o r 8 × 8 m a c r o b l o c k s a n d 14 p i x e l d i s p la c e m e n ts d x = d y = 8 (u s in g b ilin e a r in te r p o la tio n ) is 4 6 2 4 × 4 4 8 = 2 , 0 7 1 , 5 5 2 . Problem 8.26 T h e re a re s e v e r a l w a y s in w h ic h b a c k w a rd m o tio n - c o m p e n s a te d p re d ic tio n c a n h e lp : 1 . It p r o v id e s a m e a n s o f p r e d ic tin g u n c o v e r e d b a c k g r o u n d w h e n a n o b je c t is m o v in g . 2 . It p r o v id e s a m e a n s o f p r e d ic tin g p ix e ls o n th e e d g e s o f fr a m e s w h e n th e c a m e r a is p a n n in g . 3 . B a c k w a rd a n d fo r w a rd p re d ic tio n c a n a v e r a g e th e n o is e in tw o re fe re n c e fr a m e s to y ie ld a m o r e a c c u r a te p r e d ic tio n . 1 5 7 Encoded Macroblock Variable Length Decoder Encoded Motion Vector Variable Length Decoder Inverse Quantizer Inverse Mapper (e.g., DCT-1) Decoded Image Macroblock + Motion Estimator and Compensator F ig u r e P 8 .2 7 Problem 8.27 T h e a p p r o p r ia t e M P E G d e c o d e r is s h o w n in F ig . P 8 .2 7 . Problem 8.28 (a ) S u b s titu tin g ρ o f R a n d r , w e g e t = 0 in t o E q . ( 8 .2 - 4 9 ) a n d e v a lu a t in g it t o fo r m t h e e le m e n t s h ρ 1 2 R = σ ρ r = σ 1 ρ 2 ρ . 2 (b ) F ir s t fo r m th e in v e r s e o f R , R − 1 1 = σ 2 − ρ 1 1 − ρ 2 − ρ . 1 T h e n , p e r fo r m t h e m a t r ix m u lt ip lic a t io n o f E q . ( 8 .2 - 4 5 ) : − 1 α = R T h u s , α 1 = ρ a n d α 2 r = σ σ 2 2 ρ 1 − ρ 2 1 − ρ 0 2 = ρ 0 . = 0 . ( c ) T h e v a r ia n c e is c o m p u t e d u s in g E q . ( 8 .2 - 4 8 ) : σ e 2 = σ 2 − α T r = ρ 0 ρ ρ 2 = σ 2 1 − ρ 2 . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 5 8 Problem 8.29 T h e d e r iv a tio n p r o c e e d s b y s u b s titu tin g th e u n ifo r m p r o b a b ility fu n c tio n in to E q s . ( 8 .2 - 5 7 ) - ( 8 .2 - 5 9 ) a n d s o lv in g t h e r e s u lt in g s im u lt a n e o u s e q u a t io n s w it h L = 4 . E q u a t io n ( 8 .2 - 5 8 ) y ie ld s 0 = 0 1 = s s s 1 (t 2 = 1 . 2 + t 2 ) 1 S u b s titu tin g th e s e v a lu e s in to th e in te g r a ls d e fi n e d b y E q . (8 .2 - 5 7 ), w e g e t tw o e q u a tio n s . T h e fi r s t is (a s s u m in g s 1 ≤ A ) s 1 (s − t 1 ) p (s ) d s = 0 s 1 1 (t 1 + t 2 ) 2 2 A 0 1 + t 2 )2 − 4 t 1 (t (t 1 + t 2 ) (t 2 − t 1 s 2 0 (t 1 2 s (s − t 1 ) d s = 1 2 (t 1 + t 2 ) 0 + t 2 ) = 0 − 3 t 1 ) = 0 = 0 s o 1 = − t 2 = 3 t 1 . t t 2 T h e fi r s t o f th e s e r e la tio n s d o e s n o t m a k e s e n s e s in c e b o th t 1 a n d t 2 m u s t b e p o s itiv e . T h e s e c o n d r e la tio n s h ip is a v a lid o n e . T h e s e c o n d in te g r a l y ie ld s (n o tin g th a t s 1 is le s s th a n A s o th e in te g r a l fr o m A to 1 is 0 b y th e d e fi n itio n o f p (s )) s 2 (s − t 2 ) p (s ) d s = 0 s 1 A 1 (s − t 2 ) d s = 2 A 1 2 4 A (t 1 + t 2 ) 2 − 8 A t 2 − (t 1 2 s 2 A − t 2 s + t 2 )2 − 4 t 2 (t 1 1 2 (t 1 + t 2 ) + t 2 ) = 0 . = 0 1 5 9 S u b s titu tin g t 2 = 3 t 1 fr o m th e fi r s t in te g r a l s im p lifi c a tio n in to th is r e s u lt, w e g e t 8 t t 1 − 2 − 6 A t 1 A 2 (8 t 2 + A 1 = 1 − 2 A ) 0 0 A = t t = 1 1 2 A = . 4 B a c k s u b s titu tin g th e s e v a lu e s o f t 1 , w e fi n d th e c o r r e s p o n d in g t 2 = 2 = t t 3 A 2 3 A 4 a n d a n d s 1 = A s 1 = A 2 fo r fo r 1 = A 1 = A t t 2 a n d s 1 v a lu e s : 4 2 . B e c a u s e s 1 = A is n o t a r e a l s o lu tio n (th e s e c o n d in te g r a l e q u a tio n w o u ld th e n b e e v a lu a te d fr o m A to A , y ie ld in g 0 o r n o e q u a tio n ), th e s o lu tio n is g iv e n b y th e s e c o n d . T h a t is , s 1 = A2 s 2 = 1 s 0 = 0 A t 1 = 4 t 2 = 3 4A . Problem 8.30 T h e r e a r e m a n y w a y s to a p p r o a c h th is p r o b le m . F o r e x a m p le , JP E G - 2 0 0 0 c o m p r e s s i o n c o u l d b e u s e d . H e r e ’s a n o t h e r a l t e r n a t i v e . B e c a u s e t h e T 1 t r a n s f e r r a t e is 1 .5 4 4 M b it / s e c , a 6 s e c o n d t r a n s fe r w ill p r o v id e (1 .5 4 4 × 1 0 6 )(6 s e c ) = 9 .2 6 4 × 1 0 6 b its o f d a ta . T h e in itia l a p p r o x im a tio n o f th e X - r a y m u s t c o n ta in n o m o re th a n th is n u m b e r o f b its . T h e re q u ire d c o m p re s s io n r a tio is th u s C = 4 0 9 6 × 4 0 9 6 × 1 2 = 2 1 .7 3 9 .2 6 4 × 1 0 6 T h e JP E G tr a n s fo r m c o d in g a p p r o a c h o f S e c tio n c o m p r e s s io n a n d p r o v id e r e a s o n a b ly g o o d r e c o c o d e r, th e X - r a y c a n b e JP E G c o m p re s s e d u s in g a a b o u t a 2 5 :1 c o m p r e s s io n . W h ile it is b e in g t r a n re m o te v ie w in g s ta tio n , th e e n c o d e r c a n d e c o d e id e n tify th e “ d iffe r e n c e s ” b e tw e e n th e r e s u ltin g 8 .2 .8 c a n a c h n s tr u c tio n s . n o r m a liz a tio n s m itte d o v e r t th e c o m p re s s e X -ra y a p p ro x ie v e th is le v e l o f A t th e X -ra y e n a r r a y th a t y ie ld s h e T 1 lin e to th e d JP E G d a ta a n d im a tio n a n d th e C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 6 0 o r ig in a l X - r a y im a g e . S in c e w e w is h to tr a n s m it th e s e “d iffe re n c e s ” o v e r a s p a n o f 1 m in u te w ith re fi n e m e n ts e v e r y 5 - 6 s e c o n d s , th e re c a n b e n o m o re th a n 6 0 6 o r 1 0 re fi n e m e n t n a l X m u s t is m c o ra b e e n ts rre s y a n o b t . If w p o n d d th e a in e d e a s s u m e th s to th e “d if JP E G re c o n s p e r b it (to a C = w tr m “d a t fe r tr u llo 1 2 e n c t w to 6 0 5 1 2 re fi n e c e s” b e d a p p a 6 s e c m e n t e tw e e r o x im o n d a to s a re n o n a tio v e ra m a d e e o f th n , th e n g e tra n a n d e 1 2 th e s fe r th a t b its c o m p tim e e a in re fo c h th s s r e re fi n e e o r ig iio n th a t a c h b it) 4 0 9 6 × 4 0 9 6 × 1 = 1 .8 1 9 .2 6 4 × 1 0 6 h e re , a s b e fo re , th e b o tto m o f th e fr a c tio n is th e n u m b e r o f b its th a t c a n b e a n s m itte d o v e r a T 1 lin e in 6 s e c o n d s . T h u s , th e “ d iffe r e n c e ” d a ta fo r e a c h b it u s t b e c o m p r e s s e d b y a fa c to r ju s t le s s th a n 2 . O n e s im p le w a y to g e n e r a te th e iffe re n c e in fo r m a tio n ” is to X O R th e a c tu a l X - r a y w ith th e re c o n s tr u c te d JP E G a p p r o x im a tio n . T h e r e s u ltin g b in a r y im a g e w ill c o n ta in a 1 in e v e r y b it p o s itio n a t w h ic h th e a p p r o x im a tio n d iffe r s fr o m th e o r ig in a l. If th e X O R r e s u lt is tr a n s m itte d o n e b it a t a tim e b e g in n in g w ith th e M S B a n d e n d in g w ith th e L S B , a n d e a c h b it is c o m p r e s s e d b y a n a v e r a g e fa c t o r o f 1 .8 1 :1 , w e w ill a c h ie v e t h e p e r fo r m a n c e th a t is r e q u ir e d in th e p r o b le m s ta te m e n t. T o a c h ie v e a n a v e r a g e e r r o r fr e e b it - p la n e c o m p r e s s io n o f 1 .8 1 :1 ( s e e S e c t io n 8 .2 .7 ) , t h e X O R d a t a c a n b e G r a y c o d e d , r u n - le n g th c o d e d , a n d fi n a lly v a r ia b le - le n g th c o d e d . A c o n c e p tu a l b lo c k d ia g r a m fo r b o th t h e e n c o d e r a n d d e c o d e r a r e g iv e n in F ig . P 8 .3 0 . N o te th a t th e d e c o d e r c o m p u te s th e b it re fi n e m e n ts b y X O R in g th e d e c o d e d X O R d a ta w ith th e re c o n s tr u c te d JP E G a p p r o x im a tio n . Problem 8.31 T F a o o d e m o n W T fi lte r n d e v e n u tp u t o f s tra te b a n k o u tp u s te p 4 Y 4 th e e m e th ts o f o f th (0 ) = q u iv a le n c e o f th o d , w e s im p ly d th e liftin g a lg o r e a lg o r ith m c a n = Y 2 (0 ) + δ [Y X (0 ) + β [Y 1 3 e liftin e r iv e g ith m o b e w r g b a s e d a p p r o a c h a n d th e tr a d itio n a l e n e r a l e x p re s s io n s fo r o n e o f th e o d d f E q . (8 .2 - 6 2 ). F o r e x a m p le , th e Y (0 ) itte n a s (− 1 ) + Y (− 1 ) + Y 1 3 (1 )] (1 )] + δ [Y 3 (− 1 ) + Y 3 (1 )] 1 6 1 X-ray JPEG Encoder MUX JPEG Decoder Control/ Sequencer Bit Selector MUX 1-bit XOR Gray Coder Bit Selector MUX Compressed Data In Compressed T1 Transmitter Data Out Variable Run-length Length Coder Coder Encoder JPEG Decoder Frame Buffer MUX Control/ Sequencer 12-bit XOR Display Generator X-ray to Display Decoder Zero Pad Variable Run-length Gray and Length Decoder Decoder Position Bit Decoder F ig u r e P 8 .3 0 w h e r e t h e s u b s c r i p t s o n t h e Y ’s h a v e b e e n a d d e d t o i d e n t i f y t h e s t e p o f t h e l i f t in g a lg o r ith m fr o m w h ic h th e v a lu e is g e n e r a te d . C o n tin u in g th is s u b s titu tio n p a t t e r n f r o m e a r l i e r s t e p s o f t h e a l g o r i t h m u n t i l Y 4 ( 0 ) i s a f u n c t i o n o f X ’s o n l y , w e g e t Y (0 ) 1 + 2 α β + 2 α δ + 6 α β γ δ + 2 γ δ = β + 3 β γ δ + δ + β γ δ + α β γ δ + + + X (4 ) X (− 1 ) α β + 4 α β γ δ + α δ + γ δ β γ δ α β γ δ X (2 ) X (3 ) β + 3 β γ δ + δ + + X (1 ) α β + 4 α β γ δ + α δ + γ δ + X (0 ) X (− 3 ) X (− 4 ) . X (− 2 ) C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 6 2 T h u s , w e c a n fo r m t h e lo w p a s s a n a ly s is fi lt e r c o e ffi c ie n t s s h o w n in T a b le P 8 .3 1 1 . C o e ffi c ie ± ± ± ± T a b le P 8 .3 1 - 1 E x p re s s io n α β γ δ / K β γ δ / K α β + 4 α β γ δ + α δ + γ δ / K β + 3 β γ δ + δ / K 1 + 2 α β + 2 α δ + 6 α β γ δ + 2 γ δ / K n t In d e x 4 3 2 1 0 H e re , th e c o e ffi c a n d th e d iv is io n c o e ffi c ie n t v a lu e β , γ , δ , a n d K fr d e r iv a tio n b e g in ie n t e b y K s in c o m th n in g x p re s s io is in a c c o lu m n 3 e te x t in w ith Y 3 n s a o rd a a re to th (1 ) = Y re ta n c e d e te e e x k e n d ire c w ith s te p r m in e d b p re s s io n s (1 ) + γ [Y 1 2 tly fr o m o 6 o f E q . ( y s u b s titu o f c o lu m (0 ) + Y 2 u r 8 .2 tin n 2 V a lu e 0 .0 2 6 7 4 8 7 5 7 - 0 .0 1 6 8 6 4 1 1 8 - 0 .0 7 8 2 2 3 2 6 0 .2 6 6 8 6 4 1 1 0 .6 0 2 9 4 9 0 1 e x p a n s io n o f Y (0 ) -6 2 ). T h e g th e v a lu e s o f α , . A s im ila r (2 )] y ie ld s Y (1 ) α + 3 α β γ + δ = 1 + 2 β γ + X (1 ) α + 3 α β γ + δ + β γ + α β γ + β γ + + α β γ X (0 ) X (2 ) X (3 ) X (4 ) X (− 1 ) X (− 2 ) fr o m w h ic h w e c a n o b ta in th e h ig h p a s s a n a ly s is fi lte r c o e ffi c ie n ts s h o w n in T a b le P 8 .3 1 - 2 C o e ffi c ie n t In d e x -2 -1 0 1 2 3 4 T a b le E x − − − K α − K − K α − − P 8 .3 1 - 2 p re s s io n K α β γ K β γ + 3 α β γ + δ 1 + 2 β γ + 3 α β γ + δ K β γ K α β γ -0 0 0 -1 0 0 -0 .0 .0 .5 .1 .5 .0 .0 V a lu 9 1 2 7 5 7 5 4 9 1 2 7 1 5 0 8 9 1 2 7 5 7 5 4 9 1 2 7 e 1 7 3 5 1 7 7 0 1 7 3 5 1 7 6 2 2 5 6 6 5 3 6 6 2 5 6 2 1 6 3 Problem 8.32 F r o m E q . ( 8 .6 - 5 ) a n d t h e p r o b le m s t a t e m e n t , w e g e t t h a t μ ε = μ 0 = 8 = ε 0 + 2 − 2 = ε 2 L L 2 L L = 8 . 0 S u b s t it u t in g t h e s e v a lu e s in t o E q . ( 8 .2 - 6 4 ) , w e fi n d t h a t fo r t h e 2 L L s u b b a n d Δ 2 L L (8 + 0 )− 8 = 2 H e re , w e h a v e a s s u m e d a n 8 -b 6 5 ) , ( 8 .2 - 6 4 ) , a n d F ig . 8 .4 8 ( t o g e t Δ 2 H H = 2 (8 + 2 Δ 2H L = Δ 2 L H Δ 1 H H = 2 (8 + 2 Δ 1H L = Δ 1 L H 8 1 + 2 = 1 .0 0 3 9 0 6 2 5 . 1 1 it im a g e s o t h a t R b = 8 . L ik e w is e , u s in g E q s . ( 8 .2 fi n d th e a n a ly s is g a in b its fo r e a c h s u b b a n d ), w e )− 8 = 2 )− 8 = 2 8 1 + 1 1 2 (8 + 1 )− 8 1 + 8 2 1 1 (8 + 1 )− 8 = 4 .0 1 5 6 2 5 1 + 2 81 1 = 2 . 0 0 7 8 1 2 5 = 4 .0 1 5 6 2 5 1 + 2 81 1 = 2 . 0 0 7 8 1 2 5 . Problem 8.33 O n e a p p r o a c h is t o im p le m e n t E q . ( 8 .3 - 1 ) u s in g F o u r ie r t r a n s fo r m s . U s in g t h e p r o p e r tie s o f th e F o u r ie r tr a n s fo r m : f = f (1 − α ) f + α w = w F = = w w = = = S o , v is ib le w a te a s c a le d (b y α ) 1 − α ) o f a n im s u m . T h is is o s p a tia l d o m a in (1 − α ) f + α w (1 − α ) f (1 − α ) = r m a r k in g in th e tr a n s fo r v e r s i o n o f a w a t e r m a r k ’s a g e ’s F o u r i e r t r a n s f o r m b v io u s ly m o r e c o m p u ta a p p r o a c h [E q . ( 8 .3 - 1 ) ]. m d o F o u r a n d tio n a f m a ie r ta k lly + = [α w ] + α = [w ] in tr in d c a n a n s f g th e m a b e a c c o m o r m to a s e in v e r s e n d in g th a p lis c a le tra n n th h e d b y a d v e r s io s fo r m o e e q u iv d d n ( f t a le in g b y h e n t Problem 8.34 A v a r ie ty o f m e th o d s fo r in s e r tin g in v is ib le w a te r m a r k s in to th e D F T c o e ffi c ie n ts o f a n im a g e h a v e b e e n r e p o r te d in th e lite r a tu r e . H e r e is a s im p lifi e d o u tlin e o f o n e in w h ic h w a te r m a r k in s e r tio n is d o n e a s fo llo w s : C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 6 4 II I III IV F ig u r e P 8 .3 4 1 . C r e a te a w a te r m a r k b y g e n e r a tin g a P - e le m e n t p s e u d o - r a n d o m s e q u e n c e o f n u m b e r s , ! 1 , ! 2 , ..., ! P , t a k e n fr o m a G a u s s ia n d is t r ib u t io n w it h z e r o m e a n a n d u n it v a r ia n c e . 2 . C o m p u te th e D F T o f th e im a g e to b e w a te r m a r k e d . W e a s s u m e th a t th e tr a n s fo r m h a s n o t b e e n c e n te r e d b y p r e - m u ltip ly in g th e im a g e b y (− 1 )x + y . 3 . C h o m id c ie n (th e o s e P2 c o e d le fr e q u e ts in th e o lo w fr e q u ffi c ie n n c y ra rd e r s h e n c y c ts fro n g e . o w n o e ffi c m T in ie e a h is F ig n ts c h o f th e is e a s ily . P 8 .3 4 a ) in e a c h fo u r q u a d r a n ts o f th e D F T in th e a c c o m p lis h e d b y c h o o s in g c o e ffi n d s k ip p in g th e fi r s t K c o e ffi c ie n ts q u a d ra n t. 4 . In s e r t th e fi r s t h a lf o f th e w a te r m a r k in to th e c h o s e n D F T c o e ffi c ie n ts , c f o r 1 ≤ i ≤ P2 , i n q u a d r a n t s I a n d I I I o f t h e D F T u s i n g c 5 . In o f c e a d s e r t th e q u a d ra s s m a in d itio n , s e c o n d n ts II a n ta in s th c o n s ta n h a lf o d IV o e s y m t α d e f th e f th e m e tr te r m i 0 = c w a te D F T y o f t in e s t i (1 + α ! i) r m in h e h e a r k in to th e c a s im ila r m a n tra n s fo r m o f s tre n g th o f th h o s n e r a re e in e n D . N o t a l- v a s e r te F T c o e ffi c e th a t th is lu e d im a g d w a te r m ie n p r e . a rk ts o In . 6 . C o m p u te th e in v e r s e D F T w ith th e w a te r m a r k e d c o e ffi c ie n ts r e p la c in g th e u n m a r k e d c o e ffi c ie n ts . i 1 6 5 W a te r m a r k e x tr a c tio n is p e r fo r m e d a s fo llo w s : 1 . L o c a te th e D F T c o e ffi c ie n ts c o n ta in in g th e w a te r m a r k b y fo llo w in g th e in s e r tio n p r o c e s s in th e e m b e d d in g a lg o r ith m . 2 . C o m p u t e t h e w a t e r m a r k !^ 1 , !^ 2 , . . . , !^ !^ i ^c = u s in g P i − c i 3 . C o m p u t e t h e c o r r e l a t i o n b e t w e e n ! a n d !^ a n d c o m p a r e t o a p r e - d e t e r m i n e d th r e s h o ld T to d e te r m in e if th e m a r k is p r e s e n t. Problem 8.35 T h e r e a r e m a n y w a y s to w a te r m a r k a n im a g e u s in g D W T s . A s im p le e x a m p le th a t h a s b e e n r e p o r te d in th e lite r a tu r e u s e s th e fo llo w in g w a te r m a r k in s e r tio n te c h n iq u e : 1 . C r e a te a w a te r m a r k b y g e n e r a tin g a 1 0 0 0 e le m e n t p s e u d o - r a n d o m s e q u e n c e o f n u m b e r s , ! 1 , ! 2 , ..., ! 1 0 0 0 , t a k e n fr o m a G a u s s ia n d is t r ib u t io n w it h z e r o m e a n a n d u n it v a r ia n c e . 2 . C o m p u te th L s o th a t th e 1 0 0 0 . R e c a ll w h e r e J = lo a lg o r ith m , w e L + 1 - le v e n u m b e r o f fro m c h a p te g 2 N a n d th e w ill c a ll th l D W T o f t a p p r o x im a r 7 th a t th e e im a g e is e s e le c te d h e im a g tio n c o e s e c o e ffi o f s iz e N c o e ffi c ie e to b e w ffi c ie n ts c ie n ts w e × N . F o n ts c i (i ) a te r m a t le v e re d e n r th e p fo r 1 ≤ a rk e d . C h o o l J − L is a b o o te d W ' ( J − u rp o s e s o f th i ≤ 1 0 0 0 . s e u t L ,m ,n ) is 3 . C o m p u te th e a v e r a g e o f th e s e le c te d a p p r o x im a tio n c o e ffi c ie n ts c . 4 . E m b e d w a te r m a r k ! in to th e s e le c te d a p p r o x im a tio n c o e ffi c ie n ts u s in g c i 0 = c + [c i − c ] (1 + α ! i) w h e re α d e te r m in e s th e “ in te n s ity ” o f th e w a te r m a r k . 5 . C o m p u te th e w a te r m a r k e d im a g e b y ta k in g th e in v e r s e D W T w ith th e m a r k e d a p p r o x im a tio n c o e ffi c ie n ts r e p la c in g th e o r ig in a l u n m a r k e d c o e ffi c ie n ts . W a te r m a r k d e te c tio n is a c c o m p lis h e d a s fo llo w s : 1 . C o m p u te th e L + 1 - le v e l D W T o f th e im a g e in q u e s tio n . C H A P T E R 8 . P R O B L E M S O L U T IO N S 1 6 6 2 . C o m p u t e t h e a v e r a g e c ^¯ a n d v a r i a n c e σ ( c ^ ) o f t h e l e v e l J − L a p p r o x i m a t i o n c o e f fi c i e n t s , ^c 1 , ^c 2 , . . . , ^c 1 0 0 0 . 3 . E x t r a c t w a t e r m a r k !^ u s i n g ^c !^ i = i − σ (c ) σ ( c^ ) ^c ¯ c i − − (c i − ¯c ) ¯c 4 . C o m p u t e t h e c o r r e l a t i o n b e t w e e n ! a n d !^ a n d c o m p a r e t o a p r e - d e t e r m i n e d th r e s h o ld T to d e te r m in e if th e m a r k is p r e s e n t. Chapter 9 Problem Solutions Problem 9.1 ( a ) C o n v e r tin g a r e c ta n g u la r to a h e x a g o n a l g r id b a s ic a lly r e q u ir e s th a t e v e n a n d o d d lin e s b e d is p la c e d h o r iz o n ta lly w ith r e s p e c t to e a c h o th e r b y o n e - h a lf th e h o r iz o n ta l d is ta n c e b e tw e e n a d ja c e n t p ix e ls (s e e th e fi g u r e in th e p r o b le m s ta te m e n t). B e c a u s e in a r e c ta n g u la r g r id th e r e a r e n o p ix e l v a lu e s d e fi n e d a t th e n e w lo c a tio n s , a r u le m u s t b e s p e c ifi e d fo r th e ir c r e a tio n . A s im p le a p p r o a c h is to d o u b le th e im a g e r e s o lu tio n in b o th d im e n s io n s b y in te r p o la tio n (s e e S e c t io n 2 .4 .4 ) . T h e n , t h e a p p r o p r ia t e 6 - c o n n e c t e d p o in t s a r e p ic k e d o u t o f t h e e x p a n d e d a r r a y . T h e r e s o lu tio n o f th e n e w im a g e w ill b e th e s a m e a s th e o r ig in a l ( b u t t h e fo r m e r w ill b e s lig h t ly b lu r r e d d u e t o in t e r p o la t io n ) . F ig u r e P 9 .1 ( a ) illu s tr a te s th is a p p r o a c h . T h e b la c k p o in ts a r e th e o r ig in a l p ix e ls a n d th e w h ite p o in ts a r e th e n e w p o in ts c r e a te d b y in te r p o la tio n . T h e s q u a r e s a r e th e im a g e p o in ts p ic k e d fo r th e h e x a g o n a l g r id a r r a n g e m e n t. (b ) R o ta tio n s in a 6 - n e ig h b o r a r r a n g e m e n t a re in v a r ia n t in 6 0 ◦ in c re m e n ts . ( c ) Y e s . A m b ig u itie s a r is e w h e n th e r e is m o r e th a n o n e p a th th a t c a n b e fo llo w e d fr o m o n e 6 - c o n n e c t e d p ix e l t o a n o t h e r. F ig u r e P 9 .1 ( b ) s h o w s a n e x a m p le , in w h ic h th e 6 - c o n n e c te d p o in ts o f in te r e s t a r e in b la c k . Problem 9.2 (a ) W ith re fe re n c e to th e d is c u s s io n in S e c tio n a v o id m u ltip le p a th s th a t a r e in h e r e n t in 8 - c o n n c o n n e c te d b o u n d a r ie s , th e s e m u ltip le p a th s m a s ic p a t t e r n s s h o w n in F ig . P 9 .2 ( a ) . T h e s o lu t io n o r- m is s tr a n s fo r m to d e te c t th e p a tte r n s a n d th 0 , th u s e lim in a tin g th e m u ltip le p a th s . A b a s ic s 1 6 7 2 .5 .2 e c tiv n ife s to th e n to e q u e , m ity . t th e p c h n c e - c o n n e c tiv ity is u s e d In o n e - p ix e l- th ic k , fu e m s e lv e s in th e fo u r b r o b le m is to u s e th e h a n g e th e c e n te r p ix e l o f m o r p h o lo g ic a l s te to lly a itto p s C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 6 8 (a) (b) F ig u r e P 9 .1 to a c c o m p lis h th is is a s fo llo w s : 1 = A 1 = A \ X 2 = Y 1 2 = Y 1 3 = Y 2 3 = Y 2 4 = Y 3 4 = Y 3 X Y X Y X Y X Y 1 B c 1 2 B c \ X 2 3 B c \ X 3 4 B \ X c 4 w h e re A is th e in p u t im a g e c o n ta in in g th e b o u n d a r y . ( b ) O n ly o n e p a s s is r e q u ir e d . A p p lic a tio n o f th e h it- o r - m is s tr a n s fo r m u s in g a g iv e n B i fi n d s a ll in s ta n c e s o f o c c u r r e n c e o f th e p a tte r n d e s c r ib e d b y th a t s tr u c tu r in g e le m e n t. (c ) T h e o rd e r d o e s m a tte r. P 9 .2 (b ), a n d a s s u m e th a t w p o in t a w ill b e d e le te d a n s tr u c tu r in g e le m e n ts . If, o d e le te d a n d p o in t a w ill r e c e p ta b le ) m - p a th s . F o r e e a re d p o n th e m a in x a tr in o m p a v e t b th e . T h u le , c o n lin g fr o w ill r e r h a n d s , w e w s id m m a , B o u e r th e s e q u e n c e o f p o le ft to r ig h t. If B 1 is a p in a fte r a p p lic a tio n o 3 is a p p lie d fi r s t , p o in ld e n d u p w ith d iffe r e in ts in F p lie d fi r f a ll o th t b w ill n t (b u t a ig . s t, e r b e c - 1 6 9 (b) F ig u r e P 9 .2 Problem 9.3 S e e F ig . P 9 .3 . K e e p in m in d t h a t e r o s io n is t h e s e t fo r m e d fr o m t h e lo c a t io n s o f th e o r ig in o f th e s tr u c tu r in g e le m e n t, s u c h th a t th e s tr u c tu r in g e le m e n t is c o n ta in e d w ith in th e s e t b e in g e r o d e d . Problem 9.4 ( a ) E r o s io n is s e t in te r s e c tio n . T h e in te r s e c tio n o f tw o c o n v e x s e ts is c o n v e x a ls o . ( b o o b ) S e la c k u s s e f d ila e F ig . P 9 .4 ( a ) . K d o ts . T h e lin e s a ts w o u ld b e , th e tio n in th is c a s e e e p in m re s h o w n y a re n o t is n o t c o in d fo r p a r n v e th a t th e d c o n v e n ie t o f th e s e x b e c a u s e ig ita l s e ts n c e in v is u ts b e in g c o th e c e n te in q u e s tio n a re a liz in g w h a t th n s id e re d h e re . r p o in t is n o t in th e c T h th e la r g e r o n tin u e r e s u lt e s e t. ( c ) S e e F ig . P 9 .4 ( b ) . H e r e , w e s e e t h a t t h e lo w e r r ig h t p o in t is n o t c o n n e c t e d t o th e o th e rs . ( d ) S e e F ig . 9 .4 ( c ) . T h e t w o in n e r p o in t s a r e n o t in t h e s e t . Problem 9.5 R e fe r t o F ig . P 9 .5 . T h e c e n t e r o f e a c h s t r u c t u r in g e le m e n t is s h o w n a s a b la c k d o t. ( a ) T h is s o lu tio n w a s o b ta in e d b y e r o d in g th e o r ig in a l s e t (s h o w n d a s h e d ) w ith th e s tr u c tu r in g e le m e n t s h o w n (n o te th a t th e o r ig in is a t th e b o tto m , r ig h t). ( b ) T h is s o lu tio n w a s o b ta in e d b y e r o d in g th e o r ig in a l s e t w ith th e ta ll r e c ta n g u la r s tr u c tu r in g e le m e n t s h o w n . C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 7 0 F ig u r e P 9 .3 (a) (b) (c) F ig u r e P 9 .4 ( c ) T h is s o lu tio v e r tic a l lin e s u s is s lig h tly ta lle r d ila te d w ith th e n w in g th a c ir a s th n c u o b ta in e e re c ta n th e c e n t la r s tr u c d g u e r tu b y fi la r s s e c t r in g rs t tr u io n e le e c t o m r o d in g th e im a g e s h o w n d o w n to tw o u r in g e le m e n t (n o te th a t th is e le m e n ts f th e “ U ” fi g u r e ). T h is r e s u lt w a s th e n e n t. ( d ) T h is s o lu tio n w a s o b ta in e d b y fi r s t d ila tin g th e o r ig in a l s e t w ith th e la r g e d is k s h o w n . T h e d ila te d im a g e w a s e r o d e d w ith a d is k w h o s e d ia m e te r w a s e q u a l to o n e - h a lf th e d ia m e te r o f th e d is k u s e d fo r d ila tio n . Problem 9.6 T h e s o lu t io n s t o ( a ) t h r o u g h ( d ) a r e s h o w n fr o m t o p t o b o t t o m in F ig . P 9 .6 . Problem 9.7 ( a ) T h e d ila te d im a g e w ill g r o w w ith o u t b o u n d . ( b ) A o n e - e le m e n t s e t ( i.e ., a o n e - p ix e l im a g e ) . 1 7 1 (a) (b) (c) (d) F ig u r e P 9 .5 Problem 9.8 ( a ) T h e im a g e w ill e r o d e to o n e e le m e n t. ( b ) T h e s m a lle s t s e t th a t c o n ta in s th e s tr u c tu r in g e le m e n t. Problem 9.9 T h e p r o o f, w h ic h c o n s is ts o f s h o w in g th a t th e e x p re s s io n 3 x 2 Z fo llo w m e n ts (B )x ⊆ A , o r x 2 jx + b 2 A , fo r e v e r y b 2 B s d ir e c tly fr o m o f th e fo r m x A . C o n v e r s e ly + b 2 A fo r e v th + b , (B e r y e d e fo r )x ⊆ b 2 4 ≡ 3 x 2 Z 2 j(B ) x ⊆ A 4 fi n itio n o f tr a n s la tio n b e c a u s e th e s e t ( B )x h a s e le b 2 B . T h a t is , x + b 2 A fo r e v e r y b 2 B im p lie s th a t A im p lie s th a t a ll e le m e n ts o f ( B )x a r e c o n ta in e d in B . Problem 9.10 (a ) L e t x 2 A B . T h e n , fr o m th e d e fi n itio n o f e r o s io n g iv e n in th e p r o b le m s ta te m e n t, fo r e v e r y b 2 B , x + b 2 A . B u t, x + b 2 A im p lie s th a t x 2 (A )− b . T h u s , C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 7 2 F ig u r e P 9 .6 < fo r e v e r y b 2 B , x 2 (A )− b , w h ic h im p lie s th a t x 2 (A )− b . S u p p o s e n o w th a t b 2 B < x 2 (A )− b . T h e n , fo r e v e r y b 2 B , x 2 (A )− b . T h u s , fo r e v e r y b 2 B , x + b 2 A b 2 B w h ic h , fr o m th e d e fi n itio n o f e r o s io n , m e a n s th a t x 2 A (b ) S u p p o s e th a t x 2 A x + b 2 (B )x ⊆ A a ll e le m ( a ) , x <+ ( x 2 b 2 B A . B , s o e n ts b 2 A )− b u t, a th a t o f ( A im . s s h x 2 B )x p lie o w n A B a re c s th a B in P = o n t t x = < b 2 B (A ) − b B . . T h e n , fo r e v e r y b r o b le m 9 .9 , x 2 Z 2 j(B )x a in e d in A , 2 (A )− b . T h x + b 2 A fo r ⊆ A . S im ila o r x + b 2 A u s , if fo r e v e r e v e r ly , fo r y b r y (B e v 2 2 B , x 2 (A ) b 2 )x ⊆ e r y b B , x B im A im 2 B 2 (A − b , o r p lie s th a t p lie s th a t o r, a s in )− b , th e n 1 7 3 Problem 9.11 T h e a p p r o a c h is to p r o v e th a t 3 x 2 Z T h e e le m e n t im p lie s th a t p re c e d in g e q b 2 B , th e n x 2 s o fo r u a − ( B ^ ) x \ A 6= ; f ( B^ ) x a r s o m e b tio n th a b = a o r e o f 2 B t x = x − 4 ≡ th e , x a b 2 3 x 2 Z 2 jx = a + b fo r m x − − b 2 A , o + b ). C o n A , w h ic h b f r x v e r im o r b − b s e ly p lie fo r a 2 A a n d b 2 B 2 B = a , if x s th a . T fo = t ( h e r s o a + B^ ) x c o m b \ 4 . n d i t i o n ( B ^ ) x \ A 6= ; e a 2 A (n o te in th e fo r s o m e a 2 A a n d A 6= ; . Problem 9.12 ( a ) S u p p o s e t h a t x 2 A ⊕ B=. T h e n , f o r s o m e a 2 A a n d b 2 B , x = a + b . T h=u s , x 2 (A )b . O n th e o th e r h a n d , s u p p o s e th a t x 2 (A )b . (A )b a n d , th e re fo re , x 2 T h e n , fo r s o m e b 2 B , a n a 2 A s u c h th a t x = p r o b le m s ta te m e n t, a 2 = (b ) S u p p o s e th a t x 2 b 2 B b 2 B b 2 B 2 (A )b . H o w e v e r, x 2 (A )b im p lie s th a t th e r e e x is ts a + b . B u t, fr o m th e d e fi n itio n o f d ila tio n g iv e n in th e A , b 2 B , a n d x = a + b im p ly th a t x 2 A ⊕ B . x (A )b . T h e n , fo r s o m e b 2 B , x 2 (A )b . H o w e v e r, x 2 (A ) im p lie s th a t th e r e e x is ts a n a 2 A a 2 A a n d b 2 B , th e n x − b = a o r N o w , s u p p o s e t h a t x 2 ( B ^ ) x \ A =6 s o m e b 2 B , x − b 2 A o r x − b = a fo r s o m e a 2 A a n d b 2 B , th e n x s u c h th a t x = a + b . B u t, if x = x − b 2 A , w h ic h im p lie s th a t x 2 ; . T h e c o n d i t i o n ( B ^ ) x \ A 6= ; ( i.e ., x = a + b ) fo r s o m e a = 2 A . (A 2 (A )b a n d , th e re fo re , x 2 b a + b fo r s o m e ( B ^ ) x \ A =6 ; . im p lie s th a t fo r B u t, if x = a + b )b . b 2 B Problem 9.13 F r o m t h e d e fi n it io n o f d ila tio n , E q . ( 9 .2 - 3 ) , (A ⊕ B )c = T h e c o m p le m e n t o f th ( B^ ) z \ A = ; . I n t u r n , ( i s , ( B^ ) z ⊆ A c , a n d w e c 3 4c z ( B ^ ) z \ A 6= ; . e s e t o f z ’ s t h a t s a t i s f y ( B ^ ) z \ A =6 ; i s t h e s e t o f z ’ s s u c h t h a t B^ ) z \ A = ; i m p l i e s t h a t t h a t ( B^ ) z i s c o n t a i n e d i n A c . T h a t a n w r ite 3 ( A ⊕ B ) c = z ( B^ ) = A c B^ z ⊆ A c 4 w h e r e t h e s e c o n d s t e p fo llo w s fr o m t h e d e fi n it io n o f e r o s io n , E q . ( 9 .2 - 1 ) . T h is c o m p le te s th e p r o o f. C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 7 4 Problem 9.14 S ta r tin g w ith th e d e fi n itio n o f c lo s in g , (A • B ) c = [(A ⊕ B ) B ] c ( A ⊕ B ) ⊕ B^ (A c B^ ) ⊕ B^ A c ◦ B^ . = = = c T h e p r o o f o f th e o th e r d u a lity p r o p e r ty fo llo w s a s im ila r a p p r o a c h . Problem 9.15 ( a ) E r o s io n o f a s e t A b y B is d e fi n e d a s th e s e t o f a ll v a lu e s o f tr a n s la te s , z , o f B s u c h th a t (B )z is c o n ta in e d in A . If th e o r ig in o f B is c o n ta in e d in B , th e n th e s e t o f p o in ts d e s c r ib in g th e e r o s io n is s im p ly a ll th e p o s s ib le lo c a tio n s o f th e o r ig in o f B s u c h th a t ( B )z is c o n ta in e d in A . T h e n it fo llo w s fr o m th is in te r p r e ta tio n (a n d th e d e fi n itio n o f e r o s io n ) th a t e r o s io n o f A b y B is a s u b s e t o f A . S im ila r ly , d i l a t i o n o f a s e t C b y B i s t h e s e t o f a l l l o c a t i o n s o f t h e o r i g i n o f B^ s u c h t h a t t h e i n t e r s e c t i o n o f C a n d ( B^ ) z i s n o t e m p t y . I f t h e o r i g i n o f B i s c o n t a i n e d i n B , t h i s im p lie s t h a t C is a s u b s e t o f t h e d ila t io n o f C b y B . F r o m E q . ( 9 .3 - 1 ) , w e k n o w th a t A ◦ B = (A B ) ⊕ B . L e t C d e n o te th e e r o s io n o f A b y B . It w a s a lr e a d y e s ta b lis h e d th a t C is a s u b s e t o f A . F r o m th e p r e c e d in g d is c u s s io n , w e k n o w a ls o th a t C is a s u b s e t o f th e d ila tio n o f C b y B . B u t C is a s u b s e t o f A , s o th e o p e n in g o f A b y B (th e e r o s io n o f A b y B fo llo w e d b y a d ila tio n o f th e r e s u lt) is a s u b s e t o f A . ( b ) F r o m E q . ( 9 .3 - 3 ) , > f ( B ) z j( B ) C ◦ B = a n d z ⊆ C g > f ( B ) z j( B ) D ◦ B = z ⊆ D g . T h e r e fo r e , if C ⊆ D , it fo llo w s th a t C ◦ B ⊆ D ◦ B . (c ) F r o m (a ), (A ◦ B ) ◦ B ⊆ (A ◦ B ). F r o m th e d e fi n itio n o f o p e n in g , (A ◦ B ) ◦ B f (A ◦ B ) = = f [(A B ) ⊕ B ] f (A = (A ⊇ ⊇ B g ⊕ B B ) • B g ⊕ B B ) ⊕ B A ◦ B . B g ⊕ B 1 7 5 B u t (A ◦ th e P ro , th B ) fa c b le e o ◦ B t th m 9 n ly w = (A a t th .1 6 ( a a y th a t (A ◦ B ) ◦ B ⊆ (A ◦ B ) a n d (A ◦ B ) ◦ B ⊇ (A ◦ B ) c a n h o ld is if ◦ B ). T h e n e x t to la s t s te p in th e p r e c e d in g s e q u e n c e fo llo w s fr o m e c lo s in g o f a s e t b y a n o th e r c o n ta in s th e o r ig in a l s e t [th is is fr o m )]. Problem 9.16 ( a ) F r o m P r o b l e m 9 . 1 4 , ( A • B ) c = A c ◦ B^ , a n d , f r o m P r o b l e m 9 . 1 5 ( a ) , i t f o l l o w s th a t ( A • B ) c = A c ◦ B^ ⊆ A c . T a k in g th e c o m p le m e n t o f b o th s id e s o f th is e q u a tio n r e v e r s e s th e in c lu s io n s ig n a n d w e h a v e th a t A ⊆ (A • B ), a s d e s ire d . (b ) F ro m P ro a n d B^ i n s t e a D c ◦ B^ . T h e re v e rs e s th e (c ) U s in g re s b le m d o f C re fo re in c lu s u lts fr 9 .1 5 ( b ) , if D c ⊆ C c , t h e n D c ◦ , D , a n d B . F r o m P r o b le m 9 .1 , if D c ⊆ C c th e n (D • B )c ⊆ io n , s o w e h a v e th a t if C ⊆ D , o m P r o b le m s 9 .1 4 a n d 9 .1 5 , 3 (A • B ) • B = (A • B 3 = (A c ◦ 3 = (A c ◦ B^ ⊆ C c ◦ B^ w h e r e 5 , (C • B )c = C c ◦ (C • B )c . T a k in th e n (C • B ) ⊆ (D ) c ◦ B^ B^ ) ◦ B^ 4c B^ ) (A • B ) = = c w e u s e d D c B^ a n d ( D • B g c o m p le m • B ), a s d e s , C c , )c = e n ts ire d . 4c 4c c (A • B ) . w h e r e t h e t h ir d s t e p fo llo w s fr o m P r o b le m 9 .1 5 ( c ) a n d t h e fo u r t h s t e p fo llo w s fr o m P r o b le m 9 .1 4 . Problem 9.17 F ig u r e P 9 .1 7 s h o w s th e s o lu tio n . A lth o u g h th e im a g e s s h o w n c o u ld b e s k e tc h e d b y h a n d , th e y w e r e d o n e in M A T L A B fo r c la r ity o f p r e s e n ta tio n . T h e M A T L A B c o d e fo llo w s : >> f = imread(’FigProb0917.tif’); > > se = strel(’dis’, 11, 0); % Structuring element. > > fa = imerode(f, se); > > fb = imdilate(fa, se); > > fc = imdilate(fb, se); > > fd = imerode(fc, se); 1 7 6 C H A P T E R 9 . P R O B L E M S O L U T IO N S F ig u r e P 9 .1 7 T h e s iz e o f th e o r ig in a l im a g e is 6 4 8 × 6 2 4 p ix e ls . A d is k s tr u c tu r in g e le m e n t o f r a d iu s 1 1 w a s u s e d . T h is s tr u c tu r in g e le m e n t w a s ju s t la r g e e n o u g h to e n c o m p a s s e a c h n o is e e le m e n t, a s g iv e n in th e p r o b le m s ta te m e n t. T h e im a g e s s h o w n in F ig . P 9 .1 7 a r e : ( a ) e r o s io n o f t h e o r ig in a l, ( b ) d ila t io n o f t h e r e s u lt , ( c ) a n o t h e r d ila tio n , a n d fi n a lly (d ) a n e r o s io n . T h e m a in p o in ts w e a r e lo o k in g fo r fr o m t h e s t u d e n t ’s a n s w e r a r e : T h e fi r s t e r o s i o n s h o u l d t a k e o u t a l l n o i s e e l e m e n t s th a t d o n o t to u c h th e r e c ta n g le , s h o u ld in c r e a s e th e s iz e o f th e n o is e e le m e n ts c o m p le te ly c o n ta in e d w ith in th e r e c ta n g le , a n d s h o u ld d e c r e a s e th e s iz e o f th e r e c ta n g le . If w o r k e d b y h a n d , th e s tu d e n t m a y o r m a y n o t r e a liz e th a t s o m e ” im p e r fe c tio n s ” a r e le ft a lo n g th e b o u n d a r y o f th e o b je c t. W e d o n o t c o n s id e r th is a n im p o r ta n t is s u e b e c a u s e it is s c a le - d e p e n d e n t, a n d n o th in g is s a id in th e p r o b le m s ta te m e n t a b o u t th is . T h e fi r s t d ila tio n s h o u ld s h r in k th e n o is e c o m p o n e n ts th a t w e r e in c r e a s e d in e r o s io n , s h o u ld in c r e a s e th e s iz e o f th e r e c ta n g le , 1 7 7 a n d s h o u ld n o is e c o m p fi n a l e r o s io ro u n d e d c o o g n iz e d b y ro u n d th e c o o n e n ts c o m p n (b o tto m r ig r n e r s in th e fi th e s tu d e n t. r n e rs le te ly h t) s h n a l a . T h e a n d fu o u ld t n s w e r n e r t h e a r x t d ila tio h e r in c re n d e c re a e a n im p n s h o u ld e lim in a a s e th e s iz e o f th e s e th e s iz e o f th e o r ta n t p o in t th a t te re re s h th c ta c ta o u e in te n g le . n g le . ld b e r n a l T h e T h e re c - Problem 9.18 It w a s p o s s ib le to r e c c a u s e th e y w e re n o t s tr u c tu r in g e le m e n t w b e e n tr u e if th e o b je c c o m p le te r e c o n s tr u c t e r o d e d b y a c ir c le , w o o n s tr u c c o m p le a s th e s ts a n d s io n , fo r u ld n o t t th e th r e e la r g e s q u te ly e r o d e d a n d th e a m e ( i.e ., t h e y w e r e s tr u c tu r in g e le m e n ts in s ta n c e , b y d ila tin g b e p o s s ib le . a re s to th e ir g e o m e tr y o f q u a re s ). T h is w e re re c ta n g a r e c ta n g le t o r ig in a l s iz e b e th e o b je c ts a n d a ls o w o u ld h a v e u la r. H o w e v e r, a h a t w a s p a r tia lly Problem 9.19 S e le c t a n d le a g e . T w h e re b e th e a o n t th e h e r th e s a m e - p ix e l b o o r ig in b e e s u lt o f a p t w o T ’s w e e a s th e o r rd lo p re ig e r a ro u n c a te d a t ly in g th e in p e r fe in o f th e d th e s tr u c tu r in g e le m th e h o r iz o n ta l/ v e r tic a l h it- o r- m is s tr a n s fo r m c t r e g is tr a tio n . T h e lo c s tr u c tu r in g e le m e n t. e n m w a t t (s u id p o o u ld io n o b im in t b e f th a g e o f t o f th is s a s in g le e p o in t h e T ), u b im p o in t w o u ld Problem 9.20 T h e m e r tim e a s fo k e fo , a llo y d r m b a w s iffe re n c e b e tw e e n th e L a k e a n d th e o th e r tw o fe a tu re s is th a t th e fo rs a c lo s e d c o n to u r. A s s u m in g th a t th e s h a p e s a r e p r o c e s s e d o n e a t a s ic tw o - s te p a p p r o a c h fo r d iffe re n tia tin g b e tw e e n th e th re e s h a p e s is : S te p 1 . A p p ly a n e n d - p o in t d e te c to r to th e o b je c t. If n o e n d p o in ts a r e fo u n d , th e o b je c t is a L a k e . O th e r w is e it is a B a y o r a L in e . S te p 2 . T h e re a re n u m e r o u s w a y s to d iffe re n tia te b e tw e e n a B a y a n d O n e o f th e s im p le s t is to d e te r m in e a lin e jo in in g th e tw o e n d p o in ts o f je c t. If th e A N D o f th e o b je c t a n d th is lin e c o n ta in s o n ly tw o p o in ts , u r e is a B a y . O th e r w is e it is a L in e . T h e r e a r e p a th o lo g ic a l c a s e s in w h te s t w ill fa il, a n d a d d itio n a l ” in te llig e n c e ” n e e d s to b e b u ilt in to th e p r o c th e s e p a th o lo g ic a l c a s e s b e c o m e le s s p r o b a b le w ith in c r e a s in g r e s o lu tio th in n e d fi g u re s . a L th e th e ic h e s s , n o f in e . o b fi g th is b u t th e C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 7 8 F ig u r e P 9 .2 1 Problem 9.21 ( a ) T h e e n t i r e i m a g e w o u l d b e fi l l e d w i t h 1 ’s . ( b ) T h e b a c k g r o u n d w o u l d b e fi l l e d w i t h 1 ’s . ( c ) S e e F ig . P 9 .2 1 . Problem 9.22 (a ) W ith re fe re n c e to s u lts fr o m u s in g th e s c o n n e c te d p a th (le ftm tu r in g e le m e n t in F ig . (b s e (2 th th ) U s in g a 3 × 3 s tr u c g m e n ts c h a r a c te r iz ,2 ) in F ig . 9 .1 5 ( e ) w e w a y to th e fi n a l r a t w o u ld tu r n F ig . 9 th e tr u o s t 9 .1 tu r e d o u e s u .1 5 e x c tu fi g 3 (b a m r in u re ) fo in g e b y d ld b e lt in (i) in p le g e ), w r m s h o w n le m e n t h e re a s s a 4 -c o le m e n t o f ia g o n a lly a 1 in s te a F ig . 9 .1 5 ( to a m u c h in in th e n n F ig . P 9 .2 2 F ig . 9 .1 5 (c b o u n d a r y e c te d p a th , th ) g e re s u (r ig a l l 1 ’s w o u l d i n t r o d c o n n e c te d p ix e ls . d o f a 0 . T h a t v a lu i). T h e r e w o u ld b e m o re d is to r te d o b e b o u n d a r y th n e r a lly fo r m s ltin g fr o m th e h tm o s t fi g u re ) u c e c o r n e r p ix F o r e x a m p le , e o f 1 w o u ld c o t h e r 1 ’s i n t r je c t. a t re a n 8 s tr u c . e ls in to s q u a re a r r y a ll o d u c e d Problem 9.23 (a ) If d e te r b la c k n e c te n e c te th m p d d e s p in in o in t to it c o m h e r e s a r e n o t a llo w e d to to u c h g w h ic h p o in ts a re b a c k g r o u n o n th e b o u n d a r y o f th e im a g u s in g a c o n n e c te d c o m p o n e n p o n e n ts a r e la b e ls w ith a v a lu , th e s o lu d (b la c k ) e a n d d e t t a lg o r ith e d iffe re n tio n o f th e p o in ts . T o e r m in e a ll m (S e c tio n t fro m 1 o r p r o b le m s ta r ts b d o th is , w e p ic k b la c k p o in ts c o n 9 .5 .3 ) . T h e s e c o n 0 . T h e re m a in in y a g - 1 7 9 F ig u r e P 9 .2 2 b la c k in g th b e e n p o in t fi llin g p o in ts a re in te r io r to e h o le fi llin g a lg o r ith tu r n e d in to w h ite p o s a r e a lr e a d y k n o w n , th e s p h e re s w ith o u t s p h e m in in ts . th e y h a v in re s . S e c t T h e c a n g to W e c io n 9 a le r t a ll b e d o re a n .5 .2 s tu tu g io fi ll a ll s p h e r e u n til a ll in te d e n t w ill r e a r n e d s im p ly n fi llin g a s a s w ith w h ite b y a p p ly r io r b la c k p o in ts h a v liz e th a t if th e in te r io in to w h ite p o in ts th u s e p a ra te p ro c e d u re . e r s ( b ) If th e s p h e r e s a r e a llo w e d to to u c h in a r b itr a r y w a y s , a w a y m u s t b e fo u n d to s e p a r a te th e m b e c a u s e th e y c o u ld c r e a te “ p o c k e ts ” o f b la c k p o in ts s u r r o u n d e d b y a ll w h ite o r s u r r o u n d e d b y a ll w h ite a n d p a r t o f th e b o u n d a r y o f th e im a g e . T h e s im p le s t a p p r o a c h is to s e p a r a te th e s p h e r e s b y p r e p r o c e s s in g . O n e w a y to d o th is is to e r o d e th e w h ite c o m p o n e n ts o f th e im a g e b y o n e p a s s o f a 3 × 3 s tr u c tu r in g e le m e n t, e ffe c tiv e ly c r e a tin g a b la c k b o r d e r a r o u n d th e s p h e r e s , th u s “ s e p a r a tin g ” th e m . T h is a p p r o a c h w o r k s in th is c a s e b e c a u s e th e o b je c ts a r e s p h e r ic a l, w h ic h im p lie s th a t th e y h a v e s m a ll a r e a s o f c o n ta c t. T o h a n d le th e c a s e o f s p h e r e s to u c h in g th e b o r d e r o f th e im a g e , w e s im p ly s e t a ll b o r d e r p o in t to b la c k . W e th e n p r o c e e d to fi n d a ll b a c k g r o u n d p o in ts T o d o th is , w e p ic k a p o in t o n th e b o u n d a r y o f th e im a g e (w h ic h w e k n o w is b la c k d u e to p r e p r o c e s s in g ) a n d fi n d a ll b la c k p o in ts c o n n e c te d to it u s in g a c o n n e c te d c o m p o n e n t a lg o r it h m ( S e c t io n 9 .5 .3 ) . T h e s e c o n n e c t e d c o m p o n e n ts a r e la b e ls w it h a v a lu e d iffe r e n t fr o m 1 o r 0 . T h e r e m a in in g b la c k p o in ts a r e in te r io r to th e s p h e r e s . W e c a n fi ll a ll s p h e r e s w ith w h ite b y a p p ly in g th e h o le fi llin g a lg o r ith m in S e c tio n 9 .5 .2 u n t il a ll s u c h in t e r io r b la c k p o in t s h a v e b e e n t u r n e d in t o w h it e p o in t s . T h e a le r t s tu d e n t w ill r e a liz e th a t if th e in te r io r p o in ts a r e a lr e a d y k n o w n , th e y c a n a ll b e tu r n e d s im p ly in to w h ite p o in ts th u s fi llin g th e s p h e r e s w ith o u t h a v in g to C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 8 0 d o re g io n m a k e s th e s u c h a n a r is s u e in tr o to s o lv e y e e a s a re s m s tu d e n t s h fi llin g a s a s e p a r a te p r o c e d u r e . N o te th a t th e e r o s io n o f w h b la c k a r e a s in te r io r to th e s p h e r e s g r o w , s o th e p o s s ib ility e e a n e a r th e b o r d e r o f a s p h e r e c o u ld g r o w in to th e b a c k g r o u d u c e s fu r th e r c o m p lic a tio n s th a t th e s tu d e n t m a y n o t h a v e t. W e re c o m m e n d m a k in g th e a s s u m p tio n th a t th e in te r io r a ll a n d n e a r th e c e n te r. R e c o g n itio n o f th e p o te n tia l p r o b le o u ld b e s u ffi c ie n t in th e c o n te x t o f th is p r o b le m . ite a r x is ts t n d . T th e to b la c k m b y e a s h a t h is o ls a rth e Problem 9.24 D e n o te th e o r ig in a l im a g e b y A . C re a te a n im a g e o f th e s a m e s iz e a s th e o r ig in a l , b u t c o n s i s t i n g o f a l l 0 ’s , c a l l i t B . C h o o s e a n a r b i t r a r y p o i n t l a b e l e d 1 i n A , c a ll it p 1 , a n d a p p ly th e c o n n e c te d c o m p o n e n t a lg o r ith m . W h e n th e a lg o r ith m c o n v e r g e s , a c o n n e c te d c o m p o n e n t h a s b e e n d e te c te d . L a b e l a n d c o p y in to B th e s e t o f a ll p o in ts in A b e lo n g in g to th e c o n n e c te d c o m p o n e n ts ju s t fo u n d , s e t th o s e p o in ts to 0 in A a n d c a ll th e m o d ifi e d im a g e A 1 . C h o o s e a n a r b itr a r y p o in t la b e le d 1 in A 1 , c a ll it p 2 , a n d r e p e a t th e p r o c e d u r e ju s t g iv e n . If th e r e a r e K c o n n e c te d c o m p o n e n ts in th e o r ig in a l im a g e , th is p r o c e d u r e w ill r e s u lt in a n im a g e c o n s i s t i n g o f a l l 0 ’s a f t e r K a p p l i c a t i o n s o f t h e p r o c e d u r e j u s t g i v e n . I m a g e B w i l l c o n ta in K la b e le d c o n n e c te d c o m p o n e n ts . Problem 9.25 F r o m S e c t io n 9 .5 .9 , t h e fo llo w in g e x p r e s s io n is a n im a g e H in w h ic h a ll t h e h o le s in im a g e f h a v e b e e n fi lle d : $ %c H = R Df c ( F ) . T h e h o le ta in ta in o n s h in g in g ly d a v e o n o n iffe r b e e ly th ly th e n c e b e tw e e n th is e x p re s s io n a n d th e o r ig in a l im a g e f is th a t th e n fi lle d . T h e r e fo r e , th e in te r s e c tio n o f f c a n d H is a n im a g e c o n e (fi lle d ) h o le s . T h e c o m p le m e n t o f th a t r e s u lt is a n im a g e c o n e h o le s . f h o le s = & f c \ $ R D f c (F ) %c ' c . F ig u r e P 9 .2 5 s h o w s t h e h o le s e x t r a c t e d fr o m F ig 9 .3 1 ( a ) . K e e p in m in d t h a t t h e h o l e s i n t h e o r i g i n a l i m a g e a r e b l a c k . T h a t ’s t h e r e a s o n f o r t h e c o m p l e m e n t i n th e p re c e d in g e q u a tio n . 1 8 1 F ig u r e P 9 .2 5 Problem 9.26 ( a ) If a ll t h e b o r d e r p o in t s a r e 1 , t h e n F in E q . ( 9 .5 - 2 8 ) w ill b e a ll 0 s . T h e d ila t io n o f F b y B w ill a ls o b e a ll 0 s , a n d th e in te r s e c tio n o f th is r e s u lt w ith f c w ill b e a ll 0 s a ls o . T h e n H , w h ic h is th e c o m p le m e n t, w ill b e a ll 1 s . (b ) If a e n tire im a g e w ith in ll th e p o im a g e is s h o u ld b h o le s , s o in ts in a h o le e fi lle d th e re th , s w s u e b o H ith lt is o rd in 1 s . a s e r o f (a ) w T h is e x p e c f a re 1 , th a t m e a n s th a t th e in te r io r o f th e ill b e th e c o r r e c t r e s u lt. T h a t is , th e e n tir e a lg o r ith m is n o t c a p a b le o f d e te c tin g h o le s te d . Problem 9.27 E r is s o B^ o s io n is th e s e t o f p o in ts z s u c h th a t B , tr a n s la te d b y z , is c o n ta in e d in A . If a s in g le p o in t, th is d e fi n itio n w ill b e s a tis fi e d o n ly b y th e p o in ts c o m p r is in g e r o s io n o f A b y B is s im p ly A . S im ila r ly , d ila tio n is th e s e t o f p o in ts z s u c h th ( B^ = B i n t h i s c a s e ) , t r a n s l a t e d b y z , o v e r l a p s A b y a t l e a s t o n e p o i n t . B e c a u B is a s in g le p o in t, th e o n ly s e t o f p o in ts th a t s a tis fy th is d e fi n itio n is th e s e t p o in ts c o m p r is in g A , s o th e d ila tio n o f A b y B is A . B A , a t s e o f Problem 9.28 T h e d a r k im a g e s tr u c tu r e s th a t a r e c o m p le te ly fi lle d b y m o r p h o lo g ic a l c lo s in g r e m a in c lo s e d a fte r th e r e c o n s tr u c tio n . C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 8 2 Problem 9.29 C o n s id e r fi r s t th e c a s e fo r n = 1 : E (1 ) G (F ) &$ E = %c ' c (F ) c c [(F B ) [ G ] = c (F B )c \ G c F c ⊕ B^ \ G = = = $ D = w h e re th e th s te p fo llo w s th e fi fth s te p th e d e fi n itio g e o d e s ic e r o o b ta in it in t tio n e d , c o m c o m p le m e n (1 ) G c F ⊕ B (1 ) G c c (F ) c c c c \ G %c i r d s t e p f o l l o w s f r o m D e M o r g a n ’s l a w , ( A [ B ) c = A c \ B c , t h e f o u r t h fr o m t h e d u a lity p r o p e r t y o f e r o s io n a n d d ila tio n ( s e e S e c t io n 9 .2 .3 ) , fo llo w s fr o m th e s y m m e tr y o f th e S E , a n d th e la s t s te p fo llo w s fr o m (2 ) n o f g e o d e s ic d ila tio n . T h e n e x t s te p , E G (F ), w o u ld in v o lv e th e s io n o f th e a b o v e r e s u lt. B u t th a t r e s u lt is s im p ly a s e t, s o w e c o u ld e r m s o f d ila tio n . T h a t is , w e w o u ld c o m p le m e n t th e r e s u lt ju s t m e n p le m e n t G , c o m p u te th e g e o d e s ic d ila tio n o f s iz e 1 o f th e tw o , a n d t th e r e s u lt. C o n tin u in g in th is m a n n e r w e c o n c lu d e th a t & $ %c ! ' c (n ) (1 ) (n − 1 ) E G = D G c (F ) E G #%c $ " (1 ) (n − 1 ) F c = D G c D G c . S im ila r ly , D (1 ) G (F ) &$ D = (1 ) G (F ) %c ' c [(F ⊕ B ) \ G ] = (F ⊕ B )c [ G c F c B^ [ G = = = $ E = F c B [ G %c ) . (1 ) G c (F $ D (n − 1 ) G c c c c c c c c A s b e fo re , D (n ) G = = & E $ E (1 ) G c (1 ) G c " E (n − 1 ) G c (F ) F c %c ! ' c #%c . 1 8 3 Problem 9.30 D G R (F ) (k ) = D G (F ) " $ (1 ) E G c E $ (k ) E G c F = = = E G R (k − 1 ) G c %c c c c F c #%c c F w h e r e w e u s e d t h e r e s u lt fr o m P r o b le m 9 .2 9 . T h e o t h e r d u a lit y p r o p e r t y is p r o v e d in a s im ila r m a n n e r. Problem 9.31 (a ) C o n s id e r th e c a s e w h e n n = 2 [(F 2 B )] c = c [(F B ) B ] ( F B ) c ⊕ B^ = = = F c ⊕ B^ F c ⊕ 2 B^ ⊕ B^ w h e r e th e s e c o n d a n d th ir d lin e s fo llo w fr o m th e d u a lity p r o p e r ty in E q . (9 .2 - 5 ). F o r a n a r b itr a r y n u m b e r o f e r o s io n s , [(F n B )] c = [(F (n − 1 ) B ) B ] = [ ( F ( n − 1 ) B ) ] c ⊕ B^ w h ic h , w h e n e x p a n d e d , w ill y ie ld [(F n B )]c = F c ⊕ n B^ . ( b ) P r o v e d in a s im ila r m a n n e r. Problem 9.32 O (n ) R (F ) = D F R = (F n B ) E F = R F = R $ C = R [F n B ] c F E c E F c (n ) R c F c ⊕ n B^ c F c c c ⊕ n B %c c c C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 8 4 w h e re (P r o b le s te p fo tio n o f s im ila r th e s e c o n d m 9 .3 0 ) , t h llo w s fr o m c lo s in g b y m a n n e r. s te e th th e re c o p fo ird s s y m n s tr llo w s fr te p fo llo m e tr y o u c tio n . o m w s f B T h th e fro m , a n d e o th d u a th e th e e r d lity o f r e c o n s tr u c r e s u lt in P r o b le m la s t s te p fo llo w s u a lity p r o p e r ty c a tio n 9 .3 1 fro m n b e b y d , th e th e p ro v ila fo d e e d tio n u r th fi n iin a Problem 9.33 ( a ) F r o m E q . ( 9 .6 - 1 ) , f b c c = f (x + s ,y + t ) m in (s ,t ) 2 b = c − f (x + s ,y + t ) m a x − (s ,t ) 2 b = m a x (s ,t ) 2 b − f (x + s ,y + t ) − f ⊕ b^ f c ⊕ b^ . = = T h e s e c o n d s te p fo llo w s fr o m th e d e fi n itio n o f th e c o m p le m e n t o f a g r a y - s c a le fu n c tio n ; th a t is , th e th e m a x im u m o f th e th e d e fi n itio n o f th e c g r a y - s c a le d ila tio n in s te p fo llo w s fr o m th e p r o p e r ty is p r o v e d in m in im u m o f a s e t o f n u m b e n e g a tiv e o f th o s e n u m b e r s . o m p le m e n t. T h e fo u r th s te p E q . ( 9 .6 - 2 ) , u s in g t h e fa c t t h a d e fi n itio n o f th e c o m p le m e n a s im ila r m a n n e r. rs T fo t b^ is e q u a l to th h e th ird s te p llo w s fr o m th e (x ,y ) = b (− x t, − f = f c . T h e e n e g a tiv e o f fo llo w s fr o m d e fi n itio n o f − y ). T h e la s t o th e r d u a lity ( b ) W e p r o v e th e s e c o n d d u a lity p r o p e r ty : f ◦ b c = f b = = f b = T h e s s io n , o th e r (c ) W 1 : e c o n d a a n d th e p ro p e r e p ro v e n d th ird s la s t s te p ty in th e p th e fi rs t d f ⊕ b^ c f c c c ⊕ b b^ b^ • b^ . te p s fo llo w fr o m th e fo llo w s fr o m th e d e fi r o b le m s ta te m e n t is u a lity p r o p e r ty . S ta r d u a lity n itio n p ro v e d t w ith t p r o f in h e o p e r t c lo s in a s im a g e o y o f d ila tio n a n d e r o g in E q . (9 .6 - 8 ). T h e ila r m a n n e r. d e s ic d ila tio n o f s iz e 1 8 5 D (1 ) g &$ D = f (1 ) g %c ' c f = ( f ⊕ b ) ^ g = − c c c c b ) _ g c %c (1 ) . f c g c c ( f ⊕ b )c _ g = = ( f $ E = c c − ( f ⊕ b ) _ − g = c − ( f ⊕ b ) _ − g c T h e s e c o n d s te p fo llo w s fr o m th e d e fi n itio n o f g e o d e s ic d ila tio n . T h e th ir d s te p fo llo w s fr o m th e fa c t th a t th e p o in t- w is e m in im u m o f tw o s e ts o f n u m b e r s is th e n e g a tiv e o f th e p o in t- w is e m a x im u m o f th e tw o n u m b e r s . T h e fo u r th a n d fi fth s te p s fo llo w fr o m th e d e fi n itio n o f th e c o m p le m e n t. T h e s ix th s te p fo llo w s fr o m t h e d u a l i t y o f d i l a t i o n a n d e r o s i o n ( w e u s e d t h e g i v e n f a c t t h a t b^ = b ) . T h e l a s t s te p fo llo w s fr o m th e d e fi n itio n o f g e o d e s ic e r o s io n . (2 ) T h e n e x t s te p in th e ite r a tio n , D g f , w o u ld in v o lv e th e g e o d e s ic d ila tio n o f s iz e 1 o f th e p r e c e d in g r e s u lt. B u t th a t r e s u lt is s im p ly a s e t, s o w e c o u ld o b ta in it in te r m s o f e r o s io n . T h a t is , w e w o u ld c o m p le m e n t th e r e s u lt ju s t m e n tio n e d , c o m p le m e n t g , c o m p u te th e g e o d e s ic e r o s io n o f th e tw o , a n d c o m p le m e n t th e r e s u lt. C o n tin u in g in th is m a n n e r w e c o n c lu d e th a t #%c $ " (1 ) (n − 1 ) f c D (g n ) ( f ) = E g c E g c . T h e o th e r p r o p e r ty is p r o v e d in a s im ila r w a y . (d ) W e p ro v e th e fi rs t p ro p e r ty : R g D ( f ) D (g k ) ( f ) $ " (1 ) E g c E $ (k ) E g c f $ R gE c f = = = = (k − 1 ) f c g c #%c %c c %c c . T h e o th e r p r o p e r ty is p r o v e d in a s im ila r m a n n e r. (e ) W e p r o v e th e fi r s t p r o p e r ty . C o n s id e r th e c a s e w h e n n = 2 f 2 b c = = f B = f b c ⊕ b^ c ⊕ 2 b^ f = f c b ⊕ b^ ⊕ b^ c C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 8 6 w h e r e th e s e c o n d a n d th ir d lin e s fo llo w fr o m th e d u a lity p r o p e r ty in E q . (9 .6 - 5 ). F o r a n a r b itr a r y n u m b e r o f e r o s io n s , f n b c = f (n − 1 )b = w h ic h , w h e n e x p a n d e d , w ill y ie ld p r o v e d in a s im ila r m a n n e r. (f ) W e p ro v e th e fi rs t p ro p e r ty : O (n ) R ( f ) = = = = = w h e re g iv e n lo w s f c lo s in m a n n th e s e c o n in (d ) , th e ro m th e s y g b y re c o n s e r. d s te p th ird m m e tr tr u c tio fo llo w s fr o m s te p fo llo w s y o f b , a n d t n . T h e o th e r b c f (n − 1 )b c f n b R Df $ R $ R $ R $ C = f c c ⊕ b^ ⊕ n b^ . T h e o t h e r p r o p e r t y i s f n b E f c E f c E f c c f (n ) R f %c ⊕ n b^ c ⊕ n b %c f c n th e d u fro m th h e la s t d u a lity a lity e re s s te p p ro p %c c f n b %c o f re c o n s tr u u lt in (e ), th fo llo w s fr o m e r ty c a n b e p c tio n e fo u r th e d ro v e d b y th e fi in d ila tio n s te p fo ln itio n o f a s im ila r Problem 9.34 T h e m e th o d is p r e d ic a te d o n im a g e o p e n in g s a n d c lo s in g s , h a v in g n o th in g to d o w ith s p a tia l a r r a n g e m e n t. B e c a u s e th e b lo b s d o n o t to u c h , th e r e is n o d iffe r e n c e b e t w e e n t h e fu n d a m e n t a l a r r a n g e m e n t in F ig . 9 .4 3 a n d t h e fi g u r e in t h is p r o b le m . T h e s te p s to th e s o lu tio n w ill b e th e s a m e . T h e o n e th in g to w a tc h is th a t th e S E u s e d to r e m o v e th e s m a ll b lo b s d o n o t r e m o v e o r s e v e r e ly a tte n u a te la r g e b lo b s a n d th u s o p e n a p o te n tia l p a th to th e b o u n d a r y o f th e im a g e la r g e r th a n th e d ia m e te r o f th e la r g e b lo b s . In th is c a s e , d is k s o f r a d iu s 3 0 a n d 6 0 (th e s a m e t h o s e u s e d in F ig . 9 .4 3 ) d o t h e jo b p r o p e r ly . T h e s o lu t io n im a g e s a r e s h o w n in F ig . P 9 .3 4 . T h e e x p la n a tio n is th e s a m e a s F ig . 9 .4 3 . T h e M A T L A B c o d e u s e d to g e n e r a te d th e s o lu tio n fo llo w s . >> >> >> >> >> f = imread(’FigP0934(blobs_in_circular_arrangement).tif’); figure, imshow(f) % Remove small blobs. fsm = imclose(f, strel(’disk’,30)); figure, imshow(fsm) 1 8 7 F ig u r e P 9 .3 4 > > % Remove large blobs. > > flrg = imopen(fsm, strel(’disk’,60)); > > figure, imshow(flrg) > > % Use a morphological gradient to obtain the boundary > > % between the regions. > > se = ones(3); > > grad = imsubtract(imdilate(flrg, se), imerode(flrg, se)); > > figure, imshow(grad) > > % Superimpose the boundary on the original image. > > idx = find(grad > 0); > > final = f; > > final(idx) = 255; > > figure, imshow(final) C H A P T E R 9 . P R O B L E M S O L U T IO N S 1 8 8 F ig u r e P 9 .3 5 Problem 9.35 (a ) T h e n o is e s p ik e s a re o f th e g e n e r a l fo r m s h o p o s s ib ilitie s in b e tw e e n . T h e a m p litu d e is ir r e le v o f th e n o is e s p ik e s is o f in te re s t. T o re m o v e th e s e w ith a c y lin d r ic a l s tr u c tu r in g e le m e n t o f r a d iu s F ig . P 9 .3 5 (b ). N o te th a t th e s h a p e o f th e s tr u c tu k n o w n s h a p e o f th e n o is e s p ik e s . ( b ) T h e b a s ic s o lu t th e v a r io u s p o s s ib in g e le m e n t lik e th d o th e jo b . N o te in th is a p p r o a c h . T h b e n e e d e d a n d , c o w n in a n t in s p ik e g re a te r in g e F ig . th is s w e r th a le m e P 9 .3 5 ( a ) , w it h c a s e ; o n ly th e p e r fo r m a n o p n R max , a s s h o n t is m a tc h e d o th e r s h a p e e n in g w n in to th e io n is th e s a m e a s in (a ), b u t n o w w e h a v e to ta k e in to a c c o u n t le o v e r la p p in g g e o m e t r ie s s h o w n in F ig . P 9 .3 5 ( c ) . A s t r u c t u r e o n e u s e d in (a ) b u t w ith r a d iu s s lig h tly la r g e r th a n 4 R m a x w ill (a ) a n d (b ) th a t o th e r p a r ts o f th e im a g e w o u ld b e a ffe c te d b y e b ig g e r R m a x , th e b ig g e r th e s tr u c tu r in g e le m e n t th a t w o u ld n s e q u e n tly , th e g r e a te r th e e ffe c t o n th e im a g e a s a w h o le . Problem 9.36 ( a ) C o lo r th e im a g e b o r d e r p ix e ls th e s a m e c o lo r a s th e p a r tic le s (w h ite ). C a ll th e r e s u ltin g s e t o f b o r d e r p ix e ls B . A p p ly th e c o n n e c te d c o m p o n e n t a lg o r ith m 1 8 9 ( S e c t io n 9 .5 .3 ) . A ll c o n n e c t e d c o m p o n e n t s t h a t c o n t a in e le m e n t s fr o m B p a r tic le s th a t h a v e m e r g e d w ith th e b o r d e r o f th e im a g e . ( b ) It is g iv e n th a t a ll p a r tic le s a r e p r o b le m ; m o r e g e n e r a l a n a ly s is r e a r e a (n u m b e r o f p ix e ls ) o f a s in g le th e im a g e th e p a r tic le s th a t w e r e th e c o n n e c te d c o m p o n e n t a lg o r it p o n e n t. A c o m p o n e n t is th e n d e p ix e ls is le s s th a n o r e q u a l to A + " fo r v a r ia tio n s in s iz e d u e to n o is e . a re o f th e s a m e s iz e (th is is d o n e to s im p lify th e q u ir e s to o ls fr o m C h a p te r 1 1 ). D e te r m in e th e p a r tic le ; d e n o te th e a r e a b y A . E lim in a te fr o m m e r g e d w ith th e b o r d e r o f th e im a g e . A p p ly h m . C o u n t th e n u m b e r o f p ix e ls in e a c h c o m s ig n a te d a s a s in g le p a r tic le if th e n u m b e r o f , w h e r e " is a s m a ll q u a n tity a d d e d to a c c o u n t ( c ) S u b tr a c t fr o m th e im a g e s in g le p a r tic le s a n d th e p a r tic le s th a t h a v e m e r g e d w ith th e b o r d e r, a n d th e r e m a in in g p a r tic le s a r e o v e r la p p in g p a r tic le s . Problem 9.37 A s g iv e n in th e p r o b le m s ta te m e n t, in te r e s t lie s in d e v ia tio n s fr o m th e r o u n d in th e in n e r a n d o u te r b o u n d a r ie s o f th e w a s h e r s . It is s ta te d a ls o th a t w e c a n ig n o re e r r o r s d u e to d ig itiz in g a n d p o s itio n in g . T h is m e a n s th a t th e im a g in g s y s te m h a s e n o u g h r e s o lu tio n s o th a t o b je c tio n a b le a r tifa c ts w ill n o t b e in tr o d u c e d a s a r e s u lt o f d ig itiz a tio n . T h e m e c h a n ic a l a c c u r a c y s im ila r ly te lls u s th a t n o a p p r e c ia b le e r r o r s w ill b e in tr o d u c e d a s a r e s u lt o f p o s itio n in g . T h is is im p o r ta n t if w e w a n t to d o m a tc h in g w ith o u t h a v in g to re g is te r th e im a g e s . T h e fi r s t s te p in th e s o lu tio n is th e s p e c ifi c a tio n o f a n illu m in a tio n a p p r o a c h . B e c a u s e w e a re in te re s te d in b o u n d a r y d e fe c ts , th e m e th o d o f c h o ic e is a b a c k lig h tin g s y s te m th a t w ill p r o d u c e a b in a r y im a g e . W e a r e a s s u r e d fr o m th e p r o b le m s ta te m e n t th a t th e illu m in a tio n s y s te m h a s e n o u g h r e s o lu tio n s o th a t w e c a n ig n o re d e fe c ts d u e to d ig itiz in g . T h e n e x t s te p is to s p e c ify a c o m p a r is o n s c h e m e . T h e s im p le s t w a y to m a tc h b in a r y im a g e s is to A N D o n e im a g e w ith th e c o m p le m e n t o f th e o th e r. H e r e , w e m a tc h th e in p u t b in a r y im a g e w ith th e c o m p le m e n t o f th e g o ld e n im a g e (th is is m o r e e ffi c ie n t th a n c o m p u tin g th e c o m p le m e n t o f e a c h in p u t im a g e a n d c o m p a r in g it to th e g o ld e n im a g e ). If th e im a g e s a r e id e n tic a l (a n d p e r fe c tly r e g is te r e d ) th e r e s u lt o f th e A N D o p e r a tio n w ill b e a ll 0 s . O th e r w is e , th e r e w ill b e 1 s in th e a re a s w h e re th e tw o im a g e s d o n o t m a tc h . N o te th a t th is re q u ire s th a t th e im a g e s b e o f th e s a m e s iz e a n d b e re g is te re d , th u s th e a s s u m p tio n o f th e m e c h a n ic a l a c c u r a c y g iv e n in th e p r o b le m s ta te m e n t. A s n o te d , d iffe r e n c e s in th e im a g e s w ill a p p e a r a s r e g io n s o f 1 s in th e A N D im a g e . T h e s e w e g r o u p in to r e g io n s (c o n n e c te d c o m p o n e n ts ) b y u s in g th e a lg o r ith m g iv e n in S e c t io n 9 .5 .3 . O n c e a ll c o n n e c t e d c o m p o n e n ts h a v e b e e n e x - 1 9 0 C H A P T E R 9 . P R O B L E M S O L U T IO N S tr a c te d , w e c a n c o m p a re th e m a g a in s t s p e c ifi e d c r ite r ia fo r a c c e p ta n c e o r re je c tio n o f a g iv e n w a s h e r. T h e s im p le s t c r ite r io n is to s e t a lim it o n th e n u m b e a n d s iz e (n u m b e r o f p ix e ls ) o f c o n n e c te d c o m p o n e n ts . T h e m o s t s tr in g e n t c r ite r io n is 0 c o n n e c te d c o m p o n e n ts . T h is m e a n s a p e r fe c t m a tc h . T h e n e x t le v e l fo “ r e la x in g ” a c c e p ta n c e is o n e c o n n e c te d c o m p o n e n t o f s iz e 1 , a n d s o o n . M o r s o p h is tic a te d c r ite r ia m ig h t in v o lv e m e a s u r e s lik e th e s h a p e o f c o n n e c te d c o m p o n e n ts a n d th e r e la tiv e lo c a tio n s w ith r e s p e c t to e a c h o th e r. T h e s e ty p e s o d e s c r ip to r s a re s tu d ie d in C h a p te r 1 1 . r r e f Chapter 10 Problem Solutions Problem 10.1 E x p a n d f (x + Δ x ) in to a T a y lo r s e r ie s a b o u t x : f (x ) + Δ x f 0(x ) + f (x + Δ x ) = (Δ x ) f 2 ! 00 (x ) + ··· T h e in c r e m e n t in t h e s p a t ia l v a r ia b le x is d e fi n e d in S e c t io n 2 .4 .2 t o b e 1 , s o b y le ttin g Δ x = 1 a n d k e e p in g o n ly th e lin e a r te r m s w e o b ta in th e r e s u lt f 0(x ) = f (x + 1 ) − f (x ) w h ic h a g r e e s w it h E q . ( 1 0 .2 - 1 ) . Problem 10.2 T h y ie e n a + in e m a s k s ld a v a lu te d in th 2 w h e n th e d ire c w o u ld h a v e e o f 0 w h e n e d ire c tio n f a m a s k is c e tio n fa v o re d th e c e n a v o n te b y c te re re th o e ffi c ie n ts s h o re d o n a p ix e l d b y th a t m a s k d o n a o n e - p ix a t m a s k . w n in o f a n . C o n e l g a p F ig . u n b r v e rs e in a P 1 0 .2 . o k e n 3 ly , th e r 3 - p ix e l E a c h m a s k p ix e l s e g m e e s p o n s e w o s e g m e n t o r w o u ld n t o r iu ld b e ie n te d Problem 10.3 T h e k a d e fi h a v e th e le p o in t e y to s o lv in n itio n o f e n b e e n fo u n d n g th s o f th e s o f e v e r y p g th is p r o b le m is to fi n d a d p o in t) o f lin e s e g m e n ts , th e D 8 d is ta n c e b e tw e e n v a r io u s g a p s . W e c h o o s e a ir o f s e g m e n ts a n d a n y s 1 9 1 ll in a th u c e n d p o in ts (s e e th e im a g e . O n ll p a ir s o f s u c h e s m a lle s t d is ta h d is ta n c e le s s S e c t io n 9 .5 .8 c e a ll e n d p o e n d p o in ts g n c e b e tw e e n th a n o r e q u a fo r in ts iv e s e n d l to C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 1 9 2 F ig u r e P 1 0 .2 K s a tis fi e n u m e ro u F o r e x a m to b e le s s lik e th is a s u c h te s t th is u p in s th e s ta te m e n t o f th e p r o b le m . T h is is s e m b e llis h m e n ts c a n b e a d d e d to b u ild p le , it is p o s s ib le fo r e n d p o in ts o f d iffe r e th a n K p ix e ls a p a r t, a n d h e u r is tic te s ts t r e q u ite u s e fu l. A lth o u g h th e p r o b le m s t s , th e y n o r m a lly a r e n e e d e d in p r a c tic e c la s s if th is p r o b le m is a s s ig n e d a s h o m e a r u d im e n ta r y s o lu tio n , a n d in te llig e n c e in to th e p r o c e s s . n t, b u t c lo s e ly a d ja c e n t, lin e s h a t a tte m p t to s o r t o u t th in g s a te m e n t d o e s n o t c a ll fo r a n y a n d it is w o r th w h ile to b r in g w o rk . Problem 10.4 ( a ) T h e lin e s w e r e th ic k e r th a n th e w id th o f th e lin e d e te c to r m a s k s . T h u s , w h e n , fo r e x a m p le , a m a s k w a s c e n te r e d o n th e lin e it ” s a w ” a c o n s ta n t a r e a a n d g a v e a re s p o n s e o f 0 . ( b ) V ia c o n n e c tiv ity a n a ly s is . Problem 10.5 (a ) T p ro fi in g g b o rd a g e s h e fi r s t r o w in F ig . P 1 0 .5 s h o w s a s t e p , r a m p , a n d le s th r o u g h th e ir c e n te r s . S im ila r ly , th e s e c o n d r a d ie n t im a g e s a n d h o r iz o n ta l p r o fi le s th r o u g h e r s in th e im a g e s a r e in c lu d e d fo r c la r ity in d e fi ; th e y a re n o t p a r t o f th e im a g e d a ta . e d g e ro w s th e ir n in g im a g h o w s c e n te th e b e , a n th e rs . T o rd e d h c o r h e rs o o r iz re s p th in f th o n ta l o n d d a rk e im - ( b ) T h e t h ir d r o w in F ig . P 1 0 .5 s h o w s t h e a n g le im a g e s a n d t h e ir p r o fi le s . A ll im a g e s w u la r, th e p r o fi le itiv e v a lu e s . T h a n d d a rk a re a s T h e b la c k in a ll (2 5 5 b e c a u s e th e re o f e g c o r o th e s e s c a le d fo r d is p la y , s o o th e a n g le im a g e o f th e r a y in th e s c a le d a n g le re s p o n d to p o s itiv e a n e r im a g e s d e n o te s 0 a n a re 8 - b it im a g e s ). G r a n ly th e s h a p e s a r e o f in te r e s t. r o o f e d g e h a s z e r o , n e g a tiv e , im a g e d e n o te s z e r o , a n d th e d e q u a lly n e g a tiv e v a lu e s , r e s d th e p u re w h ite is th e m a x im y s a r e v a lu e s in b e tw e e n . In p a r tic a n d p o s th e lig h t p e c tiv e ly . u m v a lu e 1 9 3 Edges and their profiles Gradient images and their profiles Angleimages and their profiles F ig u r e P 1 0 .5 Problem 10.6 F ig u r e P 1 0 .6 s h o w s t h e s o lu t io n . Problem 10.7 F ig u r e P 1 0 .7 s h o w s t h e s o lu t io n . Problem 10.8 ( a ) In s p e c tio n o f th e S o b e l m a s k s s h o w s th a t g x = 0 fo r e d g e s o r ie n te d v e r tic a lly a n d g y = 0 fo r e d g e s o r ie n te d h o r iz o n ta lly . T h e r e fo r e , it fo llo w s in th is c a s e th a t, ? g y2 = g y , a n d s i m i l a r l y f o r h o r i z o n t a l e d g e s . fo r v e r tic a l e d g e s , r f = ( b ) T h e s a m e a r g u m e n t a p p lie s to th e P r e w itt m a s k s . C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 1 9 4 n n F ig u r e P 1 0 .6 Problem 10.9 C o n s id e r fi r s t t h e S o b e l m a s k s o f F ig s . 1 0 .1 4 a n d 1 0 .1 5 . A s im p le w a y t o p r o v e th a t th e s e m a s k s g iv e is o tr o p ic r e s u lts fo r e d g e s e g m e n ts o r ie n te d a t m u ltip le s o f 4 5 ◦ is to o b ta in th e m a s k re s p o n s e s fo r th e fo u r g e n e r a l e d g e s e g m e n ts s h o w n in F ig . P 1 0 .9 , w h ic h a r e o r ie n t e d a t in c r e m e n t s o f 4 5 ◦ . T h e o b je c t iv e is t o s h o w th a t th e r e s p o n s e s o f th e S o b e l m a s k s a r e in d is tin g u is h a b le fo r th e s e fo u r e d g e s . T h a t t h is is t h e c a s e is e v id e n t fr o m T a b le P 1 0 .9 , w h ic h s h o w s t h e r e s p o n s e o f e a c h S o b e l m a s k to th e fo u r g e n e r a l e d g e s e g m e n ts . W e s e e th a t in e a c h c a s e th e re s p o n s e o f th e m a s k th a t m a tc h e s th e e d g e d ire c tio n is (4 a − 4 b ), a n d th e re s p o n s e o f th e c o r re s p o n d in g o r th o g o n a l m a s k is 0 . T h e re s p o n s e o f th e re m a in in g tw o m a s k s is e ith e r (3 a − 3 b ) o r (3 b − 3 a ). T h e s ig n d iffe re n c e is n o t s ig n ifi c a n t b e c a u s e th e g r a d ie n t is c o m p u te d b y e ith e r s q u a r in g o r ta k in g th e a b s o lu te v a lu e o f th e m a s k r e s p o n s e s . T h e s a m e lin e o f r e a s o n in g a p p lie s to th e P re w itt m a s k s . E d g e d ire c tio n H o r iz o n ta l V e r tic a l + 4 5 ◦ − 4 5 ◦ H o r iz o S o b e l 4 a − 0 3 a − 3 b − n ta l (g x ) 4 b 3 b 3 a T a b le P 1 0 .9 V e r tic a l S o b e l (g y ) 0 4 a − 4 b 3 a − 3 b 3 a − 3 b S o 3 3 4 + 4 b e l a − a − a − 0 5 ◦ (g 45 ) 3 b 3 b 4 b − 4 S o b e l 3 b − 3 a − 5 (g ◦ − 4 5 ) 3 a 3 b 0 4 a − 4 b Problem 10.10 C o n a n d p o in re s p s id e r a g e n t h a s o n s e fi rs t e ra l v a lu o f th th 3 e e e 3 × × 3 s e , a s 3 × 3 3 s m u b im F ig . m a s k o o th in a g e a r P 1 0 .1 0 w h e n g m a s k e a w ith s h o w s its c e n m e n tio n e in te n s itie . R e c a ll th te r is a t th d in th e p r o s a th ro u g h a t v a lu e e is a t lo c a tio n . b le i , re Ig n m s ta te m w h o s e c e p la c e d b y o r in g th e e n t, n te r th e 1 / 9 1 9 5 F ig u r e P 1 0 .7 s c a le fa c to r, th e r e s p o n s e o f t c + d + e + f + g + h + i). T h e id e a w ith th e o n e - d im a p ix e l b y th e re s p o n s e o f th e m in d , th e m a s k [1 1 1 ] w o u ld p ix e ls w ith v a lu e s b , e , a n d h , N e x t, w e p a s s th e m a s k h e m a s k w h e n c e n te r e d a t th a t lo c a tio n is (a + b + e n m a y ie re s s io s k ld p e n a l m a s k w h e n it is th e fo llo w c tiv e ly : (a is c in + th e s a e n te re g re s p b + c ) m e : d o n o n s e , (d + W e r e p la c e th th a t p ix e l. W s w h e n c e n te e + f ), a n d ( e v a lu e ith th is re d a t t g + h + o f in h e i ). ⎤ ⎡ 1 ⎥ ⎦ ⎢ ⎣ 1 1 th r o u g h th e s e r e s u lts r e s p o n s e w ill b e [(a + r e s u lt p r o d u c e d b y th R e tu r n in g n o w to th e p ix e l w ith v a lu e e th e o n e - d im e n s io n a l . W h e n th is m a s k b + c ) + (d + e + f e 3 × 3 s m o o th in g p r o b le m a t h a n d , , its re s p o n s e is g x d iffe re n c in g m a s k ⎡ is c e n te re ) + (g + h m a s k . w h e n th e = (g + 2 h − 1 ⎢ ⎣ 0 1 ⎤ ⎥ ⎦ d a t th e p ix e l w ith v a lu e e , its + i )], w h ic h is th e s a m e a s th e g x S o b e l m a s k is c e n te re d a t + i ) − (a + 2 b + c ). If w e p a s s C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 1 9 6 th r o u g h th e im a g e , its r e s p o n s e w h e n its c e n te r is a t th e p ix e ls w ith v a lu e s d , e , a n d f , r e s p e c t iv e ly , w o u ld b e :( g − a ) , (h − b ), a n d (i − c ). N e x t w e a p p ly t h e s m o o th in g m a s k [1 2 1 ] to th e s e r e s u lts . W h e n th e m a s k is c e n te r e d a t th e p ix e l w ith v a lu e e , its r e s p o n s e w o u ld b e [( g − a ) + 2 (h − b ) + (i − c )] w h ic h is [( g + 2 h + i ) − (a + 2 b + c )]. T h is is th e s a m e a s th e re s p o n s e o f th e 3 × 3 S o b e l m a s k fo r g x . T h e p r o c e s s to s h o w e q u iv a le n c e fo r g y is b a s ic a lly th e s a m e . N o te , h o w e v e r, th a t th e d ir e c tio n s o f th e o n e - d im e n s io n a l m a s k s w o u ld b e r e v e r s e d in th e s e n s e th a t th e d iffe r e n c in g m a s k w o u ld b e a c o lu m n m a s k a n d th e s m o o th in g m a s k w o u ld b e a r o w m a s k . Problem 10.11 ( a ) T h e o p e r a to r s a r e a s fo llo w s (n e g a tiv e n u m b e r s a r e s h o w n u n d e r lin e d ): 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 ( b ) T h e s o lu tio n is a s fo llo w s : C o m p a s s g r a d ie n t o p e r a to r s E N E N N W W S W S S E G r a d ie n t d ir e c tio n N N W W S W S S E E N E Problem 10.12 ( a ) T h e s o lu t io n is s h o w n in F ig . P 1 0 .1 2 ( a ) . T h e n u m b e r s in b r a c k e t s a r e v a lu e s o f [g x , g y ]. F ig u r e P 1 0 .9 1 9 7 F ig u r e P 1 0 .1 0 ( b ) T h e s o lu t io n is s h o w n in F ig . P 1 0 .1 2 ( b ) . T h e a n g le w a s n o t c o m p u t e d fo r t h e tr iv ia l c a s e s in w h ic h g x = g y = 0 . T h e h is to g r a m fo llo w s d ir e c tly fr o m th is ta b le . ( c ) T h e s o lu t io n is s h o w n in F ig . P 1 0 .1 2 ( c ) . Problem 10.13 ( a ) T h e lo c a l a v e r a g e a t a p o in t (x , y ) in a n im a g e is g iv e n b y f¯ ( x , y ) = 1 n z 2 z i2 S i x y w h e re S x y is th e re g io n in th e im a g e e n c o m p a s s e d b y th e n × n a v e r a g in g m a s k w h e n it is c e n te r e d a t (x , y ) a n d th e z i a r e th e in te n s itie s o f th e im a g e p ix e ls in th a t re g io n . T h e p a r tia l @ f¯ / @ x = f¯ ( x + 1 , y ) − f¯ ( x , y ) is th u s g iv e n b y @ f¯ / @ x = T h e fi in th e ro w p w r ite rs s ic th t s e c k e e u m m o n d s d u p p re c e a tio n o n th u m m a tio n b y th e m a d in g e q u a t 1 z n z i2 S 1 − i 2 z i 2 n x + 1 ,y z i2 S x y e r ig h t c a n b e in te r p r e te d a s c o n s is tin g o f a ll th e p ix e ls m in u s th e p ix e ls in th e fi r s t r o w o f th e m a s k , p lu s th e s k a s it m o v e d fr o m (x ,y ) to (x + 1 ,y ). T h u s , w e c a n io n a s @ f¯ / @ x = 1 n z 2 z i2 S x + 1 ,y i − 1 n z 2 z i2 S x y i C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 1 9 8 F ig u r e P 1 0 .1 2 , = 1 n z n − 1 2 f (x + 1 n + x y 2 n = i k = y − n − 1 2 y + n − 1 2 f (x + 2 k = y − 1 n 2 (s u m o f p ix e ls in n e w r o w ) (s u m o f p ix e ls in 1 s t r o w ) 2 n y + 1 2 S i 1 − = z 2 n − 1 2 n + 1 ,k ) − 2 n + 1 ,k ) − 2 y + 1 n 1 − n z 2 z i2 S n − 1 2 f (x − 2 k = y − f (x − i x y n − 1 2 n − 1 ,k ) . 2 n − 1 ,k ) 2 1 9 9 T h i s e x p r e s s i o n g i v e s t h e v a lu e o f @ f¯ / @ x a t c o o r d i n a t e s ( x , y ) o f t h e s m o o t h e d im a g e . S im ila r ly , @ f¯ / @ y = 1 z 2 n , = z i2 S 1 i 1 + n − 1 2 k = x − n − 1 2 x + n − 1 2 (s u m o f p ix e ls in n e w c o l) n − 1 2 1 − x + 1 z 2 n z i2 S f (k ,y − k = x − f (k ,y − i x y n − 1 2 2 n n + 1 ) − 2 f (k ,y + 2 k = x − i x y n + 1 ) − 2 f (k ,y + 1 2 n x y 2 n n z i2 S (s u m o f p ix e ls in 1 s t c o l) 2 n x + 1 = z z i2 S z 2 n - 2 − = x ,y + 1 1 n 1 − i n − 1 2 n − 1 ) 2 n − 1 ) . 2 T h e e d g e m a g n i t u d e i m a g e c o r r e s p o n d i n g t o t h e s m o o t h e d i m a g e f¯ ( x , y ) i s t h e n g iv e n b y ( @ f¯ / @ x ) 2 + ( @ f¯ / @ y ) 2 . M¯ ( x , y ) = ( b ) F r o m t h e p r e c e d i n g e q u a t i o n f o r @ f¯ / @ x , t h e m a x i m u m v a lu e t h i s t e r m c a n h a v e is w h e n e a c h d iffe re n c e in th e s u m m a tio n is m a x im u m w h ic h , fo r a n m - b it im a g e , is L = 2 m − 1 ( e .g ., 2 5 5 fo r a n 8 - b it im a g e ) . T h u s , @ f¯ / @ x m a x = 1 n 2 (n L ) = L n a n d s im ila r ly fo r o th e r d e r iv a tiv e te r m . T h e r e fo r e , ) L 2 L 2 L p M¯ m a x ( x , y ) = + = 2 . 2 2 n n n F o r th e o r ig in a l im a g e , th e m a x im u m v a lu e th a t @ f / @ x c a n h a v e is L , a n d s im ila r ly fo r @ f / @ y . T h e r e fo r e , p M max (x ,y ) = L 2 a n d th e r a tio is : M¯ M m a x m a x (x ,y ) = (x ,y ) 1 n w h ic h s h o w s th a t th e e d g e s tre n g th o f a s m o o th e d im a g e c o m p a re d to th e o r ig in a l im a g e is in v e r s e ly p r o p o r tio n a l to th e s iz e o f th e s m o o th in g m a s k . C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 0 0 Problem 10.14 ( a ) W e p r o c e e e d a s fo llo w s A v e ra g e r 2G (x ,y ) 1 1 − 1 1 − 1 1 = = − 1 4 p 4 σ 4 2 σ p 4 π − 4 π = 0 p 2 − y 2 2 σ 2 d x d y d y 1 d y e − x 2 2 σ 2 d x d x d y 2 π σ p 2 2 π σ × σ 2 π σ σ 2 2 = x 2 + y 2 2 σ 2 − 1 4 y 2 2 σ 2 − e − e 1 − e x 2 + y 2 2 σ 2 − − 1 2 π σ × σ + 4 2 − 1 1 σ e − 1 y 2 2 d x 1 σ 1 − 2 σ 1 x 2 2 σ 2 − e 1 − = 2 − 1 + 2 + y σ x σ 2 x − 1 1 1 = r 2G (x ,y )d x d y 2 π σ 2 th e fo u r th lin e fo llo w s fr o m th e fa c t th a t v a r ia n c e (z ) = σ a n d p ( b ) C o n v o lv in g a s m u ltip ly in g d o m a in . F r o m fre q u e n c y d o m fre q u e n c y d o m s o its F o u r ie r tr F o u r ie r tr a n s fo 2 π σ 1 1 p = 2 π σ 1 1 a n im a g e f (x ,y ) th e F o u r ie r tr a n C h a p te r 4 , w e k a in is p r o p o r tio n a in . W e s h o w e d a n s fo r m a t th e o r m s o f f (x ,y ) a n 2 e − z 2 2 σ 2 z 2 e − z 2 2 σ 2 d z − 1 d z = 1 . − 1 w ith r 2 G (x ,y s fo r m s o f th e n o w th a t th e a l to th e v a lu e in (a ) th a t th e r ig in m u s t b e d r 2G (x ,y ) e ) in th e s p a tia l d o m a in s e tw o fu n c tio n s in th e a v e r a g e v a lu e o f a fu n c o f its tr a n s fo r m a t th e o a v e r a g e v a lu e o f r 2 G (x z e ro . T h e re fo re , th e p ro v a lu a te d a t th e o r ig in is is th e s a m e fre q u e n c y tio n in th e r ig in o f th e , y ) is z e r o , d u c t o f th e z e ro , fro m 2 0 1 w h ic h it fo llo w s th a t th e c o n v o lu tio n o f th e s e tw o fu n c tio n s h a s a z e r o a v e r a g e v a lu e . (c ) T h th e L a w ith a s o if it v o lv in e a n s w e r is y e s . F p la c ia n m a s k s in n y im a g e g iv e s a s a v e r a g e is z e r o , g th is r e s u lt w ith ro th re th a n m P r o b le m 3 .1 6 w e e p r o b le m s ta te m e s u lt w h o s e a v e r a g e is m e a n s th a t a ll th y im a g e a ls o g iv e s a k n o w n t) w h v a lu e e e le m r e s u lt th a t c o o s e c o is z e r o e n ts s u w h o s e n v o lv in g a e ffi c ie n ts s . T h e re s u m to z e ro . a v e ra g e v a m a s k (lik u m to z e r lt is d ig ita T h u s , c o n lu e is z e r o e o l, . Problem 10.15 ( a ) L e t g L (x , y ) d e n o t e t h e L o G im a g e , a s in F ig . 1 0 .2 2 ( b ) . T h is im a g e h a s b o t h p o s itiv e a n d n e g a tiv e v a lu e s , a n d w e k n o w th a t th e z e r o c r o s s in g s a r e s u c h th a t a t le a s t a p a ir o f o p p o s in g lo c a tio n s in a 3 × 3 n e ig h b o r h o o d d iffe r in s ig n . C o n s id e r a b in a r y im a g e g P (x , y ) fo r m e d b y le ttin g g P (x , y ) = 1 if g L (x , y ) > 0 a n d g P (x , y ) = 0 o t h e r w is e . F ig u r e P 1 0 .1 5 ( a ) s h o w s g P (x , y ) fo r t h e L a p la c ia n im a g e in F ig . 1 0 .2 2 ( b ) . T h e im p o r t a n t t h in g a b o u t t h is im a g e is t h a t it c o n s is t s o f c o n n e c te d c o m p o n e n ts . F u th e r m o re (fo r th e 3 × 3 m a s k u s e d to d e te c t z e ro c r o s s in g s a n d a th r e s h o ld o f 0 ) e a c h p o in t o n th e b o u n d a r y o f th e s e c o n n e c te d c o m p o n e n t s is e it h e r a p o in t s o f t r a n s it io n b e t w e e n p o s it iv e a n d n e g a t iv e ( i.e ., it is th e c e n te r p o in t o f th e m a s k ) o r it is a d ja c e n t to th e p o in t o f tr a n s itio n . In o th e r w o r d s , a ll z e r o - c r o s s in g p o in ts a r e a d ja c e n t to th e b o u n d a r is o f th e c o n n e c te d c o m p o n e n ts ju s t d e s c r ib e d . B u t, b o u n d a r ie s o f c o n n e c te d c o m p o n e n ts fo r m a c lo s e d p a th (a p a th e x is ts b e tw e e n a n y tw o p o in ts o f a c o n n e c te d c o m p o n e n t, a n d th e p o in ts fo r m in g th e b o u n d a r y o f a c o n n e c te d c o m p o n e n ts a re p a r t o f th e c o n n e c te d c o m p o n e n t, s o th e b o u n d a r y o f a c o n n e c te d a c o m p o n e n t is a c lo s e d p a th ) . F ig u r e P 1 0 .1 5 ( b ) s h o w s t h e c lo s e d p a th s fo r th e p r o b le m in q u e s t io n . C o m p a r e t h e s e c lo s e d p a t h s a n d t h e b in a r y r e g io n s in F ig . P 1 0 .1 5 ( a ) . (b ) T h e a n s w e r th e z e r o c r o s s in tio n a n d a th re s a r e e x p la in e d in P o g g io , IE E E T r a 1 4 7 - 1 6 3 . L o o k in u n d e r p in n in g s o s tu d e n ts . is y e s fo r fu n c tio n s th a t m e e t c e r ta in m ild c o n d itio n s , a n d g m e th o d is b a s e d o n r o ta tio n a l o p e r a to r s lik e th e L o G fu n h o ld o f 0 . G e o m e tr ic a l p r o p e r tie s o f z e r o c r o s s in g s in g e n e r s o m e d e t a i l i n t h e p a p e r ” O n E d g e D e t e c t i o n ,” b y V . T o r r e a n d n s . P a t t e r n A n a ly s is a n d M a c h in e In t e ll., v o l. 8 , n o . 2 , 1 9 8 6 , p g u p th is p a p e r a n d b e c o m in g fa m ilia r w ith th e m a th e m a tic f e d g e d e te c tio n is a n e x c e lle n t r e a d in g a s s ig n m e n t fo r g r a d u a if c a l T . p . a l te C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 0 2 F ig u r e P 1 0 .1 5 Problem 10.16 G 0(r ) − r − r 22 e 2σ σ 2 G 00( r ) 1 r 2 − 4 σ σ r 2 − σ 2 σ 4 = r 2G (x ,y ) = = = L e ttin g r 2 = x 2 + y 2 2 r 2 2 σ 2 − e r 2 2 σ 2 − e w e o b ta in r 2G (x ,y ) = C o m p a r in g th is d e r iv a re a s o n fo r th e d iffe re n w ith re s p e c t to x a n d y w ith r is b a s ic a lly w o r k a s w o r k in g w ith a 1 - D it tu r n s o u t, th e d iffe re a s ig n ifi c a n t d iffe re n c e x 2 2 + y σ 2 − σ e 4 − x 2 + y 2 2 σ 2 tio n w ith th e d e r iv a tio n o f E q . c e is in th e d e r iv a tiv e s o f r a s o . A n o th e r w a y o f e x p la in in g th e in g w ith a r a d ia l s lic e o f a 2 - D fu G a u s s ia n . T h e 2 - D n a tu re o f th n c e o f o n ly 2 in th e n u m e r a to r in th e fi lte r e d r e s u lt. Problem 10.17 ( 1 0 .2 - 1 5 ) w e s e e t h a t t h p p o s e d to th e d e r iv a tiv e d iffe re n c e is th a t w o r k in n c tio n , w h ic h is th e s a m e p r o b le m is th u s lo s t. A m u ltip ly in g s ig m a m a k e ( a ) F r o m E q . ( 1 0 .2 - 2 6 ) , t h e D o G fu n c t io n is z e r o w h e n 1 2 π σ 1 − 2 e x 2 + y 2 2 σ 2 1 = 1 2 π σ 2 − 2 e x 2 + y 2 2 σ 2 2 . e s g e s s 2 0 3 T a k in g th e n a tu r a l lo g o f b o th s id e s y ie ld s , 1 ln 2 π σ 1 2 x − 2 2 + y 2 σ 1 1 = ln 2 2 π σ 2 2 x − 2 2 + y 2 σ 2 . 2 C o m b in in g te r m s , x 2 1 2 + y 2 σ 1 1 − 2 2 σ 2 1 = ln 2 = ln 2 π σ 1 σ 1 σ 2 2 F in a lly , s o lv in g fo r σ 2 1 2 σ 2 1 − 2 σ 1 = ln 2 2 π σ 2 2 . 2 2 T h e L o G fu n c t io n [E q . ( 1 0 .2 - 2 3 ) ] is z e r o w h e n x p re c e d in g e q u a tio n , σ 1 − ln 2 2 + y = 2 2 σ . T h e n , fro m th e 1 σ 2 2 σ . 2 , 2 σ σ = σ 1 2 1 2 σ 2 2 − σ 2 ln 2 1 σ 2 2 σ 2 w h ic h a g r e e s w it h E q . ( 1 0 .2 - 2 7 ) . ( b ) T o o b ta in a n e x p r e s s io n in te r m s o f k , w e le t σ e q u a tio n : σ 2 2 k = = k 2 k 2 σ k 4 2 σ 2 2 − σ 2 − 1 2 2 σ 2 k ln 2 = k σ 2 in th e p re c e d in g 2 σ σ ln (k 2 2 1 2 2 2 ) w ith k > 1 . Problem 10.18 ( a ) E q u a t io n ( 1 0 .2 - 2 1 ) c a n b e w r it t e n in t h e fo llo w in g s e p a r a b le fo r m G (x ,y ) = − x 2 + y 2 2 σ 2 − x 2 2 σ 2 e − y 2 2 σ 2 = e = G (x )G (y ). e C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 0 4 F r o m E q . ( 3 .4 - 2 ) a n d t h e p r e c e d in g e q u a t io n , t h e c o n v o lu t io n o f G (x , y ) a n d f (x ,y ) c a n b e w r itte n a s a a f (x ,y ) G (x ,y ) = G (s ,t ) f (x − s ,y − t ) s = − a t = − a a a = e s = − a t = − a a = − e s 2 2 σ 2 s 2 2 σ 2 − ⎡ ⎣ a = (n − 1 )/ 2 a n d n is th e 0 .2 - 2 1 ) . T h e e x p r e s s io n in s 2 2 e n tia l te r m , e − t /2 σ , w ith t 2 2 c o n v o lu tio n o f e − s /2 σ w ith G (x ,y ) (b ) e a c 1 -D im a m u m u D ire c h lo c a c o n v g e , fo ltip lic ltip lic t im p le tio n o f o lu tio n r a to ta a tio n s a a tio n s . m e n ta tio n f (x ,y ), s o re q u ire s n l o f n × M re re q u ire d T h e c o m p u f (x − s ,y − t ) ⎤ a t 2 2 σ 2 − e s = − a w h e re E q . (1 e x p o n is th e t 2 2 σ 2 − e f (x − s ,y − t )⎦ t = − a s iz id e h e th n × c k e f (x n s o e o f th e th e b ra ro w s o f e c o lu m f (x ,y ) = G (x ) n m a ts is th ,y ). T h f th e re s k e 1 e n s u o b -D th lt. n 2 M N 2 n M N b y s a m p lin lu tio n o f th r s u m m a tio a n o th e r w a g e n y , f (x ,y ) . G (y ) o f 2 - D c o n v o lu tio n r e q u ir e s n th e to ta l n u m b e r o f m u ltip lic a m u ltip lic a tio n s a t e a c h lo c a tio × N fo r th e p a s s a lo n g th e r o w fo r th e p a s s a lo n g th e c o lu m n s ta tio n a l a d v a n ta g e , A , is th e n A = ta in e d c o n v o e o u te S ta te d 2 tio n o s . , fo m n f T r u ltip lic a s is n 2 × e v e r y ro h e n , n × a to ta l o tio n s M × w in t M × f 2 n M a t N . h e N N n = 2 w h ic h is in d e p e n d e n t o f im a g e s iz e . F o r e x a m p le , if n = 2 5 , A = 1 2 .5 , s o it t a k e s 1 2 .5 m o r e m u lt ip lic a t io n s t o im p le m e n t 2 - D c o n v o lu t io n d ir e c t ly t h a n it d o e s t o im p le m e n t th e p r o c e d u r e ju s t o u tlin e d th a t u s e s 1 - D c o n v o lu tio n s . Problem 10.19 ( a ) A s E q . ( 1 0 .2 - 2 5 ) s h o w s , t h e fi r s t t w o s t e p s o f t h e a lg o r it h m c a n b e s u m m a r iz e d in to o n e e q u a tio n : g (x ,y ) = r 2 [G (x ,y ) f (x ,y )]. U s in g th e d e fi n itio n o f th e L a p la c ia n o p e r a to r w e c a n e x p r e s s th is e q u a tio n a s g (x ,y ) 2 @ = = @ x @ @ x 2 G (x ,y ) 2 G (x ) f (x ,y ) + @ 2 @ y 2 G (y ) f (x ,y ) + G (x ,y ) 2 @ @ y f (x ,y ) 2 2 G (x ) G (y ) f (x ,y ) 2 0 5 w h e r e t h e s e c o n d s t e p fo llo w s fr o m P r o b le m 1 0 .1 8 , w it h G (x ) = e − − x 2 2 σ 2 a n d G (y ) = y 2 2 σ 2 e . T h e te r m s in s id e th e tw o b r a c k e ts a r e th e s a m e , s o o n ly tw o c o n v o lu tio n s a r e r e q u ir e d t o im p le m e n t t h e m . U s in g t h e d e fi n it io n s in S e c t io n 1 0 .2 .1 , t h e p a r tia ls m a y b e w r itte n a s 2 @ f a n d @ 2 f 2 @ y T h e fi rs t te r m c o e ffi c ie n ts c o s a m e c o e ffi c ie h a v e th e fi n a l = 2 @ x = f (x + 1 ) + f (x − 1 ) − 2 f (x ) f (y + 1 ) + f (y − 1 ) − 2 f (y ). c a n b e im p le m e n te d v ia c o n v o lu tio n w ith a 1 × 3 m a s k h a v in g e ffi c ie n ts , [1 − 2 1 ], a n d th e s e c o n d w ith a 3 × 1 m a s k h a v in g th e n t s . L e t t i n g r x2 a n d r 2y r e p r e s e n t t h e s e t w o o p e r a t o r m a s k s , w e r e s u lt: g (x ,y ) = r 2 x G (x ) f (x ,y ) + r G (y ) 2 G (x ) y G (y ) f (x ,y ) w h ic h r e q u ir e s a to ta l o f fo u r d iffe r e n t 1 - D c o n v o lu tio n o p e r a tio n s . ( b ) If w e u s e th e a lg o r ith m a s s ta te d in th e b o o k , c o n v o lv in g a n M × N w ith a n n × n m a s k w ill r e q u ir e n 2 × M × N m u ltip lic a tio n s (s e e th e s o lu P r o b le m 1 0 .1 8 ) . T h e n c o n v o lu t io n w it h a 3 × 3 L a p la c ia n m a s k w ill a d d a 9 × M × N m u ltip lic a tio n s fo r a to ta l o f (n 2 + 9 ) × M × N m u ltip lic a tio n c o m p o s in g a 2 - D c o n v o lu tio n in to 1 - D p a s s e s r e q u ir e s 2 n M N m u ltip lic a s in d ic a t e d in t h e s o lu t io n t o P r o b le m 1 0 .1 8 . T w o m o r e c o n v o lu t io n s o f s u ltin g im a g e w ith th e 3 × 1 a n d 1 × 3 d e r iv a tiv e m a s k s a d d s 3 M N + 3 M N = m u ltip lic a tio n s . T h e c o m p u ta tio n a l a d v a n ta g e is th e n A = (n 2 + 9 )M N = 2 n M N + 6 M N im a g e tio n to n o th e r s . D e a tio n s , th e re 6 M N 2 + 9 2 n + 6 n w h ic h is in d e p e n d e n t o f im a g e s iz e . F o r e x a m p le , fo r n = 2 5 , A = 1 1 .3 2 , s o it ta k e s o n th e o r d e r o f 1 1 tim e s m o r e m u ltip lic a tio n s if d ir e c t 2 - D c o n v o lu tio n is u s e d . Problem 10.20 ( a ) T h e s o lu t io n is b a s ic a lly t h e s a m e a s in P r o b le m 1 0 .1 9 , b u t u s in g t h e 1 - D m a s k s in F ig . 1 0 .1 3 t o im p le m e n t E q s . ( 1 0 .2 - 1 2 ) a n d ( 1 0 .2 - 1 3 ) . ( b ) S m o o th in g w ith a G a u s s ia n fi lte r (s te p 1 o f th e a lg o r ith m ) r e q u ir e s c o n v o lv in g a n M × N im a g e w ith a n n × n fi lte r m a s k w ill r e q u ir e n 2 × M × N m u ltip lic a t io n s a s e x p la in e d in t h e s o lu t io n o f P r o b le m 1 0 .1 9 . T h e n t w o c o n v o lu t io n s C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 0 6 w ith a 3 × 3 h o r iz o n ta l a n d v e r tic a l e d g e d e te c to r re q u ire s 2 (9 × M × N ) = 1 8 M N m u ltip lic a tio n s , fo r a to ta l o f (n 2 + 1 8 ) × M × N m u ltip lic a tio n s . T h e m a g n itu d e im a g e r e q u ir e s tw o m u ltip lic a tio n s , o n e to c o m p u te @ f / @ x tim e s its e lf a n d @ f / @ y tim e s its e lf, fo r a to ta l o f 2 M N m u ltip lic a tio n s . T h e to ta l fo r th e 2 D a p p r o a c h is th e n (n 2 + 2 0 )M N m u ltip lic a tio n s . T h e 1 - D c o n v o lu tio n fo r s te p 1 r e q u ir e s 2 n M N m u lt ip lic a t io n s ( s e e t h e s o lu t io n t o P r o b le m , 1 0 .1 9 ) . T h e y c o m p o n e n t o f th e g r a d ie n t c a n b e im p le m e n te d u s in g th e d iffe r e n c e @ f / @ y = f (x , y + 1 ) − f (x , y ), w h ic h , a s s t a t e d in S e c t io n 1 0 .2 .5 , c a n b e im p le m e n t e d b y c o n v o lv in g th e s m o o th e d im a g e w ith a 1 - D m a s k w ith c o e ffi c ie n ts [− 1 1 ]. T h is w ill r e q u ir e 2 M N m u ltip lic a tio n s . S im ila r ly , th e o th e r p a r tia l d e r iv a tiv e c a n b e im p le m e n te d w ith a v e r tic a l m a s k w ith th e s a m e c o e ffi c ie n ts , fo r a to ta l o f 4 N M m u ltip lic a tio n s . T h e s q u a r e s a r e th e s a m e a s fo r th e 2 - D im p le m e n ta tio n : 2 M N m u ltip lic a tio n s . T h e to ta l fo r th e 1 - D im p le m e n ta tio n is th e n (2 n + 6 )M N . T h e r a tio o f 2 - D to 1 - D m u ltip lic a tio n s is A = (n 2 + 2 0 )M N (2 n + 6 )M N n = 2 + 2 0 2 n + 6 w h ic h is in d e p e n d e n t o f im a g e s iz e . W h e n , fo r e x a m p le , n = 2 5 , t h e n A = 1 1 .5 2 , s o it w o u ld ta k e a p p r o x im a te ly 1 1 tim e s m o r e m u ltip lic a tio n s to im p le m e n t th e fi r s t p a r t o f th e C a n n y a lg o r ith m w ith 2 - D c o n v o lu tio n s . Problem 10.21 P a r t s ( a ) t h r o u g h ( e ) a r e s h o w n in r o w s 2 t h r o u g h 6 o f F ig . P 1 0 .2 1 . Problem 10.22 (a ) E x p re s in g te r m s b = ρ / s in a n d b o f a re p re s e n ta s x c o s θ + y s in w ith th e s lo p e θ . T h is g iv e s θ g iv e n lin e , th e tio n o f th a t lin e (b ) θ = c o t − 1 (2 ) = 2 6 .6 ◦ θ = ρ in th in te rc e p t fo = c o t− 1 (a ) p a ra m e te rs e fo r m , a n d θ a r m y ρ n d = y = a x = b s ρ c o − (c + b in θ m p o t θ )x , g iv e . O n le te ly + ρ / s in θ s a = − (c c e o b ta in e s p e c ify th . E q u a o t θ ) a n d fro m e n o r m td a a l . a n d ρ = (1 ) s in θ = 0 .4 5 . Problem 10.23 ( a ) P o in t 1 h a s c o o r d in a t e s x = 0 a n d y = 0 . S u b s t it u t in g in t o E q . ( 1 0 .2 - 3 8 ) y ie ld s ρ = 0 , w h ic h , in a p lo t o f ρ v s . θ , is a s tr a ig h t lin e . ( b ) O n ly th e o r ig in (0 , 0 ) w o u ld y ie ld th is r e s u lt. 2 0 7 Edges and their profiles Gradient images and their profiles Laplacian images and their profiles Images fromSteps 1 and 2 of theMarr-Hildreth algorithmand their profiles Images fromSteps 1 and 2 of theCanny algorithmand their profiles Canny angleimages and their profiles F ig u r e P 1 0 .2 1 2 0 8 C H A P T E R 1 0 . P R O B L E M S O L U T IO N S ( c ) A t θ = + 9 0 ◦ , it fo llo w s fr o m E q . ( 1 0 .2 - 3 8 ) t h a t x · (0 ) + y · (1 ) = ρ , o r y = ρ . A t θ = − 9 0 ◦ , x · (0 ) + y · (− 1 ) = ρ , o r − y = ρ . T h u s th e r e fl e c tiv e a d ja c e n c y . Problem 10.24 S u b d iv id in g th e θ - a x is in to K in c r e m e n ts g iv e s , fo r e v e r y p o in t (x k , y k ), K v a lu e s o f ρ c o r r e s p o n d in g to th e K p o s s ib le v a lu e s o f θ . W ith n im a g e p o in ts , th is m e th o d in v o lv e s n K c o m p u ta tio n s . T h u s th e p r o c e d u r e is lin e a r in n . Problem 10.25 T h is p r o b le m is a n a tu r a l fo r th e H o u g h tr a n s fo r m , w h ic h is s e t u p a s fo llo w s : T h e θ a x is is d iv id e d in to s ix s u b d iv is io n s , c o r re s p o n d in g to th e s ix s p e c ifi e d d ir e c tio n s a n d th e ir e r r o r b a n d s . F o r e x a m p le (b e c a u s e th e a n g le d ir e c tio n s s p e c ifi e d in th e p r o b le m s ta te m e n t a r e w ith r e s p e c t to th e h o r iz o n ta l) th e fi r s t b a n d fo r a n g le θ e x te n d s fr o m − 3 0 ◦ to − 2 0 ◦ , c o r r e s p o n d in g to th e − 2 5 ◦ d ir e c tio n a n d p p D to ρ = + D , w h e re D is th e its ± 5 ◦ b a n d . T h e ρ a x is e x te n d s fr o m ρ = − la r g e s t d is ta n c e b e tw e e n o p p o s ite c o r n e r s o f th e im a g e , p r o p e r ly c a lib r a te d to fi t th e p a r tic u la r im a g in g s e t u p u s e d . T h e s u b d iv is io n s in th e ρ a x is a r e c h o s e n fi n e ly e n o u g h to r e s o lv e th e m in im u m e x p e c te d d is ta n c e b e tw e e n tr a c k s th a t m a y b e p a r a lle l, b u t h a v e d iffe r e n t o r ig in s , th u s s a tis fy in g th e la s t c o n d itio n o f th e p r o b le m s ta te m e n t. S e t u p in th is w a y , th e H o u g h tr a n s fo r m c a n b e u s e d a s a “ fi lte r ” to c a te g o r iz e a ll p o in ts in a g iv e n im a g e in to g r o u p s o f p o in ts in th e s ix s p e c ifi e d d ir e c tio n s . E a c h g r o u p is th e n p r o c e s s e d fu r th e r to d e te r m in e if its p o in ts s a tis fy th e c r ite r ia fo r a v a lid tr a c k : (1 ) e a c h g r o u p m u s t h a v e a t le a s t 1 0 0 p o in ts ; a n d (2 ) it c a n n o t h a v e m o r e th a n th r e e g a p s , e a c h o f w h ic h c a n n o t b e m o r e th a n 1 0 p ix e ls lo n g ( s e e P r o b le m 1 0 .3 r e g a r d in g t h e e s t im a t io n o f g a p s o f a g iv e n le n g t h ) . Problem 10.26 T h e e s s e n c e o f th e a lg o r ith m is to c o m p u te a t e a a ll p ix e ls w h o s e in te n s itie s a r e le s s th a n o r e q u a l s im ila r ly , th e m e a n v a lu e , m 2 , o f a ll p ix e ls w ith v a L e t p i = n i/ n d e n o te th e i th c o m p o n e n t o f th e th e n u m b e r o f p ix e ls w ith in te n s ity i , a n d n is th im a g e . V a lid v a lu e s o f i a r e in th e r a n g e 0 ≤ i ≤ L in te n s itie s a n d i is a n in te g e r. T h e m e a n s c a n b e c h s te p th e m e a n v a lu e , m 1 , o f to th e p r e v io u s th r e s h o ld a n d , lu e s th a t e x c e e d th e th r e s h o ld . im a g e h is to g r a m , w h e re n i is e to ta l n u m b e r o f p ix e ls in th e − 1 , w h e re L is th e n u m b e r o n c o m p u te d a t a n y s te p k o f th e 2 0 9 a lg o r ith m : I (k − 1 ) m 1 (k ) = i p / P (k ) i i = 0 w h e re I (k − 1 ) P (k ) = p i i = 0 a n d L − 1 m 2 (k ) = i p i / [1 − P (k )] . i = I (k − 1 )+ 1 T h e te r m I (k − 1 ) is th e s m a lle s t in te g e r le s s th a n o r e q u a l to T (k − 1 ), a n d T (0 ) is g iv e n . T h e n e x t v a lu e o f th e th r e s h o ld is th e n T (k + 1 ) = 2 1 [m 1 (k ) + m 2 (k )] . Problem 10.27 A s s t a t e d in S e c t io n 1 0 .3 .2 , w e a s s u m e t h a t t h e in it ia l t h r e s h o ld is c h o s e n b e tw e e n th e m in im u m a n d m a x im u m in te n s itie s in th e im a g e . T o b e g in , c o n s id e r t h e h is t o g r a m in F ig . P 1 0 .2 7 . It s h o w s t h e t h r e s h o ld a t t h e k t h it e r a t iv e s t e p , a n d th e fa c t th a t th e m e a n m 1 (k + 1 ) w ill b e c o m p u te d u s in g th e in te n s itie s g r e a te r th a n T (k ) tim e s th e ir h is to g r a m v a lu e s . S im ila r ly , m 2 (k + 1 ) w ill b e c o m p u te d u s in g v a lu e s o f in te n s itie s le s s th a n o r e q u a l to T (k ) tim e s th e ir h is to g r a m v a lu e s . T h e n , T (k + 1 ) = 0 .5 [m 1 (k + 1 ) + m 2 (k + 1 )]. T h e p r o o f c o n s is t s o f t w o p a r t s . F ir s t , w e p r o v e th a t th e th r e s h o ld is b o u n d e d b e tw e e n 0 a n d L − 1 . T h e n w e p r o v e th a t th e a lg o r ith m c o n v e r g e s to a v a lu e b e tw e e n th e s e tw o lim its . T o p r o v e t h a t t h e t h r e s h o ld is b o u n d e d , w e w r it e T (k + 1 ) = 0 .5 [m 1 (k + 1 ) + m 2 (k + 1 )]. If m 2 (k + 1 ) = 0 , th e n m 1 (k + 1 ) w ill b e e q u a l to th e im a g e m e a n , M , a n d T (k + 1 ) w ill e q u a l M / 2 w h ic h is le s s th a n L − 1 . If m 2 (k + 1 ) is z e r o , th e s a m e w ill b e tr u e . B o th m 1 a n d m 2 c a n n o t b e z e r o s im u lta n e o u s ly , s o T (k + 1 ) w ill a lw a y s b e g r e a te r th a n 0 a n d le s s th a n L − 1 . T o p r o v e c o n v e r g e n c e , w e h a v e to c o n s id e r th r e e p o s s ib le c o n d itio n s : 1 . T (k + 1 ) = T (k ), in w h ic h c a s e th e a lg o r ith m h a s c o n v e r g e d . 2 . T (k + 1 ) < T (k ), in w h ic h c a s e th e th r e s h o ld m o v e s to th e le ft. 3 . T (k + 1 ) > T (k ), in w h ic h c a s e th e th r e s h o ld m o v e s to th e r ig h t. C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 1 0 Histogram values } } 0 T (k ) Intensities used to compute m 2(k +1) Intensities used to compute m 1(k +1) Intensity L - 1 F ig u r e P 1 0 .2 7 In c a s e (2 ), w h e n th e th r e s h o ld v a lu e m o v e s to th e le ft, m 2 w ill d e c r e a s e o r s ta y th e s a m e a n d m 1 w ill a ls o d e c r e a s e o r s ta y th e s a m e (th e fa c t th a t m 1 d e c r e a s e s o r s t a y s t h e s a m e i s n o t n e c e s s a r i l y o b v i o u s . I f y o u d o n ’t s e e i t , d r a w a s i m p l e h i s to g r a m a n d c o n v in c e y o u r s e lf th a t it d o e s ), d e p e n d in g o n h o w m u c h th e th r e s h o ld m o v e d a n d o n th e v a lu e s o f th e h is to g r a m . H o w e v e r, n e ith e r th r e s h o ld c a n in c r e a s e . If n e ith e r m e a n c h a n g e s , th e n T (k + 2 ) w ill e q u a l T (k + 1 ) a n d th e a lg o r ith m w ill s to p . If e ith e r (o r b o th ) m e a n d e c r e a s e s , th e n T (k + 2 ) < T (k + 1 ), a n d th e n e w th r e s h o ld m o v e s fu r th e r to th e le ft. T h is w ill c a u s e th e c o n d itio n s ju s t s ta te d to h a p p e n a g a in , s o th e c o n c lu s io n is th a t if th e th r e s h o ld s s ta r ts m o v in g le ft, it w ill a lw a y s m o v e le ft, a n d th e a lg o r ith m w ill e v e n tu a lly s to p w ith a v a lu e T > 0 , w h ic h w e k n o w is th e lo w e r b o u n d fo r T . B e c a u s e th e th r e s h o ld a lw a y s d e c r e a s e s o r s to p s c h a n g in g , n o o s c illa tio n s a r e p o s s ib le , s o th e a lg o r ith m is g u a r a n te e d to c o n v e r g e . C a s e (3 ) c a u s e s th e th r e s h o ld to m o v e th e r ig h t. A n a r g u m e n t s im ila r to th e p r e c e d in g d is c u s s io n e s ta b lis h e s th a t if th e th r e s h o ld s ta r ts m o v in g to th e r ig h t it w ill e ith e r c o n v e r g e o r c o n tin u e m o v in g to th e r ig h t a n d w ill s to p e v e n tu a lly w ith a v a lu e le s s th a n L − 1 . B e c a u s e th e th r e s h o ld a lw a y s in c r e a s e s o r s to p s c h a n g in g , n o o s c illa tio n s a r e p o s s ib le , s o th e a lg o r ith m is g u a r a n te e d to c o n v e r g e . Problem 10.28 C o n s id e r th a n L / 2 is th e m a th e ra n g e a n im a a n d le s x im u m [0 ,L − g e w h o s e s th a n L − in te n s ity 1 ]. S u p p o in te n 1 , w le v e s e th s itie h e re l (re a t w s (o f b o th b a c k g ro u n d a n d o b L is th e n u m b e r o f in te n s ity c a ll th a t w e w o r k w ith th e in e c h o o s e th e in itia l th r e s h o ld je le te a c ts ) a v e ls a n s ity s T = re n s 0 g re a te r d L − 1 c a le in . T h e n 2 1 1 Histogram values I min } } 0 L /2 Intensities of background M Intensity L - 1 Intensities of objects F ig u r e P 1 0 .2 9 a ll p ix e ls w ill b e a s s ig n e d to c la s s 1 a n d n o n e to c la s s 2 . S o m 1 w ill b e th e m e a n v a lu e , M , o f th e im a g e a n d m 2 w ill b e z e r o b e c a u s e n o p ix e ls w ill b e a s s ig n e d to c la s s 2 . T w ill b e th e s u m o f th e tw o m e a n s d iv id e d b y 2 , o r M / 2 . H o w e v e r, th e im a g e m e a n , M , is b e tw e e n L / 2 a n d L − 1 b e c a u s e th e r e a r e n o p ix e ls w ith v a lu e s b e lo w L / 2 . S o , th e n e w th r e s h o ld , T = M / 2 w ill b e b e lo w L / 2 . B e c a u s e th e r e a r e n o p ix e ls w ith v a lu e s b e lo w L / 2 , m 2 w ill b e z e r o a g a in , a n d m 1 w ill b e th e m e a n v a lu e o f th e in te n s itie s a n d T w ill a g a in b e e q u a l to M / 2 . S o , th e a lg o r ith m w ill te r m in a te w ith th e w r o n g v a lu e o f th r e s h o ld . T h e s a m e c o n c e p t is r e s ta te d m o r e fo r m a lly a n d u s e d a s a c o u n t e r - e x a m p le in t h e s o lu t io n o f P r o b le m 1 0 .2 9 . Problem 10.29 T h e v a lu e o f th e th e th r e s h o ld a t c o n v e r g e n c e is in d e p e n d e n t o f th e in itia l v a lu e if th e in itia l v a lu e o f th e th r e s h o ld is c h o s e n b e tw e e n th e m in im u m a n d m a x im u m in t e n s it y o f t h e im a g e ( w e k n o w fr o m P r o b le m 1 0 .2 7 t h a t t h e a lg o r it h m c o n v e r g e s u n d e r th is c o n d itio n ). T h e fi n a l th r e s h o ld is n o t in d e p e n d e n t o f th e in itia l v a lu e c h o s e n fo r T if th a t v a lu e d o e s n o t s a tis fy th is c o n d itio n . F o r e x a m p le , c o n s id e r a n im a g e w it h t h e h is t o g r a m in F ig . P 1 0 .2 9 . S u p p o s e t h a t w e s e le c t th e in itia l th r e s h o ld T (1 ) = 0 . T h e n , a t th e n e x t ite r a tiv e s te p , m 2 (2 ) = 0 , m 1 (2 ) = M , a n d T (2 ) = M / 2 . B e c a u s e m 2 (2 ) = 0 , it fo llo w s th a t m 2 (3 ) = 0 , m 1 (3 ) = M , a n d T (3 ) = T (2 ) = M / 2 . A n y fo llo w in g ite r a tio n s w ill y ie ld th e s a m e r e s u lt, s o th e a lg o r ith m c o n v e r g e s w ith th e w r o n g v a lu e o f th r e s h o ld . If w e h a d s t a r t e d w i t h I m in < T ( 1 ) < I m a x , t h e a lg o r i t h m w o u ld h a v e c o n v e r g e d p r o p e r ly . C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 1 2 Problem 10.30 ( a ) F o r a u n ifo r m h is to g r a m , w e c a n v ie w th e in te n s ity le v e ls a s p o in ts o f u n it m a s s a lo n g th e in te n s ity a x is o f th e h is to g r a m . A n y v a lu e s m 1 (k ) a n d m 2 (k ) a r e th e m e a n s o f th e tw o g r o u p s o f in te n s ity v a lu e s G 1 a n d G 2 . B e c a u s e th e h is to g r a m is u n ifo r m , th e s e a re th e c e n te r s o f m a s s o f G 1 a n d G 2 . W e k n o w fr o m th e s o lu t io n o f P r o b le m 1 0 .2 7 t h a t if T s t a r t s m o v in g t o t h e r ig h t , it w ill a lw a y s m o v e in th a t d ir e c tio n , o r s to p . T h e s a m e h o ld s tr u e fo r m o v e m e n t to th e le ft. N o w , a s s u m e th a t T (k ) h a s a r r iv e d a t th e c e n te r o f m a s s (a v e r a g e in te n s ity ). B e c a u s e a ll p o in ts h a v e e q u a l " w e ig h t" (r e m e m b e r th e h is to g r a m is u n ifo r m ), if T (k + 1 ) m o v e s to th e r ig h t G 2 w ill p ic k u p , s a y , Q n e w p o in ts . B u t G 1 w ill lo s e th e s a m e n u m b e r o f p o in ts , s o th e s u m m 1 + m 2 w ill b e th e s a m e a n d th e a lg o r ith m w ill s to p . (b ) T h e r ith m a o ld to w to lo s e s to p . p r o v e is s im ila r to (a ) b e c a u s e r r iv e s a t th e p o in t b e tw e e n th e a r d o n e o r th e o th e r m e a n w ill th e s a m e " m a s s " . T h u s , th e ir s u th tw c a m e m o d o m e a u s e o n w ill b e e s a re n s , fu r e g ro u th e s a id th p m e n tic a l. e r m o tio to p ic k u e a n d th W h e n th e a n o f th e th r p a n d th e o e a lg o r ith m lg e s th w o h e r ill Problem 10.31 (a ) A 1 = A 2 a n d σ 1 = σ 2 = σ , w h ic h m a k e s th e tw o m o d e s id e n tic a l [th is is th e s a m e a s P r o b le m 1 0 .3 0 ( b ) ]. ( b ) Y o u k n o w fr o m P r o b le m 1 0 tic a l, th e a lg o r ith m w o u ld c o n In th e p r e s e n t p r o b le m , th e m o T h e n , a ll w e c a n s a y is th a t th e a tw e e n th e m e a n s (fr o m S e c tio n s o m e p o in t b e tw e e n th e m in im A 1 a n d A 2 a re g re a te r th a n 0 , w a p o in t s o m e w h e re b e tw e e n m (c ) σ 1 > > σ 2 .3 0 t h a t if t h e m o d e s w e r e s y m m e t r ic a n d id e n v e r g e to th e p o in t m id w a y b e w te e n th e m e a n s . d e s a r e s y m m tr ic b u t th e y m a y n o t b e id e n tic a l. lg o r ith m w ill c o n v e r g e to a p o in t s o m e w h e r e b e 1 0 .3 .2 w e k n o w t h a t t h e a lg o r it h m m u s t s t a r t a t u m a n d m a x im u m im a g e in te n s itie s ). S o , if b o th e a r e a s s u r e d th a t th e a lg o r ith m w ill c o n v e r g e to 1 a n d m 2 . . T h is w ill ” p u ll” t h e t h r e s h o ld t o w a r d m 1 d u r in g ite r a tio n . 2 1 3 Problem 10.32 (a ) σ 2 = P 1 (m = P 1 (m = P 1 [m = P 1 [P 2 m = P 1 P = (m B = = (m 1 − m (m 1 )2 + P 2 P 2 2 2 ) [P 1 P 2 (P − m 1 w e u s e d th e fa c ts th a t m p a r t o f E q . ( 1 0 .3 - 1 5 ) . G ) 2 2 2 − (P 1 m 2 ]2 + P 2 [m 2 (m 1 + P 2 P 2 2 )]2 + P 2 [m 2 ) − P 2 m 2 2 ) G ]2 + P 2 [P 1 m 2 )2 [P 1 P 2 P 1 P 2 (m (1 − P − m 1 − m 1 − m 2 + P 2 m 1 − P 2 m 1 − m 1 )2 + P 2 (m G − (P 1 m 1 2 2 − m 1 − P 1 m 2 − m 1 ) 2 − P 1 m 2 1 + P 2 m 1 ] 1 + P 2 m 1 2 m (k ) = a n d P 2 + P 1 = 1 . T h is p r o v e s th e fi r s t 2 − m (k ) . 1 − P 1 (k ) G L − 1 P 2 (k ) i p L − 1 i p 1 − P 1 (k ) ⎡ ⎣ 1 − P 1 (k ) = i i = k + 1 1 m i i = k + 1 1 = L − 1 ⎤ k i p i i p i⎦ − i = 0 i = 0 − m (k ) . 1 − P 1 (k ) G T h e n , σ 2 = P 1 P 2 (m = P 1 P = P 1 (1 − P 1 ) B = 2 ] 1 1 = (1 − P 1 )] + P 1 )] 2 = P 1 m = 2 2 T h is w e d o a s fo llo w s : (k ) 2 2 m 2 )] 2 (b ) F ir s t, w e h a v e to s h o w th a t m − m 2 2 1 − m m − P 1 m 2 ) 2 − m 1 − P 1 G m − P 1 m G P 1 (1 − P 1 ) (m G P 1 − m )2 . P 1 (1 − P 1 ) 2 2 C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 1 4 Problem 10.33 F r o m , E q . ( 1 0 .3 - 1 5 ) , σ A s s ta te d m 1 = m 2 s ta n t), in c a s e , P 1 (k o n p o s itiv s o m e v a lu in w w )[ e e th e h ic h h ic h 1 − P a n d o f k 2 = P 1 (k )P = P 1 (k )[1 − P 1 (k )][m B (k )[m 2 (k ) − m 1 1 2 (k )] 2 (k ) − m (k )] 2 b o o k , t h e m e a s u r e σ 2B ( o r η ) t a k e s a m i n i m u im p lie s th a t th e r e is o n ly o n e c la s s o f p ix e ls c a s e P 1 (k ) = 1 o r P 1 (k ) = 0 fo r s o m e v a lu e 1 ( k ) ] > 0 o r , e q u iv a le n t ly , f o r 0 < P 1 ( k ) < 1 , s o b o u n d e d v a lu e s , a n d a fi n ite m a x im u m is g u a if th e im a g e is n o t c o n s ta n t. 2 m v a lu e o f 0 w h e n (th e im a g e is c o n o f k . In a n y o th e r th e m e a s u re ta k e s r a n te e d to e x is t fo r Problem 10.34 F r o m t h e d e fi n it io n in E q . ( 1 0 .3 - 1 2 ) , η = w h e re σ 2 B σ σ 2 B 2 G = P 1 (m 1 − m G )2 + P 2 (m = P 1 P 2 (m 1 − m 2 )2 − m 2 G ) 2 a n d L − 1 σ 2 G = (i − m G )2 p i . i = 0 A s i n t h e t e x t , w e h a v e o m i t t e d k i n σ 2B f o r t h e s a k e o f n o t a t i o n a l c l a r i t y , b u t t h e a s s u m p tio n is th a t 0 ≤ k ≤ L − 1 . A s e x p la in e d in th e b o o k , th e m in im u m v a lu e o f η is z e r o , a n d it o c c u r s w h e n th e im a g e is c o n s ta n t. It re m a in s to b e s h o w n th a t th e m a x im u m v a lu e is 1 , a n d th a t it o c c u r s fo r tw o - v a lu e d im a g e s w ith v a lu e s 0 a n d L − 1 . F r o m t h e s e c o n d l i n e o f t h e e x p r e s s i o n f o r σ 2B w e s e e t h a t t h e m a x i m u m o c c u r s w h e n th e q u a n tity (m 1 − m 2 )2 is m a x im u m b e c a u s e P 1 a n d P 2 a re p o s itiv e . T h e in te n s ity s c a le e x te n d s fr o m 0 to L − 1 , s o th e m a x im u m d iffe r e n c e b e tw e e n m e a n s o c c u r s w h e n m 1 = 0 a n d m 2 = L − 1 . B u t th e o n ly w a y th is c a n h a p p e n is if th e v a r ia n c e o f th e tw o c la s s e s o f p ix e ls is z e r o , w h ic h im p lie s th a t th e im a g e o n ly h a s th e s e tw o v a lu e s , th u s p r o v in g th e a s s e r tio n th a t th e m a x im u m o c c u r s o n ly w h e n th e im a g e is tw o - v a lu e d w ith in te n s ity v a lu e s 0 a n d L − 1 . It r e m a in s to b e s h o w n th a t th e m a x im u m p o s s ib le v a lu e o f η is 1 . 2 1 5 W h e n m 1 = 0 a n d m = L − 1 , 2 2 σ = P 1 P 2 (m = P 1 P 2 (L − 1 )2 . B − m 1 2 ) 2 F o r a n im a g e w ith v a lu e s 0 a n d L − 1 , L − 1 2 G σ = (i − m G )2 p (i − m G )2 P i i = 0 L − 1 k = + 1 i = 0 = (i − m )2 P G 2 i = k + 1 (0 − m )2 P G + (L − 1 − m 1 )2 P G 2 F r o m E q . ( 1 0 .3 - 1 0 ) m G = P 1 m 1 + P 2 m = P 2 (L − 1 ). 2 S o , σ 2 G = (0 − m = P 2 2 G )2 P 2 (L − 1 ) P 2 = (L − 1 ) (P = = + (L − 1 − m 1 2 2 P 1 2 (L − 1 ) P 2 P 1 (P P 2 P 1 (L − 1 ) )2 P 2 + (L − 1 ) (1 − P 2 )2 P 1 2 G + P 2 2 1 2 P 2 ) + P 1 ) 2 w h e r e w e u s e d t h e f a c t t h a t P 1 + P 2 = 1 . W e s e e f r o m t h e p r e c e d i n g r e s u l t s f o r σ 2B a n d σ G2 t h a t σ 2B / σ G2 = 1 w h e n t h e i m a g e i s t w o - v a l u e d w i t h v a l u e s 0 a n d L − 1 . T h is c o m p le te s th e p r r o f. Problem 10.35 (a ) L e t R 1 a n d R 2 a n d le s s o r e q u a l s o it g e ts m a p p e d in R 1 a re m a p p e d is th a t a ll v a lu e s T 0. T h e s e n s e o f in te n s itie s in th e d e n o to T , r b y th t o R 10 i n R 10 th e in tw o re te th e re g io n s w h o s e p ix e l in te n s itie s a re g re a te r th a n T e s p e c tiv e ly . T h e th r e s h o ld T is s im p ly a n in te n s ity v a lu e , e tr a n s fo r m a tio n fu n c tio n to th e v a lu e T 0 = 1 − T . V a lu e s a n d v a l u e s i n R 2 a r e m a p p e d t o R 20 . T h e i m p o r t a n t t h i n g a r e b e l o w T 0 a n d a l l v a l u e s i n R 20 a r e e q u a l t o o r a b o v e e q u a litie s h a s b e e n r e v e r s e d , b u t th e s e p a r a b ility o f th e g io n s h a s b e e n p re s e r v e d . ( b ) T h e s o lu tio n in (a ) is a s p e c ia l c a s e o f a m o r e g e n e r a l p r o b le m . A th r e s h o ld is s im p ly a lo c a tio n in th e in te n s ity s c a le . A n y tr a n s fo r m a tio n fu n c tio n th a t C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 1 6 p (z ) 0 60 170 255 z F ig u r e P 1 0 3 6 p r th s e c e e s re r v s s e r v e s th e o rd e r o f s h o ld . T h u s , a n y e th is o rd e r. T h e v e d w ith th e tr a n s f in te n s itie m o n o to n a lu e o f th o r m a tio n s w ill p r e s e r v e th e s e p a r a b iliy e s ta b lis h e d b y th e ic fu n c tio n (in c r e a s in g o r d e c r e a s in g ) w ill p r e e n e w th r e s h o ld is s im p ly th e o ld th r e s h o ld p r o fu n c tio n . Problem 10.36 W ith re fe s ta n d a rd o f th e im tio n 1 0 .3 9 0 % s p e c re n c e d e v ia a g e is .2 o r ifi c a t to F tio n w id O ts u io n . ig . P 1 0 .3 6 , t h e k e y is t o n o t e t h a t t h e s a p a r t, s o th e v a lle y b e tw e e n th e tw o e a n d d e e p . T h e s im p le g lo b a l th r e s h ’s a l g o r i t h m w i l l g i v e a p e r f o r m a n c e In fa c t, th e s o lu tio n w ill g iv e c lo s e to m e a n m o d o ld in th a t 1 0 0 % s a re m o re e s o f th e h is g a lg o r ith m e a s ily e x c e a c c u ra c y . th a n to g r o f S e d s 1 0 a m e c th e Problem 10.37 ( a ) T h e fi r s t c o lu m n w o u ld b e b la c re a s o n : A p o in t in th e s e g m e n te d th a t p o in t e x c e e d s b a t th a t p o in t. g r e a te r th a n 0 w ill b e s e t to 1 a n d a p o in ts in th e im a g e th a t d o n o t e x c p o in ts in th e fi r s t c o lu m n . k a n d im a g e B u t b ll o th e e e d 0 a ll o th e r c o lu m is s e t to 1 if th = 0 , s o a ll p o in r p o in ts w o u ld a re th e p o in ts t n s w o e v a lu ts in t b e s e t h a t a r u ld b e e o f th h e im a to 0 . B e 0 , w h w h ite . T h e e im a g e a t g e th a t a re u t th e o n ly ic h a re th e ( b ) T h e r ig h tm o s t c o lu m n w o u ld b e 0 a n d a ll o th e r s w o u ld b e 1 , fo r th e r e a s o n s ta te d in (a ). 2 1 7 ( c ) A s in (a ), a ll th e p ix e ls in th e fi r s t c o lu m n o f 0 . C o n s id e r a ll o th e r p ix e ls in th e fi r s t r o w o f t m in d th a t n = 2 a n d b = 1 . B e c a u s e th e r a m in in te n s ity to th e r ig h t, th e v a lu e o f a p ix e l a t g re a te r th a n th e (m o v in g ) a v e r a g e o f th a t p ix p o in ts a lo n g th e fi r s t r o w , w ith th e e x c e p tio n th e s c a n re a c h e s th e e n d o f th e fi rs t ro w a n d s e c o n d r o w , th e r e v e r s e c o n d itio n w ill e x is t a n o f th e s e g m e n te d im a g e w ill b e la b e le d 0 . T h th e s a m e a s in th e fi r s t r o w , s o th e n e t e ffe c t c o n s is t o f a ll 0 s in th e fi r s t c o lu m n , a n d a ll 0 s th e s e c o n d . A ll o th e r p ix e ls w ill b e 1 . th e s e g m e n te d im a g e a r e la b e le d h e s e g m e n te d im a g e a n d k e e p in p in th e o r ig in a l im a g e in c re a s e s lo c a tio n k in th e im a g e is a lw a y s e l a n d its p r e d e c e s s o r. T h u s , a ll o f th e fi r s t a r e la b e le d 1 . W h e n re v e r s e s d ire c tio n a s it s ta r ts th e d a ll p ix e ls a lo n g th e s e c o n d r o w e c o n d itio n s in th e th ird r o w a re is th a t th e s e g m e n te d im a g e w ill in a lte r n a tin g r o w s , s ta r tin g w ith ( d ) T h e fi r s t p ix e l in th e fi r s t r o w o f th e s e g m e n te d p ix e l w ill b e 0 a n d th e r e s t w ill b e 1 s fo r th e re a s o n s ta te d in (a ). H o w e v e r, in s u b s e q u e n t r o w s th e c o n d itio n s c h a n g e . C o n s id e r th e c h a n g e in d ire c tio n b e tw e e n th e e n d o f th e fi r s t r o w a n d th e r e v e r s e s c a n o f th e s e c o n d r o w . B e c a u s e n is n o w m u c h g r e a te r th a n 2 , it w ill ta k e “ a w h ile " b e fo r e th e e le m e n ts in th a t r o w o f th e o r ig in a l im a g e w ill b e c o m e s m a lle r th a n th e n r u n n in g a v e r a g e , w h ic h r e a c h e d is h ig h e s t v a lu e a t th e e n d o f th e fi r s t r o w . T h e r e s u lt w ill b e K w h ite p ix e ls b e fo r e th e v a lu e s in th e o r ig in a l im a g e d r o p b e lo w th e r u n n in g a v e r a g e a n d th e p ix e ls in th e s e g m e n te d im a g e b e c o m e b la c k . T h is c o n d itio n is r e v e r s e d w h e n th e tu r n is m a d e fr o m th e s e c o n d to th e th ir d r o w . K b la c k p ix e ls w ill n o w b e p r e s e n t in th e fi r s t r o w b e fo r e th e v a lu e s in th e o r ig in a l im a g e in c r e a s e p a s t th e r u n n in g a v e r a g e . O n c e th e y d o , th e c o r r e s p o n d in g lo c a tio n s in th e s e g m e n te d r e g io n w ill b e la b e le d w h ite th r o u g h th e e n d o f th a t r o w . T h e s e g m e n te d im a g e w ill th u s lo o k a s fo llo w s : T h e fi r s t p ix e l in th e fi r s t r o w w ill b e b la c k a n d a ll o th e r s w ill b e w h ite . T h e n e x t r o w w ill h a v e a K b la c k p ix e ls o n th e le ft a n d K w h ite p ix e ls o n th e r ig h t, w ith a ll o th e r p ix e ls b e in g b la c k . T h e le ft a n d r ig h t o f th e n e x t r o w w ill b e th e s a m e , b u t th e p ix e ls in b e tw e e n w ill b e w h ite . T h e s e tw o a lte r n a tin g r o w p a tte r n s a r e a p p lic a b le to th e re s t o f th e r o w s in th e s e g m e n te d im a g e . Problem 10.38 T h e m e a n s a re a te n s ity le v e ls . A ra n g e a b o u t 1 7 0 in te n s ity p o p u la th e o b je c ts is q u to a s e e d a n y p ix t 6 0 a n d 1 ra n g e o f g iv e s [1 4 0 tio n s . S o ite a d e q u e l th a t is 8 7 0 , a ± 3 σ 2 0 0 ] c h o o a te . -c o n n d th e s ta n d a rd a b o u t 6 0 g iv e s th s o s ig n ifi c a n t s e p s in g 1 7 0 a s th e s O n e a p p r o a c h is n e c te d to a n y p ix d e e a r e e to e l v ia tio n o f t ra n g e [3 0 , a tio n e x is ts d v a lu e fr o g r o w re g io p r e v io u s ly h e n o is e is 1 0 in 9 0 ] a n d a s im ila r b e tw e e n th e tw o m w h ic h to g r o w n s b y a p p e n d in g a p p e n d e d to th a t C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 1 8 s e e d , a n d w h o s e in te n s ity is 1 7 0 ± 3 σ . Problem 10.39 T h e r e g io n s p lit t in g is s h o w n in F ig . P 1 0 .3 9 ( a ) . T h e c o r r e s p o n d in g q u a d t r e e is s h o w n in F ig . P 1 0 .3 9 ( b ) . Problem 10.40 T o o b ta in th e s p a r s e o u te r r e g io n w e s im p ly fo r m th e A N D o f th e m a s k w ith th e o u te r r e g io n . B e c a u s e th e m a s k c o m p le te ly s e p a r a te s th e in n e r r e g io n fr o m th e b a c k g r o u n d , its c o m p le m e n t w ill p r o d u c e tw o d is jo in t r e g io n s . W e fi n d th e s e tw o r e g io n s b y s im p ly b y u s in g a c o n n e c te d - c o m p o n e n ts a lg o r ith m (s e e S e c tio n 9 .5 .3 ) . W e t h e n id e n t ify t h e r e g io n c o n t a in in g t h e b a c k g r o u n d b y d e t e r m in in g w h ic h o f th e tw o r e g io n s c o n ta in s a t le a s t o n e p o in t o n th e b o u n d a r y o f th e im a g e (s a y , a n y o n e o f th e fo u r c o r n e r p o in ts ). W e th e n A N D a n im a g e c o n ta in in g o n ly th is r e g io n w ith th e o r ig in a l to o b ta in th e b a c k g r o u n d . A N D in g th e o th e r r e g io n w ith th e im a g e is o la te s o n ly th e in n e r r e g io n . Problem 10.41 ( a ) T h e e le m e n ts o f T [n ] a r e th e c o o r d in a te s o f p o in ts in th e im a g e b e lo w th e p la n e g (x , y ) = n , w h e r e n is a n in te g e r th a t r e p r e s e n ts a g iv e n s te p in th e e x e c u tio n o f th e a lg o r ith m . B e c a u s e n n e v e r d e c r e a s e s , th e s e t o f e le m e n ts in T [n − 1 ] is a s u b s e t o f th e e le m e n ts in T [n ]. In a d d itio n , w e n o te th a t a ll th e p o in ts b e lo w th e p la n e g (x , y ) = n − 1 a r e a ls o b e lo w th e p la n e g (x , y ) = n , s o th e e le m e n ts o f T [n ] a r e n e v e r r e p la c e d . S im ila r ly , C n (M i ) is fo r m e d b y th e in te r s e c tio n o f C (M i ) a n d T [n ], w h e r e C (M i ) (w h o s e e le m e n ts n e v e r c h a n g e ) is th e s e t o f c o o r d in a te s o f a ll p o in ts in th e c a tc h m e n t b a s in a s s o c ia te d w ith re g io n a l m in im u m M i . B e c a u s e th e e le m e n ts o f C (M i ) n e v e r c h a n g e , a n d th e e le m e n ts o f T [n ] a r e n e v e r r e p la c e d , it fo llo w s th a t th e e le m e n ts in C n (M i ) a r e n e v e r r e p la c e d e ith e r. In a d d itio n , w e s e e th a t C n − 1 (M i ) ⊆ C n (M i ). (b c a e v th th ) T h is p u s e (1 ) e r r e p la e n u m b e s a m e . a r t o f th e p n a lw a y s in c e d ; a n d (3 e r o f e le m e r o b le c re a s ) T [n n ts o m is a e s ; (2 ) − 1 ] ⊆ f b o th n s w e re d b y th e s a m e th e e le m e n ts o f n e ith T [n ] a n d C n − 1 (M i) ⊆ C n (M i ) a n d T [n ] e ith a rg u m e n e r C n (M C n (M i) e r in c re a t a s in (a i ) n o r T [ , it fo llo w s e s o r re ). B e n ] a r s th a m a in e t s 2 1 9 1 2 11 12 13 14 21 22 23 32 24 41 321 322 411 412 323 324 413 414 42 31 33 34 43 44 4 3 4 1 11 12 13 41 14 411 2 21 22 412 42 413 43 44 414 3 23 24 31 321 32 322 33 323 34 324 F ig u r e P 1 0 .3 9 Problem 10.42 U s in g th e te r m in o lo g y o f th tw e e n tw o c a tc h m e n t b a s in s H o w e v e r, th e h e a r t o f th e a lg te n s ity le v e l in th e im a g e a n th e e n tire to p o g r a p h y is e n c is a b re a k th a t c a u s e s w a te r b o u n d a r ie s a r e p r e c is e ly th e a lg o r ith m a lw a y s p r o d u c e s c e w a te r s h e d a lg o r ith m , w o u ld c a u s e w a te r b e tw o r ith m is to b u ild a d a m y tim e a b re a k in s u c h b lo s e d b y s u c h a d a m , d a to m e rg e b e tw e e n tw o to p s o f th e d a m s , s o it lo s e d b o u n d a r ie s . a b re a k in a b o u n d a r y b e e e n th e tw o b a s in s to m e r g e . h ig h e r th a n th e h ig h e s t in o u n d a r ie s o c c u r s . B e c a u s e m s a r e b u ilt a n y tim e th e r e re g io n s , a n d s e g m e n ta tio n fo llo w s th a t th e w a te r s h e d 2 2 0 C H A P T E R 1 0 . P R O B L E M S O L U T IO N S F ig u r e P 1 0 .4 3 2 2 1 Problem 10.43 T h e fi r s t s te p in th e b u ild a d a m o f h e ig e n d s o f th e fu n c tio n b u ild a b o x o f h e ig h s e ttin g C [1 ] = T [1 ]. th e w a te r le v e l). T h q 1 = f g (2 )g . Q b c d e b a a p p lic a tio n o f th h t m a x + 1 to p re , a s s h o w n in F ig . t m a x + 1 a ro u n d In th is c a s e , T [1 ] e r e is o n ly o n e c N e x t, w e le t n = 2 a n d , a s [2 ] = f q 1 ;q 2 g , w h e r e , fo r c la r y s e m ic o lo n s . W e s ta r t c o n o m p o n e n t in Q [2 ]. W h e n q itio n 2 is s a tis fi e d a n d , th e re m p ty s e t) s o c o n d itio n 1 is s e c o m e s C [2 ] = f g (2 ); g (1 4 )g r e s e p a r a te d b y s e m ic o lo n s . W h e n n f 2 ,3 ;1 0 ,1 1 ; P r o c e e d in g in to th e n e d itio n 1 a n tio n 2 a n d f 2 ,3 ;1 0 ,1 1 ; = 1 3 a w d C 1 3 3 [F ig . P 1 0 .4 ,1 4 g w h e re , s a b o v e , q 1 \ s e t to y ie ld C [3 ] = f 2 ,3 [3 ] = f 2 ,3 ;1 ,1 4 g . e w v e n P 1 0 its = o n n a te r s h e d s e g m e n ta tio n t th e r is in g w a te r fr o m .4 3 ( b ) . F o r a n im a g e fu n b o r d e r. T h e a lg o r ith m g (2 ) , a s s h o w n in F ig . e c te d c o m p o n e n t in th s h o w n in F ig . P 1 0 .4 3 ( d ) , ity , d iffe re n t c o n n e c te d c o s tr u c tio n o f C [2 ] b y c o n s = q 1 , th e te r m q \ C [1 ] is fo re , C [2 ] = f g (2 )g . W h e n a tis fi e d a n d w e in c o r p o r a w h e re , a s a b o v e , d iffe re n t a lg o r ith m is to r u n n in g o ff th e c tio n w e w o u ld is in itia liz e d b y P 1 0 .4 3 ( c ) ( n o t e is c a s e : Q [1 ] = T [2 ] = f g (2 ), g (1 4 )g a n d m p o n e n ts a re s e p a ra te d id e r in g e a c h c o n n e c te d e q u a l to f g (2 )g , s o c o n q = q 2 , q \ C [1 ] = ; (th e te q in C [2 ], w h ic h th e n c o n n e c te d c o m p o n e n ts 3 (e )], T [3 ] = f 2 ,3 ,1 0 ,1 1 ,1 3 ,1 4 g a n d Q [3 ] = in o r d e r to s im p lify th e n o ta tio n w e le t k C [2 ] = f 2 g s a tis fi e s c o n d itio n 2 , s o q 1 is C [3 ] = f 2 , 3 ; 1 4 g . S im ila r ly , q 2 \ C [2 ] = ; ; 1 0 , 1 1 ; 1 4 g . F in a lly , q 3 \ C [2 ] = f 1 4 g s a 0 , 1 1 ; 1 3 , 1 4 g . It is e a s ily v e r ifi e d th a t C fq 1 ;q 2 ;q 3 g = d e n o te g (k ). in c o r p o r a te d s a tis fi e s c o n tis fi e s c o n d i[4 ] = C [3 ] = W h e n n = 5 [F ig . P 1 0 .4 3 ( f ) ], w e h a v e , T [5 ] = f 2 , 3 , 5 , 6 , 1 0 , 1 1 , 1 2 , 1 3 , 1 4 g a n d Q [5 ] = f q 1 ;q 2 ;q 3 g = f 2 ,3 ;5 ,6 ;1 0 ,1 1 ,1 2 , 1 3 ,1 4 g (n o te th e m e r g in g o f tw o p re v io u s ly d is tin c t c o n n e c te d c o m p o n e n ts ). Is is e a s ily v e r ifi e d th a t q 1 \ C [4 ] s a tis fi e s c o n d itio n 2 a n d th a t q 2 \ C [4 ] s a tis fi e d c o n d itio n 1 . P r o c e e d in g w ith th e s e tw o c o n n e c te d c o m p o n e n ts e x a c tly a s a b o v e y ie ld s C [5 ] = f 2 , 3 ; 5 , 6 ; 1 0 , 1 1 ; 1 3 , 1 4 g u p to th is p o in t. T h in g s g e t m o re in te re s tin g w h e n w e c o n s id e r q 3 . N o w , q 3 \ C [4 ] = f 1 0 ,1 1 ;1 3 ,1 4 g w h ic h , b e c u a s e it c o n ta in s tw o c o n n e c te d c o m p o n e n ts o f C [4 ], s a tis fi e s c o n d itio n 3 . A s m e n tio n e d p r e v io u s ly , th is is a n in d ic a tio n th a t w a te r fr o m tw o d iffe r e n t b a s in s h a s m e r g e d a n d a d a m m u s t b e b u ilt to p r e v e n t th is c o n d itio n . D a m b u ild in g is n o th in g m o r e th a n s e p a r a tin g q 3 in to th e tw o o r ig in a l c o n n e c te d c o m p o n e n ts . In th is p a r tic u la r c a s e , th is is a c c o m p lis h e d b y th e d a m s h o w n in F ig . P 1 0 .4 3 ( g ) , s o t h a t n o w q 3 = f q 3 1 ; q 3 2 g = f 1 0 , 1 1 ; 1 3 , 1 4 g . T h e n , q 3 1 \ C [4 ] a n d q 3 2 \ C [4 ] e a c h s a tis fy c o n d itio n 2 a n d w e h a v e th e fi n a l r e s u lt fo r n = 5 , C [5 ] = f 2 ,3 ;5 ,6 ;1 0 ,1 1 ;1 3 ;1 4 g . C o n tin u in g in th e m a n n e r ju s t e x p la in e d y ie ld s th e fi n a l s e g m e n ta tio n r e s u lt s h o w n in F ig . P 1 0 .4 3 ( h ) , w h e r e t h e “ e d g e s ” a r e v is ib le ( fr o m t h e t o p ) ju s t a b o v e C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 2 2 F ig u r e P 1 0 .4 4 th e w a te r lin e . A fi n a l p o s t- p r o c e s s in g s te p w o u ld r e m o v e th e o u te r d a m w a lls to y ie ld th e in n e r e d g e s o f in te r e s t. Problem 10.44 W ith re fe re n c e a p o s itiv e , r a th th e p o s itiv e A D T h e im a g e o n t it h e re fo r c o n v to e r I [ h e e n E q . ( 1 0 .6 - 4 ) , w e s e e th a n a n e g a tiv e , th r s e e E q . ( 1 0 .6 - 3 ) ]. T h r ig h t is th e p o s itiv e ie n c e in m a k in g th e th a t c o m p a r in e s h o ld w o u ld y e r e s u lt is s h o w A D I fr o m F ig . 1 c o m p a r is o n . g ie n 0 th ld in .5 9 e n th th (b e g a tiv e e im a g e e le ft o f ). W e h a A D n e F ig v e I a g a g a tiv . P 1 0 in c lu in s t e o f .4 4 . d e d Problem 10.45 ( a ) T r u e , a s s u m in g th a t th e th r e s h o ld is n o t s e t la r g e r th a n a ll th e d iffe r e n c e s e n c o u n te r e d a s th e o b je c t m o v e s . T h e e a s ie s t w a y to s e e th is is to d r a w a s im p le r e fe r e n c e im a g e , s u c h a s th e w h ite r e c ta n g le o n a b la c k b a c k g r o u n d . L e t th a t r e c ta n g le b e th e o b je c t th a t m o v e s . B e c a u s e th e a b s o lu te A D I im a g e v a lu e a t a n y lo c a tio n is th e a b s o lu te d iffe r e n c e b e tw e e n th e r e fe r e n c e a n d th e n e w im a g e , it is e a s y to s e e th a t a s th e o b je c t e n te r s a r e a s th a t a r e b a c k g r o u n d in th e r e fe r e n c e im a g e , th e a b s o lu te d iffe r e n c e w ill c h a n g e fr o m z e r o to n o n z e r o a t th e n e w a r e a o c c u p ie d b y th e m o v in g o b je c t. T h u s , a s lo n g a s th e o b je c t m o v e s , th e d im e n s io n o f th e a b s o lu te A D I w ill g r o w . (b ) T in g o n e v e [a s s u th a n r u e . T b je c t r e x c e m in g th e o h e b e e d , a b je p o s itiv e c a u s e th th e th re s in E q . c t]. A D I is s ta tio n e d iffe re n c e s b s h o ld in a r e a s ( 1 0 .6 - 3 ) , t h a t a r y e tw th a th e a n e e t a b d e q n th re b a c k g u a e r a c ro l to e fe r k g ro u n d th e e n c u n h a d im e n s e a n d th d in th e s lo w e r io e re in n s o f t m o v in fe re n c te n s it h e m o g o b je e im a y v a lu v c t g e e s 2 2 3 ( c ) T r u e . F r o m E q . ( 1 0 .6 - 4 ) , w e s e e t h a t d iffe r e n c e s b e t w e e n t h e b a c k g r o u n d a n d t h e o b je c t a lw a y s w ill b e n e g a t iv e [a s s u m in g , a s in E q . ( 1 0 .6 - 4 ) , t h a t t h e in te n s ity le v e ls in th e o b je c t e x c e e d th e v a lu e o f th e b a c k g r o u n d ]. A s s u m in g a ls o th a t th e d iffe r e n c e s a r e m o r e n e g a tiv e th a n th e th r e s h o ld , w e s e e fo r th e s a m e r e a s o n a s in (a ) th a t a ll n e w b a c k g r o u n d a r e a s o c c u p ie d b y th e m o v in g o b je c t w ill h a v e n o n z e r o c o u n ts , th u s in c r e a s in g th e d im e n s io n o f th e n o n z e r o e n tr ie s in th e n e g a tiv e A D I (k e e p in m in d th a t th e v a lu e s in th is im a g e a r e c o u n ts ). Problem 10.46 C o n s id e r fi r s t th e fa c t th a t m o tio n in th e x - d ir e c tio n is z e r o . W h e n a ll c o m p o n e n ts o f a n im a g e a re s ta tio n a r y , g x (t ,a 1 ) is a c o n s ta n t, a n d its F o u r ie r tr a n s fo r m y ie ld s a n im p u ls e a t t h e o r ig in . T h e r e fo r e , F ig . 1 0 .6 3 w o u ld n o w c o n s is t s o f a s in g le im p u ls e a t th e o r ig in . T h e o th e r tw o p e a k s s h o w n in th e fi g u r e w o u ld n o lo n g e r b e p r e s e n t. T o h a n d le th e m o tio n in th e p o s itiv e y - d ir e c tio n a n d its c h a n g e in th e o p p o s ite d ir e c tio n , r e c a ll th a t th e F o u r ie r tr a n s fo r m is a lin e a r p r o c e s s , s o w e c a n u s e s u p e r p o s itio n to o b ta in a s o lu tio n . T h e fi r s t p a r t o f m o tio n is in th e p o s itiv e y - d ir e c tio n a t 1 p ix e l/ fr a m e . T h is is th e s a m e a s in E x a m p le 1 0 .2 8 , s o t h e p e a k s c o r r e s p o n d in g t o t h is p a r t o f t h e m o t io n a r e t h e s a m e a s t h e o n e s s h o w n in F ig . 1 0 .6 4 . T h e r e v e r s a l o f m o t io n is in s t a n t a n e o u s , s o t h e 3 3 r d fr a m e w o u ld s h o w th e o b je c t tr a v e lin g in e x a c tly th e o p p o s ite d ir e c tio n . T o h a n d le t h is , w e s im p ly c h a n g e a 2 t o − a 2 in E q . ( 1 0 .6 - 7 ) . B a s e d o n t h e d is c u s s io n in c o n n e c t io n w it h E q . ( 1 0 .6 - 5 ) , a ll t h is c h a n g e w o u ld d o is p r o d u c e p e a k s a t fr e q u e n c ie s u = − a 2 V 2 a n d K + a 2 V 2 . F r o m E x a m p le 1 0 .2 8 w e k n o w t h a t t h e v a lu e o f a 2 is 4 . F r o m th e p r o b le m s ta te m e n t, w e k n o w th a t V 2 = 1 a n d K = 3 2 . T h u s , w e h a v e t w o n e w p e a k s a d d e d t o F ig . 1 0 .6 4 : o n e a t u = − 4 a n d t h e o t h e r a t u = 3 6 . A s n o te d a b o v e , th e o r ig in a l p e a k s c o r re s p o n d to th e m o tio n in th e p o s itiv e y - d ir e c tio n g iv e n in th e p r o b le m s ta te m e n t, w h ic h is th e s a m e a s in E x a m p le 1 0 .2 8 . N o t e t h a t t h e fr a m e c o u n t w a s r e s t a r t e d fr o m 0 t o 3 1 w it h t h e c h a n g e in d ire c tio n . Problem 10.47 R e c o n e tim d e r a t a o f s a n o a ll th a t v e lo c ity is a v e c to r, w h o s e m a g n itu d e is s p e e d . F u n c tio n g x is a - d im e n s io n a l " r e c o r d " o f th e p o s itio n o f th e m o v in g o b je c t a s a fu n c tio n o f e (fr a m e r a te ). T h e v a lu e o f v e lo c ity (s p e e d ) is d e te r m in e d b y ta k in g th e fi r s t iv a tiv e o f th is fu n c tio n . T o d e te r m in e w h e th e r v e lo c ity is p o s itiv e o r n e g a tiv e s p e c ifi c tim e , n , w e c o m p u te th e in s ta n ta n e o u s a c c e le r a tio n (r a te o f c h a n g e p e e d ) a t th a t p o in t; th a t is w e c o m p u te th e s e c o n d d e r iv a te o f g x . V ie w e d th e r w a y , w e d e te r m in e d ire c tio n b y c o m p u tin g th e d e r iv a tiv e o f th e d e r iv a - C H A P T E R 1 0 . P R O B L E M S O L U T IO N S 2 2 4 tiv e th e o r z im a s ig n o f ta n e ro g in , w g g . a h . B u t, t e n t h a s a B e c a u s e r y to its r ic h is w h x h e d e r iv a tiv e a t p o s itiv e s lo p e , g x is a c o m p le x e a l p a r t. T h is r a a t w e s ta r te d o u a p th e q u tio t to o in t is s im p ly th e ta n g v e lo c ity is p o s itiv e ; o th a n tity , its ta n g e n t is g iv is p o s itiv e w h e n S 1x a n p ro v e . e n t a t th e r w is e it e n b y th e d S 2x h a v a t is r e p o n e a tio th e in t. If g a tiv e o f its s a m e Problem 10.48 S e t in g c a p e n c im a A (0 n e n tim u p a s m a ll ta r g e t o f k n o w n , u a re a , a t c o o rd in a te s (x 0 ,y 0 ). tu re d b y th e s y s te m a n d c a n e to th e im a g e m o d e l d is c u s g in g th e ta r g e t w h e n th e b u )R a n d f a n d R w ill b e k n o w tia l te r m is k n o w n , s o c a n c e t w ill b e g iv e n b y n ifo r m r T h e s m a th u s b e s e d in S e lb is n e w n in th e o m p u te " f (x ,y ) = i (x ,y )r (x ,y ) = It is g iv e n la m p is n e n e n t o f th c o rre c te d in g th e k n t h a t O t s u ’s a l g o w (a n d t = 0 ) s o e p re v io u s e q u a im a g e w ill b e a s o w n re fl e c tiv ity (N o f (x a re im a 0 te : ,y R , g e 0 n (x 0 ,y 0 ) = A (t ) − t 2 e − [ (x − M / 2 )2 + (y − N / 2 ) r ith m w o r k s w e ll w h e n f = , if w e c a n fo rc e th e tim e a n d tio n to h a v e th e v a lu e A (0 ), d e s ire d . C o n s id e r th e p o r tio ta r g e t a t a n y tim e t n " f e fl e c tiv ity , R , n e a r a c o r n e r o f th e v ie w ll ta r g e t w ill b e c o m e p a r t o f th e im a g e s m o n ito re d b y th e s o ftw a re . W ith re fe rc t io n 2 .3 .4 , y o u c a n d e t e r m in e A (0 ) b y (t = 0 ) b e c a u s e th e n f (x 0 ,y 0 ) = i R = re g io n o f th e im a g e d ta r g e t. T h e e x p o it o n c e a n d s to re it. T h e im a g e a t a n y A (t n ) − t n2 e [ − (x A (0 s p th e n o )r a t n f t − M / 2 )2 + (y 0 − N / 2 ) 0 2 ] # r (x ,y ). (x ,y ) ia lly v s e g m h e im ., w h e n th in g c o m p o a tio n o f th a t c o n ta in e e - # R . ] 2 ( i.e a r y e n t a g e in p r a c tic e w e w o u ld u s e th e a v e r a g e v a lu e o f f a r o u n d (x 0 , y 0 ) in s te a d o f ) to r e d u c e th e e ffe c ts o f n o is e .) T h e e x p o n e n tia l te r m is k n o w n , a n d s o f n (x 0 , y 0 ), a n d t n . S o w e c a n s o lv e fo r A (t n ). T h e n w e c a n c o r r e c t th e in p u t a s fo llo w s : g (x ,y ) A (0 ) f (x ,y ) 2 e − [ (x 0 − M / 2 ) = = A ( t n ) − t n2 ⎡ A (t ) − t 2 e A (0 ) ⎣ A ( t n ) − t n2 e [ − − [ + (y 0 − N / 2 ) 2 ] (x − M / 2 )2 + (y − N / 2 ) (x 0 2 − M / 2 )2 + (y 0 − N / 2 ) ⎤ ] 2 ] ⎦r (x ,y ). A t t = t n , g ( x , y ) = A ( 0 ) r ( x , y ) , a n d w e k n o w t h a t O t s u ’s a l g o r i t h m w i l l p e r f o r m s a t i s f a c t o r i l y . B e c a u s e w e d o n ’t k n o w h o w A ( t ) b e h a v e s a s a f u n c t i o n o f t i m e a n d 2 2 5 th e la m p s a r e e x p e r im e n ta l, th e s a fe s t c o u r s e o f a c tio n is to p e r fo r m th in g c o r r e c tio n a s m a n y tim e s a s p o s s ib le d u r in g th e tim e th e la m p s a tin g . T h is re q u ire s fre q u e n t c o m p u ta tio n o f A (t n ) u s in g in fo r m a tio n fr o m th e re fl e c tiv e ta r g e t, a s w e d id a b o v e . If c o n tin u o u s c o r re c tio n a c o m p u ta tio n a l b u r d e n th a t is to o g r e a t, o r to o e x p e n s iv e to im p le m p e r fo r m in g e x p e r im e n ts w ith v a r io u s la m p s c a n h e lp in d e te r m in in g a c c e p ta b le p e r io d b e tw e e n c o r r e c tio n s . It is lik e ly th a t lo n g e r p e r io d s c o r r e c tio n s w ill b e a c c e p ta b le b e c a u s e th e c h a n g e in p h y s ic a l d e v ic e s is m u c h s lo w e r th a n th e s p e e d o f im a g in g d e v ic e s . e p re c e d a re o p e ro b ta in e d p re s e n ts e n t, th e n a lo n g e r b e tw e e n g e n e r a lly Problem 10.49 (a ) It is g iv e n th a t 1 0 % o f th e im a g e a re a in th e h o r iz o n ta l d ire c tio n is o c c u b y a b u lle t th a t is 2 .5 c m lo n g . B e c a u s e th e im a g in g d e v ic e is s q u a r e (2 5 6 × e le m e n ts ) th e c a m e r a lo o k s a t a n a r e a th a t is 2 5 c m × 2 5 c m , a s s u m in g n o o p d is t o r t io n s . T h u s , t h e d is t a n c e b e t w e e n p ix e ls is 2 5 / 2 5 6 = 0 .0 9 8 c m / p ix e l. m a x im u m s p e e d o f t h e b u lle t is 1 0 0 0 m / s e c = 1 0 0 ,0 0 0 c m / s e c . A t t h is s p e e d b u lle t w ill t r a v e l 1 0 0 , 0 0 0 / 0 .9 8 = 1 .0 2 × 1 0 6 p ix e ls / s e c . It is r e q u ir e d t h a t t h e b n o t t r a v e l m o r e t h a n o n e p ix e l d u r in g e x p o s u r e . T h a t is , ( 1 .0 2 × 1 0 6 p ix e ls / s e K s e c ≤ 1 p ix e l. S o , K ≤ 9 .8 × 1 0 − 7 s e c . p ie d 2 5 6 tic a l T h e , th e u lle t c ) × ( b ) T h e fr a m e r a te m u s t b e fa s t e n o u g h to c a p tu r e a t le a s t tw o im a g e s o f th e b u lle t in s u c c e s s iv e fr a m e s s o th a t th e s p e e d c a n b e c o m p u te d . If th e fr a m e r a te is s e t s o th a t th e b u lle t c a n n o t tr a v e l a d is ta n c e lo n g e r (b e tw e e n s u c c e s s iv e fr a m e s ) th a n o n e h a lf th e w id th o f th e im a g e , th e n w e h a v e th e c a s e s s h o w n in F ig . P 1 0 .4 9 . In c a s e s A a n d E w e g e t t w o s h o t s o f t h e e n t ir e b u lle t in fr a m e s t 2 a n d t 3 a n d t 1 a n d t 2 , r e s p e c tiv e ly . In th e o th e r c a s e s w e g e t p a r tia l b u lle ts . A lth o u g h th e s e c a s e s c o u ld b e h a n d le d w ith s o m e p r o c e s s in g ( e .g ., b y d e te r m in in g s iz e , le a d in g a n d tr a ilin g e d g e s , a n d s o fo r th ) it is p o s s ib le to g u a r a n te e th a t a t le a s t tw o c o m p le te s h o ts o f e v e r y b u lle t w ill b e a v a ila b le b y s e ttin g th e fr a m e r a te s o th a t a b u lle t c a n n o t tr a v e l m o r e th a n o n e h a lf th e w id th o f th e fr a m e , m in u s th e le n g t h o f t h e b u lle t . T h e le n g t h o f t h e b u lle t in p ix e ls is ( 2 .5 c m ) / ( 0 .0 9 8 c m / p ix e l) ≈ 2 6 p ix e ls . O n e h a lf o f th e im a g e fr a m e is 1 2 8 p ix e ls , s o th e m a x im u m tr a v e l d is ta n c e a llo w e d is 1 0 2 p ix e ls . B e c a u s e th e b u lle t tr a v e ls a t a m a x im u m s p e e d o f 1 .0 2 × 1 0 6 p ix e ls / s e c , t h e m in im u m fr a m e r a t e is 1 .0 2 × 1 0 6 / 1 0 2 = 1 0 4 fr a m e s / s e c . ( c ) In a fl a s h in g s itu a tio n w ith a r e fl e c tiv e o b je c t, th e im a g e s w ill te n d to b e d a r k , w it h t h e o b je c t s h in in g b r ig h t ly . T h e t e c h n iq u e s d is c u s s e d in S e c t io n 1 0 .6 .1 w o u ld th e n b e q u ite a d e q u a te . ( d ) F ir s t w e h a v e to d e te r m in e if a p a r tia l o r w h o le im a g e o f th e b u lle t h a s b e e n o b ta in e d . A fte r th e p ix e ls c o r r e s p o n d in g to th e o b je c t h a v e b e e n id e n tifi e d u s - 2 2 6 C H A P T E R 1 0 . P R O B L E M S O L U T IO N S F ig u r e P 1 0 .4 9 in g m o tio n s e g m e n ta tio n , w e d e te r m in e if th e o b je c t r u n s in to th e le ft b o u n d a r y ( s e e th e s o lu tio n t o P r o b le m 9 .3 6 r e g a r d in g a m e t h o d fo r d e t e r m in in g if a b in a r y o b je c t r u n s in to th e b o u n d a r y o f a n im a g e ). If it d o e s , w e lo o k a t th e n e x t tw o fr a m e s , w ith th e a s s u r a n c e th a t a c o m p le te im a g e o f th e b u lle t h a s b e e n o b ta in e d in e a c h b e c a u s e o f th e fr a m e r a te in (b ). If th e o b je c t d o e s n o t r u n in to th e le ft b o u n d a r y , w e a r e s im ila r ly a s s u r e d o f tw o fu ll s h o ts in tw o o f th e th r e e fr a m e s . W e th e n c o m p u te th e c e n tr o id o f th e o b je c t in e a c h im a g e a n d c o u n t th e n u m b e r o f p ix e ls b e tw e e n th e c e n tr o id s . B e c a u s e th e d is ta n c e b e tw e e n p ix e ls a n d th e tim e b e tw e e n fr a m e s a re k n o w n , c o m p u ta tio n o f th e s p e e d is a tr iv ia l p r o b le m . T h e p r in c ip a l u n c e r ta in ty in th is a p p r o a c h is h o w w e ll th e o b je c t is s e g m e n te d . H o w e v e r, b e c a u s e th e im a g e s a r e o f th e s a m e o b je c t in b a s ic a lly th e s a m e g e o m e tr y , c o n s is te n c y o f s e g m e n ta tio n b e tw e e n fr a m e s c a n b e e x p e c te d . Chapter 11 Problem Solutions Problem 11.1 ( a ) T h e k e y to th is p r o b le m is to r e c o g n iz e th a t th e v a lu e o f e v e r y e le c h a in c o d e is r e la tiv e to th e v a lu e o f its p r e d e c e s s o r. T h e c o d e fo r a t h a t is t r a c e d in a c o n s is t e n t m a n n e r ( e .g ., c lo c k w is e ) is a u n iq u e c ir c n u m b e r s . S ta r tin g a t d iffe r e n t lo c a tio n s in th is s e t d o e s n o t c h a n g e tu r e o f th e c ir c u la r s e q u e n c e . S e le c tin g th e s m a lle s t in te g e r a s th e s ta r s im p ly id e n tifi e s th e s a m e p o in t in th e s e q u e n c e . E v e n if th e s ta r tin n o t u n iq u e , th is m e th o d w o u ld s till g iv e a u n iq u e s e q u e n c e . F o r e x a s e q u e n c e 1 0 1 0 1 0 h a s th r e e p o s s ib le s ta r tin g p o in ts , b u t th e y a ll y ie ld s m a lle s t in te g e r 0 1 0 1 0 1 . m e n t in a b o u n d a r y u la r s e t o f th e s tr u c tin g p o in t g p o in t is m p le , th e th e s a m e ( b ) C o d e : 1 1 0 7 6 7 6 5 5 4 3 3 2 2 . T h e s ta r tin g p o in t is 0 , y ie ld in g th e s e q u e n c e 0 7 6 7 6 5 5 4 3 3 2 2 1 1 . Problem 11.2 (a ) T h e ja c e n t e d ire c tio w h ile to c h a n g e fi rs t d le m e n n , th e p o in t th e c o iffe r e n c e o n ly c ts o f th e c o d e . fi r s t d iffe re n c e o u t to s tu d e n ts d e its e lf ). o u n ts th B e c a u s e is in d e p e th a t th e e n th n d a s s u m b e r o f d e c o u n tin g e n t o f b o u n u m p tio n h e ire p r d a re c t o c r y is io n s t e s s is ro ta t th a t r h a t s e p in d e p e io n . (It o ta tio n a ra t n d e is w d o e e a n t o r t s n d o f h o t (b ) C o d e : 0 1 0 1 0 3 0 3 0 3 3 2 3 2 3 2 2 1 2 1 1 1 . D iffe re n c e : 3 1 3 1 3 3 1 3 1 3 0 3 1 3 1 3 0 3 1 3 0 0 . T h e c o d e w a s tr e a te d a s a c ir c u la r s e q u e n c e , s o th e fi r s t e le m e n t o f th e d iffe r e n c e is th e tr a n s itio n b e tw e e n th e la s t a n d fi r s t e le m e n t o f th e c o d e , a s e x p la in e d in th e te x t. 2 2 7 C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 2 8 F ig u r e P 1 1 .3 Problem 11.3 (a ) T h fl e c tio s tr u c t lin e s , u r a tio (b ) s u c th e d iff c e n e r u b b e r n o f th e u re o f th e th is p r o d n . If a h th s itu e re n te re -b a n d a p p c e ll w a ll. in n e r a n d u c e s th e m ro a c h fo rc e s th e p o T h a t is , th e lo c a tio o u te r w a lls . B e c a u s in im u m - p e r im e te r ly g o n to h a v e v e n s o f th e v e r tic e e th e v e r tic e s a re p o ly g o n fo r a n y r tic e s s a re jo in e g iv e n a t e v e r y fi x e d b y d b y s tra w a ll c o n in th ig h fi g c o r n e r o f a c e ll is c e n te r e d a t a p ix e l o n th e b o u n d a r y , a n a t th e r u b b e r b a n d is tig h te n e d o n th e o p p o s ite c o r n e r, w e a t io n in F ig . P 1 1 .3 . A s s u m in g t h a t t h e c e ll is o f s iz e d × d , t h p 2 d c e b e tw e e n th e p ix e l a n d th e b o u n d a r y in th a t c e ll is p d o n p ix e ls , th e m a x im u m d iffe r e n c e is ( 2 d )/ 2 . d th e c e w o u ld h e m a x im . If c e lls ll a u a e t - is v e m re Problem 11.4 (a ) W h e n th e B v e r tic e s a re m ir r o re d , th e y c o in c id e w ith th e tw o w h ite v e r tic e s in th e c o r n e r s , s o th e y b e c o m e c o llin e a r w ith th e c o r n e r v e r tic e s . T h e a lg o r ith m ig n o r e s c o llin e a r v e r tic e s , s o th e s m a ll in d e n ta tio n w ill n o t b e d e te c te d . (b th R e b e B e a n s g s g tia ) W h e n th e in d e n ta tio n is d e e p e r th a n o n e p ix e l (b u t s till 1 p ix e l w id e ) w e h a v e e s it u a t io n s h o w n in F ig . P 1 1 .4 . N o t e t h a t t h e B v e r t ic e s c r o s s a ft e r m ir r o r in g . fe r r in g to th e b o tto m fi g u r e , w h e n th e a lg o r ith m g e ts to v e r te x 2 , v e r te x 1 w ill id e n tifi e d a s a v e r te x o f th e M P P, s o th e a lg o r ith m is in itia liz e d a t th a t s te p . c a u s e o f in itia liz a tio n , v e r te x 2 is v is ite d a g a in . It w ill b e c o llin e a r w ith W C d V L , s o B C w ill b e s e t a t th e lo c a tio n o f v e r te x 2 . W h e n v e r te x 3 is v is ite d , n (V L , W C , V 3 ) w ill b e 0 , s o B C w ill b e s e t a t v e r te x 3 . W h e n v e r te x 4 is v is ite d , n (1 , 3 , 4 ) w ill b e n e g a tiv e , s o V L w ill b e s e t to v e r te x 3 a n d th e a lg o r ith m is r e in iliz e d . B e c a u s e v e r te x 2 w ill n e v e r b e v is ite d a g a in , it w ill n e v e r b e c o m e a v e r - 2 2 9 1 2 Order and location of vertices beforemirroring the B vertices 4 3 1 3 Order and location of vertices after mirroring the B vertices 4 2 F ig u r e P 1 1 .4 te x o f th e M P P. T h in d e n ta tio n s 2 p ix th e s e q u e n c e 1 − 3 in g c a u s e d b y th e T h is is a g e n e r a l re e n e x t M P e ls o r g r e a − 4 in th e m ir r o r in g s u lt fo r 1 - P v e r te te r in d s e c o n d o f th e p ix e l w x t e p fi g tw id e o b e d e te c te d w th a n d 1 p ix e l w u re . T h u s , th e a o B v e r tic e s b y , 2 p ix e l (o r g re a ill b e id e w lg o r it k e e p te r) d v e r ill b h m in g e e p (c ) W h e n th e B v e r tic e s o f a 1 - p ix e l d e e p p r o tr u s io n a re m ir r o r a lig n e d w ith th e tw o c o n v e x v e r tic e s o f th e p r o tr u s io n , w h ic h v e r tic e s o f th e M P P (o th e r w is e th e y w o u ld b e th e c o r n e r s o f th lin e p a s s in g fr o m th e fi r s t c o n v e x v e r te x to th e p r e v io u s M P P v e th a t th e c o r r e s p o n d in g m ir r o r e d B v e r te x w o u ld b e o u ts id e th e n o t b e a v e r te x o f th e M P P. A s im ila r c o n c lu s io n is r e a c h e d b y p a th e s e c o n d c o r n e r to th e n e x t v e r te x o f th e M P P, s o th e s e c o n d c o u ld n o t b e p a r t o f th e M P P. T h e c o n c lu s io n is th a t th e s m a ll p b e m is s e d b y th e a lg o r ith m . te x 4 . T h e re p re s e s o lv e s th o n ly o n e in tr u s io e re fo n te d e c ro v e r t n s . re , b y s s e x . e d , th e y b e c o m e a re k n o w n to b e e p r o tr u s io n ). A r te x w o u ld s h o w M P P, s o it c o u ld s s in g a lin e fr o m m ir r o re d v e r te x r o tr u s io n w o u ld ( d ) A d r a w in g s im ila r to th e o n e u s e d in (b ) w o u ld s h o w th a t b o th v e r tic e s o f th e p r o tr u s io n w o u ld b e d e te c te d n o r m a lly fo r a n y p r o tr u s io n e x te n d in g fo r m o r e th a n o n e p ix e l. Problem 11.5 ( a ) T h e r e s u ltin g p o ly g o n w o u ld c o n ta in a ll th e b o u n d a r y p ix e ls . ( b ) A c tu a lly , in b o th c a s e s th e r e s u ltin g p o ly g o n w o u ld c o n ta in a ll th e b o u n d a r y p ix e ls . C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 3 0 F ig u r e P 1 1 .6 Problem 11.6 ( a ) T h e s o lu t io n is s h o w n in F ig . P 1 1 .6 ( b ) . ( b ) T h e s o lu t io n is s h o w n in F ig . P 1 1 .6 ( c ) . Problem 11.7 ( a ) F r o m F ig . P 1 1 .7 ( a ) , w e s e e t h a t t h e d is t a n c e fr o m t h e o r ig in t o t h e t r ia n g le is g iv e n b y r (θ ) D = 0 0 = = = = = c o s θ D c o s (1 2 D c o s (1 8 D c o s (2 4 D c o s (3 0 D c o s (3 6 ◦ 0 ◦ − θ ) ◦ − θ ) ◦ − θ ) ◦ − θ ) ◦ − θ ) 0 0 0 0 0 0 0 0 0 ◦ ≤ θ < 6 0 6 0 ◦ ≤ θ < 1 2 0 ◦ 1 2 0 ◦ ≤ θ < 1 8 0 ◦ 1 8 0 ◦ ≤ θ < 2 4 0 ◦ 2 4 0 ◦ ≤ θ < 3 0 0 ◦ 3 0 0 ◦ ≤ θ < 3 6 0 ◦ 2 3 1 w h e r e D 0 is th e p e r p e n d ic u la r d tr ia n g le , a n d D = D 0 / c o s (6 0 ◦ ) th e tr ia n g le a r e g iv e n , d e te r m in p r o b le m , a n d D 0 (w h ic h is th e e le m e n ta r y g e o m e tr y . is ta n c e = 2 D 0 . in g th e s a m e f fr O e q o r o m n c e u a t th e th e th io n th F ig u r e P 1 1 .7 o r e c o f re e ig in to o o rd in e a c h s s tr a ig o n a te tra h t e o f th e s o f th e ig h t lin e lin e s ) fo s id v e is llo e s o f th e r tic e s o f a s im p le w s fro m C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 3 2 ( b ) F r o m F ig . P 1 1 .7 ( c ) , r (θ ) = = = = = = = = B 2 c o s θ ◦ 0 A 2 c o s (9 0 A 2 c o s (θ B 2 c o s (1 8 B 2 c o s (θ A 2 c o s (2 7 A 2 c o s (θ B 2 c o s (3 6 ◦ ' ≤ θ < 9 0 − θ ) ◦ − 1 8 0 ◦ ) ◦ − θ ) − 2 7 0 ) ◦ 0 − θ ) ◦ ≤ θ < (1 8 0 ◦ (1 8 0 − θ ) 0 ◦ 9 0 − 9 0 ◦) 0 ≤ θ < ' ◦ − ' ) − ' ) ≤ θ < 1 8 0 1 8 0 ◦ ≤ θ < 1 8 0 ◦ 1 8 0 ◦ + ' ≤ θ < 2 7 0 2 7 0 ◦ ≤ θ < 2 7 0 2 7 0 ◦ + ' ≤ θ < 3 6 0 ◦ . ◦ ◦ + ' ◦ + ' w h e re ' = ta n − 1 (A / B ). ( c ) T h e e q u a t io n o f t h e e llip s e in F ig . P 1 1 .7 ( e ) is 2 x a 2 2 y + = 1 . 2 b W e a re in te re s te d in th e d is ta n c e fr o m th e o r ig in to a n a r b itr a r y p o in t (x ,y ) o n th e e llip s e . In p o la r c o o r d in a te s , x = r c o s θ a n d y = r s in θ w h e re r is th e d is ta n c e fr o m th e o r ig in to (x ,y ): r = 2 x 2 + y . S u b s titu tin g in to th e e q u a tio n o f th e e llip s e w e o b ta in r 2 c o s 2 θ + a 2 2 r s in b 2 2 θ = 1 fr o m w h ic h w e o b ta in th e d e s ir e d r e s u lt: 1 r (θ ) = c o s θ a 2 + s in θ b 2 1 / 2 . W h e n b = a , w e h a v e th e fa m ilia r e q u a tio n o f a c ir c le , r (θ ) = a , o r x 2 + y 2 = a 2 . 2 3 3 F ig u r e P 1 1 .8 F ig u r e P 1 1 .1 0 Problem 11.8 T h e s o lu t io n s a r e s h o w n in F ig . P 1 1 .8 . Problem 11.9 (a ) In th e ( 1 1 .1 - 4 ) is E q . ( 1 1 .1 a n d p 4 · p is le ft u n c le ft u n c h a (b ) In th p is le ft th ird c a S (p ) = 2 fi rs t c a s e , N (p ) = s a tis fi e d a n d p is 4 ) is v io la te d a n d 6 · p 8 = 1 , s o c o n h a n g e d . In th e fo n g e d . e fi u n s e a n rs t c h a (c 0) d p c a s e p n g e d . a n d (d is le ft 5 , S (p ) = 1 , p 2 ·p 4 ·p 6 = 0 , a n d p 4 ·p 6 ·p fl a g g e d fo r d e le tio n . In th e s e c o n d c a s e , p is le ft u n c h a n g e d . In th e th ir d c a s e p 2 d it io n s ( c ) a n d ( d ) o f E q . ( 1 1 .1 - 4 ) a r e v io r th c a s e S (p ) = 2 , s o c o n d itio n (b ) is v io la 2 ·p 6 ·p 8 In th e s e 0) a r e v io u n c h a n g 8 = N (p ·p 4 la te te d 0 , s o ) = 1 ·p 6 d a n a n d E q . , s o = 1 d p p is = 1 s o c o n d it io n ( d 0) in E q . ( 1 1 .1 - 6 ) is v io la t e d a n d c o n d c a s e N (p ) = 1 s o p is le ft u n c h a n g e d . In th e la te d a n d p is le ft u n c h a n g e d . In th e fo u r th c a s e e d . Problem 11.10 ( a ) T h e r e s u lt is s h o w n in F ig . P 1 1 .1 0 ( b ) . ( b ) T h e r e s u lt is s h o w n in F ig . P 1 1 .1 0 ( c ) . C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 3 4 Problem 11.11 ( a ) T h e n u m b e r o f s y m b o ls in th e fi r s t d iffe r e n c e is e q u a l to th e n u m b e r o f s e g m e n t p r im itiv e s in th e b o u n d a r y , s o th e s h a p e o rd e r is 1 2 . ( b ) S ta r tin g a t th e to p le ft c o r n e r, C h a in c o d e : D iffe re n c e : S h a p e n u m b e r : 0 0 0 3 3 2 1 2 3 2 1 1 3 0 0 3 0 3 3 1 1 3 3 0 0 0 3 0 3 3 1 1 3 3 0 3 Problem 11.12 W ith re fe re n c o n ju g a te s y g in h a v e th is th a t th is c o n b y p la c in g th c e to C h m m e tr ic p ro p e r t d itio n is e o r ig in a p te r . O n ly y . T h e s a tis fi a t th e 4 , th e D F T c a n b e c o n to u rs th a t a re s a x is s y s te m o f F ig . e d fo r s y m m e tr ic fi c e n te r o f g r a v ity o f r e a l o n ly if th e y m m e tr ic w ith 1 1 .1 9 w o u ld h a g u re s . T h is c a n th e c o n to u r. d a ta s e q u e n c e re s p e c t to th e o v e to b e s e t u p b e a c c o m p lis h is r is o e d Problem 11.13 S u p p o s e th a t w e h a tic le w ill b e a t s o m e s itu a tio n w ith w h ic p o in t in th e c o m p le th e m o v in g p a r tic le d e s c r ib e s a p a th in tio n o f a c u r v e b e c a v e a p a r tic le m o v in g in th e x y - p la n e . A t e a c h tim p o in t w h o s e c o o rd in a te s c a n b e w r itte n a s [x (y h w e a r e d e a lin g is in th e c o m p le x p la n e . R e c a x p la n e is w r itte n a t c = x + j y , w e c a n w r ite th e in th e c o m p le x p la n e a s z (t ) = x (t ) + j y (t ). A s t th e c o m p le x p la n e . T h is is c a lle d th e p a r a m e tr ic u s e it d e p e n d s o n p a r a m e te r t . e t th e ),y (t )]. llin g th lo c a tio v a r ie s , re p re se p a rT h e a t a n o f z (t ) n ta - T h e " s ta n d a r d " e q u a tio n o f a c ir c le w ith c e n te r a t (b , c ) a n d r a d iu s r is g iv e n b y (x − b )2 + (y − c )2 = r 2 . U s in g p o la r c o o r d in a te s , w e c a n w r ite x (θ ) = b + r c o s θ y (θ ) = c + r s in θ . T h e n , th e c ir c le c a n b e r e p r e s e n te d in p a r a m e tr ic fo r m a s th e p a ir x (θ ), y (θ ) , w ith θ b e in g th e p a r a m e te r. T h e c ir c le c a n th u s b e r e p r e s e n te d in th e c o m p le x p la n e , a s th e c u r v e z (θ ) x (θ ) + j y (θ ) = = (b + c ) + r (c o s θ + j s in θ ). 2 3 5 U s in g o n ly t w o d e s c r ip t o r s in E q . ( 1 1 .2 - 5 ) g iv e s s^ ( k ) = = 2 π k 2 π k 1 + j s in a (0 ) + a (1 ) c o s P K K 2 π k a (1 ) 2 π k a (0 ) c o s + + j s in P P K K w h ic h w e s e e is in th e fo r m o f a c ir c le b y le ttin g (b + c ) = a (0 )/ P , r = a (1 )/ P , a n d θ = 2 π k / K . Problem 11.14 T h e m e a n is s u ffi c ie n t. Problem 11.15 T w o e llip s e s w ith d iffe r e n t, s a y , m a jo r a x e s , h a v e s ig n a tu r e s w ith th e s a m e m e a n a n d th ird s ta tis tic a l m o m e n t d e s c r ip to r s (b o th d u e to s y m m e tr y ) b u t d iffe re n t s e c o n d m o m e n t (d u e to s p re a d ). Problem 11.16 T h is p r o b le m c a n b e s o lv e d b y u s in g tw o d e s c r ip to r s : h o le s a n d th e c o n v e x d e fi c ie n c y ( s e e S e c t io n 9 .5 .4 r e g a r d in g t h e c o n v e x h u ll a n d c o n v e x d e fi c ie n c y o f a s e t). T h e d e c is io n m a k in g p r o c e s s c a n b e s u m m a r iz e d in th e fo r m o f a s im p le d e c is io n , a s fo llo w s : If th e c h a r a c te r h a s tw o h o le s , it is a n 8 . If it h a s o n e h o le it is a 0 o r a 9 . O th e r w is e , it is a 1 o r a n X . T o d iffe re n tia te b e tw e e n 0 a n d 9 w e c o m p u te th e c o n v e x d e fi c ie n c y . T h e p re s e n c e o f a ” s ig n ifi c a n t” d e fi c ie n c y (s a y , h a v in g a n a r e a g r e a te r th a n 2 0 % o f th e a r e a o f a r e c ta n g le th a t e n c lo s e s th e c h a r a c te r ) s ig n ifi e s a 9 ; o th e r w is e w e c la s s ify th e c h a r a c te r a s a 0 . W e fo llo w a s im ila r p r o c e d u re to s e p a r a te a 1 fr o m a n X . T h e p re s e n c e o f a c o n v e x d e fi c ie n c y w ith fo u r c o m p o n e n ts w h o s e c e n tr o id s a r e lo c a te d a p p r o x im a te ly in th e N o r th , E a s t, W e s t, a n d E a s t q u a d r a n ts o f th e c h a r a c te r in d ic a te s th a t th e c h a r a c te r is a n X . O th e r w is e w e s a y th a t th e c h a r a c te r is a 1 . T h is is th e b a s ic a p p r o a c h . Im p le m e n ta tio n o f th is te c h n iq u e in a re a l c h a r a c te r re c o g n itio n e n v ir o n m e n t h a s to t a k e in t o a c c o u n t o t h e r fa c t o r s s u c h a s m u lt ip le ” s m a ll” c o m p o n e n t s in t h e c o n v e x d e fi c ie n c y d u e to n o is e , d iffe r e n c e s in o r ie n ta tio n , o p e n lo o p s , a n d th e lik e . H o w e v e r, th e m a te r ia l in C h a p te r s 3 , 9 a n d 1 1 p r o v id e a s o lid b a s e fr o m w h ic h to fo r m u la te s o lu tio n s . C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 3 6 Problem 11.17 (a ) C o - o c c u r re n c e m a tr ix : 1 9 6 0 0 2 0 0 2 0 0 0 0 0 ( b ) N o r m a liz e th e m a tr ix b y d iv id in g e a c h c o m p o n e n t b y 1 9 6 0 0 + = 3 9 8 0 0 : 0 .4 9 2 5 0 .0 0 5 0 0 0 .5 0 2 5 s o p 1 1 = 0 .4 9 2 5 , p = 0 .0 0 5 , p 1 2 = 0 , a n d p 2 1 2 2 = 0 .5 0 2 5 . (c ) D e s c r ip to r s : ( 1 ) M a x im u m p r o b a b ilit y : 0 .0 5 0 2 5 . (2 ) C o r re la tio n : T h e m e a n s a re 2 m 2 = i r p i = 1 = 1 (p = i j j = 1 + p 1 1 ) + 2 (p 1 2 2 1 + p 2 2 ) 1 (.4 9 2 5 + 0 .0 0 5 ) + 2 (0 + 0 .5 0 2 5 ) = 1 .5 0 2 5 a n d 2 m 2 = j c p i = 1 = 1 (p = i j i = 1 + p 1 1 ) + 2 (p 2 1 1 2 + p 2 2 ) 1 .5 0 7 5 . S im ila r ly , th e s ta n d a r d d e v ia tio n s a r e : 2 σ 2 2 = (i − m r ) r 2 p i = 1 = (1 − m = i j j = 1 r )(p 1 1 + p 1 2 p i j ) + (2 − m r )(p 2 1 + p 2 2 ) 0 .5 0 0 0 a n d 2 σ 2 2 (j − m c = j = 1 = c ) 2 i = 1 = (1 − m c )(p 1 1 + p 2 1 ) + (2 − m c )(p 1 2 + p 2 2 ) 0 .4 9 9 9 . 2 0 0 + 2 0 0 0 0 2 3 7 T h e n , th e c o r r e la tio n m e a s u r e is c o m p u te d a s 2 2 (i − m ) j − m r σ i = 1 j = 1 σ r p c = σ c = 2 2 1 i j σ r (i − m c ) j − m r p c i j i = 1 j = 1 0 .9 9 0 0 . (3 ) C o n tra st: 2 2 2 i − j p = (1 − 1 )2 p = 0 .0 0 5 . i j + (1 − 2 )2 p 1 1 + (2 − 1 )2 p 1 2 2 1 + (2 − 2 )2 p 2 2 i = 1 j = 1 (4 ) U n ifo r m ity : 2 2 2 i j p )2 + (p = (p = 0 .4 9 5 1 . 1 1 1 2 )2 + (p )2 + (p 2 2 p 2 1 + 2 p 2 2 1 2 1 ) 2 i = 1 j = 1 (5 ) H o m o g e n e ity : 2 2 p 1 + i = 1 i = 1 i j i − j p 1 2 + 2 p 1 1 + 1 = = 0 .9 9 7 5 . (6 ) E n tro p y : 2 2 p − i j lo g 2 p i j = − p 1 1 lo g p 1 1 + p + p 2 2 lo g 2 1 2 lo g p 2 2 2 p 1 2 + p 2 1 lo g 2 p 2 1 i = 1 i = 1 = w h e r e w e u s e d 0 lo g 2 2 1 .0 4 0 5 0 ≡ 0 . Problem 11.18 W e c a n u s e t h e p o s i t i o n o p e r a t o r P : “ 2 m p i x e ls t o t h e r i g h t a n d 2 m p i x e ls b e lo w .” C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 3 8 Problem 11.19 (a ) T h e im a g e is L o r T c e t z 1 = 0 a n d z 2 = 1 . B e c a u r d e r 2 × 2 . E le m e n t g 1 1 is th ig h t o f a 0 . B y in s p e c tio n , h e to ta l n u m b e r o f p ix e ls o - o c c u r re n c e m a tr ix is 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 s e th e re e n u m b g 11 = 0 . s a tis fy in a r e o n ly tw o in te n s ity le v e e r o f p ix e ls v a lu e d 0 lo c a te d S im ila r ly , g 1 2 = 1 0 , g 2 1 = g th e p re d ic a te P is 2 0 , s o 0 1 / 2 G = . 1 / 2 0 ls , m o n e 1 0 , a th e a tr ix G p ix e l t n d g 22 n o r m a is o f o th e = 0 . liz e d . ( b ) I n t h i s c a s e , g 1 1 i s t h e n u m b e r o f 0 ’s t w o p i x e l s t o t h e r i g h t o f a p i x e l v a l u e d 0 . B y in s p e c tio n , g 1 1 = 8 . S im ila r ly , g 1 2 = 0 , g 2 1 = 0 , a n d g 2 2 = 7 . T h e n u m b e r o f p ix e ls s a tis fy in g P is 1 5 , s o th e n o r m a liz e d c o - o c c u r r e n c e m a tr ix is 8 / 1 5 0 G = 0 7 / 1 5 . Problem 11.20 W h e n a s s ig n in g th is p r o b le m , th e In s tr u c to r m a y w is h to p o in t th e s tu d e n t to th e re v ie w o f m a tr ic e s a n d v e c to r s in th e b o o k w e b s ite . F r o m E q . ( 1 1 .4 - 6 ) , y = A (x − m x ) . T h e n , m E f y g = E f A (x − m x )g = y A [E f x g − E f m x g ] = = = A (m x − m x ) 0 . T h is e s t a b lis h e s t h e v a lid it y o f E q . ( 1 1 .4 - 7 ) . T o p r o v e t h e v a lid it y o f E q . ( 1 1 .4 - 8 ) , w e s t a r t w it h t h e d e fi n it io n o f t h e c o v a r ia n c e m a t r ix g iv e n in E q . ( 1 1 .4 - 3 ) : C y = E f (y − m y )(y − m y )T g . 2 3 9 B e c a u s e m y = 0 , it fo llo w s th a t C A E f (x − m x )(x − m x )T g A = = T A C x A v a lid ity o f E q . (1 1 r ia n c e m a tr ic e s a h a t a re a l s y m m e (w h ic h a r e e a s ily r o w s o f m a tr ix A C x A g E f [A (x − m x )][A (x − m x )]T g = S h o w in g th e in g th a t c o v a it is k n o w n t e ig e n v e c to r s c e d u re ). T h e T E f y y = y T . .4 - 9 ) is a re re a l a n tr ic m a tr o r th o n o a re th e o = little m o r d s y m m e ix o f o rd e r m a liz e d r th o n o r m e c o m p lic a te d . W e s ta r t b y n o t tr ic . F r o m b a s ic m a tr ix a lg e b r a r n h a s n lin e a r ly in d e p e n d e n b y , s a y , th e G r a m - S c h m id t p r o a l e ig e n v e c to r s o f C x . T h e n , C x [e 1 ,e 2 ,... e = [λ = A e 1 ,λ 1 T 2 λ ⎢ ⎢ 0 D = ⎢⎢ . . ⎣ . 0 , t - e 2 ,...,λ n ] e n n ] D w h e r e w e u s e d t h e d e fi n it io n o f a n e ig e n v e c t o r ( i.e ., C x e a g o n a l m a tr ix c o m p o s e d o f th e e ig e n v a lu e s o f C x : ⎡ - ] n [C x e 1 ,C x e 2 ,... C x e = T ··· ··· .. 0 1 λ 2 .. . .. . λ λ ie i ) a n d D is a d i- ⎥ ⎥ ⎥. ⎥ ⎦ 0 ··· 0 = ⎤ 0 . i n P r e m u ltip ly in g b o th s id e s o f th e p r e c e d in g e q u a tio n b y m a tr ix A g iv e s A C x A T = A A = w h e re w e u s e d th e fa c t th a m a l v e c to rs . T h e re fo r, b e c a m a tr ix th a t is p r o d u c e d b y tr ix c o m p o s e d o f its e ig e n v a s th e e ig e n v a lu e s o f C x . (R d ia g o n a l te r m s ). T h e fa c t t C y a re e q u a l to th e e ig e n v e t A T A = A A T = u s e C y = A C x A d ia g o n a liz in g e c to r s . T h e e ig e c a ll th a t th e e h a t C y e i = D e i c to rs o f C x . T D D I b e c a u s e th e ro w s o f A a re o r th o n o r, w e h a v e s h o w n th a t C y is a d ia g o n a l m a tr ix C x u s in g a tr a n s fo r m a tio n m a e n v a lu e s o f C y a r e s e e n to b e th e s a m e ig e n v a lu e s o f a d ia g o n a l m a tr ix a r e its = λ i e i s h o w s th a t th e e ig e n v e c to r s o f T C H A P T E R 1 1 . P R O B L E M S O L U T IO N S 2 4 0 Problem 11.21 T h e m e a w h o s e c o p a r tic u la th e m e a n n s q u rre s p r c a s e s q u a a re o n d , th re e e rr in g e fo rro o r, g iv e n b y E q . ( 1 1 .4 - 1 2 ) , is t h e s u m o f t h e e ig e n v a lu e s e ig e n v e c to r s a re n o t u s e d in th e tr a n s fo r m a tio n . In th is u r s m a lle s t e ig e n v a lu e s a r e a p p lic a b le ( s e e T a b le 1 1 .6 ) , s o r is 6 e λ = m s = 1 7 2 9 . j j = 3 T o o o h e m a x im u f a ll th e e ig n ly th e tw o f th e to ta l p m e rro e n v a lu e ig e n v o s s ib le r o c c u r s w h e n K = 0 in E q . ( 1 1 .4 - 1 2 ) w h ic h t h e n is t h e s u m e s , o r 1 5 0 3 9 in th is c a s e . T h u s , th e e r r o r in c u r re d b y u s in g e c t o r s c o r r e s p o n d in g t o t h e la r g e s t e ig e n v a lu e s is ju s t 1 1 .5 % e rro r. Problem 11.22 T h is 4 0 9 6 m a tr ( 1 1 .4 p r o b le m is s im ila r to th × 4 0 9 6 b e c a u s e th e im a g ix is th e id e n tity m a tr ix , -1 2 ), th e m e a n s q u a re e r e p re v io u s o n e . T h e c o v a r ia n c e m a tr ix is o f o rd e r e s a re o f s iz e 6 4 × 6 4 . It is g iv e n th a t th e c o v a r ia n c e s o a ll its 4 0 9 6 e ig e n v a lu e s a r e e q u a l to 1 . F r o m E q . r o r is 4 0 9 6 e 2 0 4 8 λ m s = j λ − j = 1 = i i = 1 2 0 4 8 . Problem 11.23 W h e n th e b o u n d a r y is s y m m e tr ic a b o u t th e b o th th e m a jo r a n d m in o r a x e s a n d b o th a x e s in te r s e c t a t th e c e n tr o id o f th e b o u n d a r y . Problem 11.24 A s o lu t i o n u s i n g t h e r e la t i o n s h i p ” c o n n e c t e d t o ,” i s s h o w n i n F i g . P 1 1 .2 4 . Problem 11.25 W e c a n c o m p u te a m e a s u re o f te x tu re u s in g th e e x p re s s io n R (x ,y ) = 1 − 1 1 + σ 2 (x ,y ) w h e re σ 2 (x ,y ) is th e in te n s ity v a r ia n c e c o m p u te d in a n e ig h b o r h o o d o f (x ,y ). T h e s iz e o f th e n e ig h b o r h o o d m u s t b e s u ffi c ie n tly la r g e s o a s to c o n ta in e n o u g h 2 4 1 F ig u r e P 1 1 .2 4 s a m p le s to h a v e a s ta b le e s tim a te o f th e m e a n a n d v a r ia n c e . N e ig h b o r h o o d s o f s iz e 7 × 7 o r 9 × 9 g e n e r a lly a r e a p p r o p r ia te fo r a lo w - n o is e c a s e s u c h a s th is . B e c a u s e th e v a r ia n c e o f n o r m a l w a fe r s is k n o w n to b e 4 0 0 , w e c a n o b ta in a n o r m a l v a lu e fo r R (x , y ) b y u s in g σ 2 = 4 0 0 in th e a b o v e e q u a tio n . A n a b n o r m a l r e g io n w ill h a v e a v a r ia n c e o f a b o u t (5 0 )2 = 2 , 5 0 0 o r h ig h e r, y ie ld in g a la r g e r v a lu e o f R (x , y ). T h e p r o c e d u r e th e n is to c o m p u te R (x , y ) a t e v e r y p o in t (x , y ) a n d la b e l th a t p o in t a s 0 if it is n o r m a l a n d 1 if it is n o t. A t th e e n d o f th is p r o c e d u r e w e l o o k f o r c l u s t e r s o f 1 ’s u s i n g , f o r e x a m p l e , c o n n e c t e d c o m p o n e n t s ( s e e S e c t io n 9 .5 .3 r e g a r d in g c o m p u ta tio n o f c o n n e c t e d c o m p o n e n ts ) . If th e a r e a (n u m b e r o f p ix e ls ) o f a n y c o n n e c te d c o m p o n e n t e x c e e d s 4 0 0 p ix e ls , th e n w e c la s s ify th e s a m p le a s d e fe c tiv e . Problem 11.26 T h is p r o b le m h a s fo u r m a jo r p a r ts . (1 ) D e te c tin g in d iv id u a l b o ttle s in a n im a g e ; (2 ) fi n d in g th e to p e a c h b o ttle ; (3 ) fi n d in g th e n e c k a n d s h o u ld e r o f e a c h b o ttle ; a n d (4 ) d e te r m in in g th e le v e l o f th e liq u id in th e r e g io n b e tw e e n th e n e c k a n d th e s h o u ld e r. (1 ) F in d in g in d iv id u a l b o ttle s . N o te th a t th e b a c k g r o u n d in th e s a m p le im a g e is m u c h d a r k e r th a n th e b o ttle s . W e a s s u m e th a t th is is tr u e in a ll im a g e s . T h e n , a s im p le w a y to fi n d in d iv id u a l b o ttle s is to fi n d v e r tic a l b la c k s tr ip e s in th e im a g e h a v in g a w id th d e te r m in e d b y th e a v e r a g e s e p a r a tio n b e tw e e n b o ttle s , a n u m b e r th a t is e a s ily c o m p u ta b le fr o m im a g e s r e p r e s e n ta tiv e o f th e a c tu a l s e tu p d u r in g 2 4 2 C H A P T E R 1 1 . P R O B L E M S O L U T IO N S o p e r a tio n . W e c a n fi n d th e s e s tr ip e s in v a r io u s w a y s . O n e w a y is to s m o o th th e im a g e to re d u c e th e e ffe c ts o f n o is e (w e a s s u m e th a t, s a y , a 3 × 3 o r 5 × 5 a v e r a g in g m a s k is s u ffi c ie n t). T h e n , w e r u n a h o r iz o n ta l s c a n lin e th r o u g h th e m id d le o f th e im a g e . T h e lo w v a lu e s in th e s c a n lin e w ill c o r r e s p o n d to th e b la c k o r n e a r ly b la c k b a c k g r o u n d . E a c h b o ttle w ill p r o d u c e a s ig n ifi c a n t r is e a n d fa ll o f in te n s ity le v e l in th e s c a n lin e fo r th e w id th o f th e b o ttle . B o ttle s th a t a r e fu lly in th e fi e ld o f v ie w o f th e c a m e r a w ill h a v e a p r e d e te r m in e d a v e r a g e w id th . B o ttle s th a t a r e o n ly p a r tia lly in th e fi e ld o f v ie w w ill h a v e n a r r o w e r p r o fi le s , a n d c a n b e e lim in a te d fr o m fu r th e r a n a ly s is (b u t w e n e e d to m a k e s u r e th a t th e tr a ilin g in c o m p le te b o ttle s a r e a n a ly z e d in th e n e x t im a g e ; p r e s u m a b ly , th e le a d in g p a r tia l b o t t le w a s a lr e a d y p r o c e s s e d .) . (2 ) F in d in g th e to p o f e a c h b o ttle . O n c e th e lo c a tio n o f e a c h (c o m p le te o r n e a r ly c o m p le te ) b o ttle is d e te r m in e d , w e a g a in c a n u s e th e c o n tr a s t b e tw e e n th e b o ttle s a n d th e b a c k g r o u n d to fi n d th e to p o f th e b o ttle . O n e p o s s ib le a p p r o a c h is to c o m p u te a g r a d ie n t im a g e (s e n s itiv e o n ly to h o r iz o n ta l e d g e s ) a n d lo o k fo r a h o r iz o n ta l lin e n e a r th e to p o f th e g r a d ie n t im a g e . A n e a s ie r m e th o d is to r u n a v e r tic a l s c a n lin e th r o u g h th e c e n te r o f th e lo c a tio n s fo u n d in th e p r e v io u s s te p . T h e fi r s t m a jo r tr a n s itio n in g r a y le v e l (fr o m th e to p o f th e im a g e ) in th e s c a n lin e w ill g iv e a g o o d in d ic a tio n o f th e lo c a tio n o f th e to p o f a b o ttle . (3 ) F in d in g th e n e c k a n d s h o u ld e r o f a b o ttle . In th e a b s e n c e o f o th e r in fo rm a tio n , w e a s s u m e th a t a ll b o ttle s a r e o f th e s a m e s iz e , a s s h o w n in th e s a m p le im a g e . T h e n , o n c e w e n o w w h e r e th e to p o f a b o ttle is , th e lo c a tio n o f th e n e c k a n d s h o u ld e r a r e k n o w n to b e a t a fi x e d d is ta n c e fr o m th e b o ttle to p . (4 ) D e te r m in in g th e le v e l o f th e liq u id . T h e a re a d e fi n e d b y th e b o tto m o f th e n e c k a n d th e to p o f th e s h o u ld e r is th e o n ly a r e a th a t n e e d s to b e e x a m in e d to d e te r m in e a c c e p ta b le v s . u n a c c e p ta b le fi ll le v e l in a g iv e n b o ttle . In fa c t, A s s h o w n in th e s a m p le im a g e , a n a r e a o f a b o ttle th a t is v o id o f liq u id a p p e a r s q u ite b r ig h t in a n im a g e , s o w e h a v e v a r io u s o p tio n s . W e c o u ld r u n a s in g le v e r tic a l s c a n lin e a g a in , b u t n o te th a t th e b o ttle s h a v e a r e a s o f r e fl e c tio n th a t c o u ld c o n fu s e th is a p p r o a c h . T h is c o m p u ta tio n is a t th e c o re o f w h a t th is s y s te m is d e s ig n e d to d o , s o a m o r e r e lia b le m e th o d s h o u ld b e u s e d . O n e a p p r o a c h is to th r e s h o ld th e a r e a s p a n n in g a r e c ta n g le d e fi n e d b y th e b o tto m o f th e n e c k , th e s h o u ld e r, a n d s id e s o f th e b o ttle . T h e n , w e c o u n t th e n u m b e r o f w h ite p ix e ls a b o v e th e m id p o in t o f th is r e c ta n g le . If th is n u m b e r is g r e a te r th a n a p r e - e s ta b lis h e d v a lu e , w e k n o w th a t e n o u g h liq u id is m is s in g a n d d e c la r e th e b o ttle im p r o p e r ly fi lle d . A s lig h tly m o r e s o p h is tic a te d te c h n iq u e w o u ld b e to a c tu a lly fi n d th e le v e l o f th e liq u id . T h is w o u ld c o n s is t o f lo o k in g fo r a h o r iz o n ta l e d g e in th e r e g io n w ith in th e b o ttle d e fi n e d b y th e s id e s o f th e b o ttle , th e b o tto m o f th e n e c k , a n d a lin e p a s s in g m id w a y b e tw e e n th e s h o u ld e r a n d th e b o tto m o f th e n e c k . A g r a d ie n t/ e d g e lin k in g a p p r o a c h , a s d e s c r ib e d in C h a p te r 1 0 , w o u ld b e s u ita b le . N o te h o w e v e r, 2 4 3 th a t c o m ta tio fi n d if n o e p le te ly n to re a n e d g d g e is fo u n d , th e r e g io n is e ith e r fi lle d (d a r k v a lu e s in th e r e g io n ) o r v o id o f liq u id (w h ite , o r n e a r w h ite v a lu e s in th e r e g io n ). A c o m p u s o lv e th e s e tw o p o s s ib le c o n d itio n s h a s to fo llo w if th e s y s te m fa ils to e . Problem 11.27 T h e k e y s p e c ifi c a tio n o f th e d e s ir e d s y s te m is th a t it b e a b le to d e te c t in d iv id u a l b u b b le s . N o s p e c ifi c s iz e s a r e g iv e n . W e a s s u m e th a t b u b b le s a r e n e a r ly r o u n d , a s s h o w n in th e te s t im a g e . O n e s o lu tio n c o n s is ts o f (1 ) s e g m e n tin g th e im a g e ; (2 ) p o s t- p r o c e s s in g th e r e s u lt; (3 ) fi n d in g th e b u b b le s a n d b u b b le c lu s te r s , a n d d e te r m in in g b u b b le s th a t m e r g e d w ith th e b o u n d a r y o f th e im a g e ; (4 ) d e te c tin g g r o u p s o f to u c h in g b u b b le s ; (5 ) c o u n tin g in d iv id u a l b u b b le s ; a n d (6 ) d e te r m in in g th e r a tio o f th e a r e a o c c u p ie d b y a ll b u b b le s to th e to ta l im a g e a r e a . (1 ) S e g m e n tin g th e im a g e . W e a s s u m e th a t th e s a m p le im a g e is tr u ly r e p r e s e n ta tiv e o f th e c la s s o f im a g e s th a t th e s y s te m w ill e n c o u n te r. T h e im a g e s h o w n in th e p r o b le m s ta te m e n t is ty p ic a l o f im a g e s th a t c a n b e s e g m e n te d b y a g lo b a l t h r e s h o ld . A s s h o w n b y t h e h is t o g r a m in F ig . P 1 1 .2 7 , t h e in t e n s it y le v e ls o f th e o b je c ts o f in te r e s t a r e h ig h o n th e g r a y s c a le . A s im p le a d a p tiv e th r e s h o ld m e th o d fo r d a ta th a t is th a t h ig h o n th e s c a le is to c h o o s e a th r e s h o ld e q u a l to th e m e a n p lu s a m u ltip le o f th e s ta n d a r d d e v ia tio n . W e c h o s e a th r e s h o ld e q u a l to m + 2 σ , w h ic h , fo r th e im a g e in th e p r o b le m s ta te m e n t, w a s 1 9 5 . T h e s e g m e n t e d r e s u lt is s h o w n o n t h e r ig h t o f F ig . P 1 1 .2 7 . O b v io u s ly t h is is n o t t h e o n ly a p p r o a c h w e c o u ld ta k e , b u t th is is a s im p le m e th o d th a t a d a p ts to o v e r a ll c h a n g e s in in te n s ity . ( 2 ) P o s t - p r o c e s s in g . A s s h o w n in t h e s e g m e n t e d im a g e o f F ig . P 1 1 .2 7 , m a n y o f th e b u b b le s a p p e a r a s b r o k e n d is k s , o r d is k s w ith in te r io r b la c k c o m p o n e n ts . T h e s e a r e m o s tly d u e e ith e r to r e fl e c tio n o r a c tu a l v o id s w ith in a b u b b le . W e c o u ld a tte m p t to b u ild a m o r p h o lo g ic a l p r o c e d u r e to r e p a ir a n d / o r fi ll th e b u b b le s . H o w e v e r, th is c a n tu r n in to a c o m p u ta tio n a lly e x p e n s iv e p r o c e s s th a t is n o t w a r r a n te d u n le s s s tr in g e n t m e a s u r e m e n t s ta n d a r d s a r e r e q u ir e d , a fa c t n o t m e n tio n e d in th e p r o b le m s ta te m e n t. A n a lte r n a tiv e is to c a lc u la te , o n a v e r a g e (a s d e te r m in e d fr o m a s e t o f s a m p le im a g e s ), th e p e r c e n ta g e o f b u b b le a r e a s th a t a r e fi lle d w ith b la c k o r h a v e b la c k ” b a y s ” w h ic h m a k e s th e ir b la c k a r e a s m e r g e w ith th e b a c k g r o u n d . T h e n , o n c e th e d im e n s io n s o f e a c h b u b b le (o r b u b b le c lu s te r ) h a v e b e e n e s ta b lis h e d , a c o r r e c tio n fa c to r b a s e d o n a r e a w o u ld b e a p p lie d . ( 3 ) F in d in g t h e b u b b le s . R e fe r to th e s o lu tio n t o P r o b le m 9 .3 6 . T h e s o lu tio n is b a s e d o n c o n n e c te d c o m p o n e n ts , w h ic h a ls o y ie ld s a ll b u b b le s a n d b u b b le c lu s te r s . 2 4 4 C H A P T E R 1 1 . P R O B L E M S O L U T IO N S F ig u r e P 1 1 .2 7 (4 ) In o r d e r to d e te c t b u b b le c lu s te r s w e m a k e u s e o f s h a p e a n a ly s is . F o r e a c h c o n n e c t e d c o m p o n e n t , w e fi n d t h e e ig e n a x e s ( s e e S e c t io n 1 1 .4 ) a n d t h e s t a n d a r d d e v ia tio n o f th e d a ta a lo n g th e s e a x e s (s q u a r e r o o t o f th e e ig e n v a lu e s o f th e c o v a r ia n c e m a tr ix ). O n e s im p le s o lu tio n is to c o m p u te th e r a tio o f th e la r g e to th e s m a ll v a r ia n c e o f e a c h c o n n e c te d c o m p o n e n t a lo n g th e e ig e n a x e s . A s in g le , u n ifo r m ly - fi lle d , p e r fe c tly r o u n d b u b b le w ill h a v e a r a tio o f 1 . D e v ia tio n s fr o m 1 in d ic a te e lo n g a tio n s a b o u t o n e o f th e a x e s . W e lo o k fo r e llip tic a l s h a p e s a s b e in g fo r m e d b y c lu s te r s o f b u b b le s . A th r e s h o ld to c la s s ify b u b b le s a s s in g le v s . c lu s te r s h a s to b e d e te r m in e d e x p e r im e n ta lly . N o te th a t s in g le p ix e ls o r p ix e l s tr e a k s o n e p ix e l w id e h a v e a s ta n d a rd d e v ia tio n o f z e r o , s o th e y m u s t b e p r o c e s s e d s e p a r a te ly . W e h a v e th e o p tio n o f c o n s id e r in g c o n n e c te d c o m p o n e n ts th a t c o n s is t o f o n ly o n e p ix e l to b e e ith e r n o is e , o r th e s m a lle s t d e te c ta b le b u b b le . N o in fo r m a tio n is g iv e n in th e p r o b le m s ta te m e n t a b o u t th is . In th e o r y , it is p o s s ib le fo r a c lu s te r to b e fo r m e d s u c h th a t its s h a p e w o u ld b e s y m m e tr ic a l a b o u t b o th a x e s , in w h ic h c a s e th e s y s te m w o u ld c la s s ify th e c lu s te r a s a s in g le b u b b le . R e s o lu tio n o f c o n fl ic ts s u c h a s th is w o u ld r e q u ir e a d d itio n a l p r o c e s s in g . H o w e v e r, th e r e is n o e v id e n c e in th e s a m p le im a g e to s u g g e s t th a t th is in fa c t is a p r o b le m . B u b b le c lu s te r s te n d to a p p e a r a s e llip tic a l s h a p e s . In c a s e s w h e r e th e r a tio o f th e s ta n d a r d d e v ia tio n s is c lo s e to th e th r e s h o ld v a lu e , w e c o u ld a d d a d d itio n a l p r o c e s s in g to re d u c e th e c h a n c e s o f m a k in g a m is ta k e . (5 ) C o u n tin g in d iv id u a l b u b b le s . A b u b b le th a t d o e s n o t m e r g e w ith th e b o r d e r o f th e im a g e o r is n o t a c lu s te r, is b y d e fi n itio n a s in g le b u b b le . T h u s , c o u n tin g th e s e b u b b le s is s im p ly c o u n tin g th e c o n n e c te d c o m p o n e n ts th a t h a v e n o t b e e n ta g g e d a s c lu s te r s o r m e r g e d w ith th e b o u n d a r y o f th e im a g e . (6 ) R a tio o f th e a r e a s . T h is r a tio is s im p ly th e n u m b e r o f p ix e ls in a ll th e c o n n e c te d c o m p o n e n ts p lu s th e c o r r e c tio n fa c to r s m e n tio n e d in (2 ), d iv id e d b y th e to ta l n u m b e r o f p ix e ls in th e im a g e . 2 4 5 t a o o T h e p r e c t. If, a s b u b b le , n e p ix e l. f o n e p ix o b le m a ls o a m e n tio n e d th e n th e s m F ro m th e p r e l is 1 0 m m . s k s fo r in (4 ), a lle s t b o b le m th e s iz e o f th e s m a lle s t w e e le c t to c a ll a o n e - p u b b le d im e n s io n d e te c s ta te m e n t, 7 0 0 p ix e ls c o b u b b le th e s y s te m c a n d e ix e l c o n n e c te d c o m p o n e n t ta b le is th e p h y s ic a l s iz e o f v e r 7 c m , s o th e d im e n s io n Chapter 12 Problem Solutions Problem 12.1 (a ) B y in s p (1 .5 , 0 .3 )T , c o lo r, a n d E q . ( 1 2 .2 - 5 e c tio n , th m 2 = (4 .3 v ir g in ic a , ). S u b s tit e m e a , 1 .3 )T re s p e u tin g n v e c to rs o f th e , a n d m 3 = (5 .5 c tiv e ly . T h e d e c th e p re c e d in g v d 1 (x ) = x T d 2 (x ) = x T d 3 (x ) = x T 1 − m 2 − m 3 − 1 m 2 1 2 1 2 m T m T m T 1 3 2 th r e e c la s , 2 .1 )T fo r is io n fu n c a lu e s o f m s e th tio e a s a re e c la n s a n v e , a s s re c t p p e s o f o rs ro x Ir is th e g iv m 1 = 1 .5 x 1 + 0 .3 x 2 − 1 .2 m 2 = 4 .3 x 1 + 1 .3 x 2 − 1 0 .1 m 3 = 5 .5 x 1 + 2 .1 x 2 − 1 7 .3 . (b ) T h e d e c is io n b o u n d a r ie s a re g iv e n b y th e e q u a tio n s d 1 2 (x ) = d 1 (x ) − d 2 (x ) = − 2 .8 x 1 − 1 .0 x 2 + 8 .9 = 0 d 1 3 (x ) = d 1 (x ) − d 3 (x ) = − 4 .0 x 1 − 1 .8 x 2 + 1 6 .1 = 0 d 2 3 (x ) = d 2 (x ) − d 3 (x ) = − 1 .2 x 1 − 0 .8 x 2 + 7 .2 = 0 . F ig u r e P 1 2 .1 s h o w s a p lo t o f t h e s e b o u n d a r ie s . Problem 12.2 F r o m th e d e fi n itio n o f th e E u c lid e a n d is ta n c e , D j @ @ ( x ) = @x − m j @= (x − m j )T (x − m j ) .1 2 4 7 / 2 im s e fo e s a te ly , m 1 = to s a , v e r s ir m g iv e n in : C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 4 8 F ig u r e P 1 2 .1 B e c a u s e D j (x ) is n o n - n e g a tiv e , c h o o s in g th e s m a lle s t D i n g t h e s m a l l e s t D 2j ( x ) , w h e r e D 2 j (x ) (x ) is th e s a m e a s c h o o s j @ @ @x − m j @2 = ( x − m j ) T ( x − m j ) = = x = x T x − 2 x T x − 2 T x m j T m + m j T j 1 − 2 m m j T j m . j W e n o te th a t th e te r m x T x is in d e p e n d e n t o f j (th a t is , it is a c o n s ta n t w ith re s p e c t t o j i n D 2j ( x ) , j = 1 , 2 , . . . ) . T h u s , c h o o s i n g t h e m i n i m u m o f D 2j ( x ) i s e q u i v a " # l e n t t o c h o o s i n g t h e m a x i m u m o f x T m j − 12 m Tj m j . Problem 12.3 T h e e q u a tio n o f th e d e c is io n b o u n d a r y b e tw e e n a p a ir o f m e a n v e c to r s is d i j (x ) = x T (m i − m j ) − 1 2 (m i T m i − m T j m j ). T h e m id p o in t b e t w e e n m i a n d m j is (m i + m j )/ 2 ( s e e F ig . P 1 2 .3 ) . F ir s t , w e s h o w th a t th is p o in t is o n th e b o u n d a r y b y s u b s titu tin g it fo r x in th e a b o v e e q u a tio n 2 4 9 F ig u r e P 1 2 .3 a n d s h o w in g th a t th e r e s u lt is e q u a l to 0 : 1 2 (m i T m i − m T j m j ) − 2 1 (m T i m T j − m i m j ) 1 = 2 1 − = N e x t, w e s h b o u n d a r y . T (m i − m j ) is h y p e r p la n e o w th a h e re a r in th e w ith e q t th e e s e v s a m e u a tio v e c e ra l d ir n w to r (m i w a y s to e c tio n a 1 x 1 + w − m j ) is p e r d o th is . P e r h s th e u n it n o 2 x 2 + ...w n x n u = w k w T (m 2 i (m m i − m T m i i T j − m m j ) T j m j ) 0 . p e n d ic u a p s th e r m a l to + w n + 1 la r to e a s ie s th e h y = 0 , th th e h y p e rp t is to s h o w p e r p la n e . F e u n it n o r m la n e th a t o r a a l is o o k w h e r e w o = (w 1 , w 2 , ..., w n )T . C o m p a r in g t h e a b o v e e q u a t io n fo r d i j (x ) w it h t h e g e n e r a l e q u a tio n o f a h y p e r p la n e ju s t g iv e n , w e s e e th a t w o = (m i − m j ) a n d w n + 1 = − ( m Ti m i − m Tj m j ) / 2 . T h u s , t h e u n i t n o r m a l o f o u r d e c i s i o n b o u n d a r y i s u = (m @ @m − m j) i i @ − m j@ w h ic h is in th e s a m e d ire c tio n a s th e v e c to r (m i − m j ). T h is c o n c lu d e s th e p r o o f. C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 5 0 F ig u r e P 1 2 .4 Problem 12.4 T h e s o l u t i o n i s s h o w n i n F i g . P 1 2 . 4 , w h e r e t h e x ’s a r e t r e a t e d a s v o l t a g e s a n d t h e Y ’s d e n o t e i m p e d a n c e s . F r o m b a s i c c i r c u i t t h e o r y , t h e c u r r e n t s , I ’s , a r e t h e p r o d u c ts o f th e v o lta g e s tim e s th e im p e d a n c e s . Problem 12.5 A s s u m e th a t th e m a s k is o f s iz e J × K . F o r a n y v a lu e o f d is p la c e m e n t (s , t ), w e c a n e x p r e s s th e a r e a o f th e im a g e u n d e r th e m a s k , a s w e ll a s th e m a s k w (x , y ), in v e c to r fo r m b y le ttin g th e fi r s t r o w o f th e s u b im a g e u n d e r th e m a s k r e p r e s e n t th e fi r s t K e le m e n ts o f a c o lu m n v e c to r a , th e e le m e n ts o f n e x t r o w th e n e x t K e le m e n ts o f a , a n d s o o n . A t th e e n d o f th e p r o c e d u r e w e s u b tr a c t th e a v e r a g e v a lu e o f th e in te n s ity le v e ls in th e s u b im a g e fr o m e v e r y e le m e n t o f a . T h e v e c to r a is o f s iz e ( J × K ) × 1 . A s im ila r a p p r o a c h y ie ld s a v e c to r, b , o f th e s a m e s iz e , fo r th e m a s k w (x ,y ) m in u s its a v e r a g e . T h is v e c to r d o e s n o t c h a n g e a s (s ,t ) v a r ie s b e c a u s e th e c o e ffi c ie n ts o f th e m a s k a re fi x e d . W ith th is c o n s tr u c tio n in m in d , w e s e e t h a t t h e n u m e r a t o r o f E q . ( 1 2 .2 - 8 ) is s im p ly t h e v e c t o r in n e r - p r o d u c t a T b . S im ila r ly , th e fi r s t te r m in th e d e n o m in a to r is th e n o r m s q u a r e d o f a , d e n o te d a T a = k a k 2 , w h ile th e s e c o n d te r m h a s a s im ila r in te r p r e ta tio n fo r b . T h e c o r r e la tio n c o e ffi c ie n t th e n b e c o m e s T b a )(b T a γ (s ,t ) = (a T b ) 1 / 2 . W h e n a = b (a p e r fe c t m a tc h ), γ (s ,t ) = k a k 2 / k a k k a k = 1 , w h ic h is th e m a x im u m v a lu e o b ta in a b le b y th e a b o v e e x p r e s s io n . S im ila r ly , th e m in im u m v a lu e o c c u r s 2 5 1 w h e n a = − b , in w h ic h c a s e γ (s , t ) = − 1 . T h u s , a lth o u g h th e v e c to r a v a r ie s in g e n e r a l fo r e v e r y v a lu e o f (s , t ), th e v a lu e s o f γ (s , t ) a r e a ll in th e r a n g e [− 1 , 1 ]. Problem 12.6 T h e s o lu tio n to th e fi r s t p a r t o f th is p r o b le m is b a s e d o n b e in g a b le to e x tr a c t c o n n e c te d c o m p o n e n ts (s e e C h a p te r s 2 a n d 1 1 ) a n d th e n d e te r m in in g w h e th e r a c o n n e c te d c o m p o n e n t is c o n v e x o r n o t (s e e C h a p te r 1 1 ). O n c e a ll c o n n e c te d c o m p o n e n ts h a v e b e e n e x tr a c te d w e p e r fo r m a c o n v e x ity c h e c k o n e a c h a n d r e je c t th e o n e s th a t a r e n o t c o n v e x . A ll th a t is le ft a fte r th is is to d e te r m in e if th e r e m a in in g b lo b s a r e c o m p le te o r in c o m p le te . T o d o th is , th e r e g io n c o n s is tin g o f t h e e x t r e m e r o w s a n d c o l u m n s o f t h e i m a g e i s d e c l a r e d a r e g i o n o f 1 ’s . T h e n if th e p ix e l- b y - p ix e l A N D o f th is r e g io n w ith a p a r tic u la r b lo b y ie ld s a t le a s t o n e r e s u lt th a t is a 1 , it fo llo w s th a t th e a c tu a l b o u n d a r y to u c h e s th a t b lo b , a n d th e b lo b is c a lle d in c o m p le te . W h e n o n ly a s in g le p ix e l in a b lo b y ie ld s a n A N D o f 1 w e h a v e a m a r g in a l r e s u lt in w h ic h o n ly o n e p ix e l in a b lo b to u c h e s th e b o u n d a r y . W e c a n a r b itr a r ily d e c la r e th e b lo b in c o m p le te o r n o t. F r o m th e p o in t o f v ie w o f im p le m e n ta tio n , it is m u c h s im p le r to h a v e a p r o c e d u r e th a t c a lls a b lo b in c o m p le te w h e n e v e r th e A N D o p e r a tio n y ie ld s o n e o r m o r e r e s u lts v a lu e d 1 . A fte r th e b lo b s h a v e b e e n s c r e e n e d u s in g th e m e th o d ju s t d is c u s s e d , th e y n e e d to b e c la s s ifi e d in to o n e o f th e th r e e c la s s e s g iv e n in th e p r o b le m s ta te m e n t. W e p e r fo r m th e c la s s ifi c a tio n p r o b le m b a s e d o n v e c to r s o f th e fo r m x = (x 1 , x 2 )T , w h e r e x 1 a n d x 2 a r e , r e s p e c tiv e ly , th e le n g th s o f th e m a jo r a n d m in o r a x is o f a n e llip tic a l b lo b , th e o n ly ty p e le ft a fte r s c r e e n in g . A lte r n a tiv e ly , w e c o u ld u s e t h e e ig e n a x e s fo r t h e s a m e p u r p o s e . ( S e e S e c t io n 1 1 .2 .1 o n o b t a in in g t h e m a jo r a x e s o r t h e e n d o f S e c tio n 1 1 .4 r e g a r d in g th e e ig e n a x e s .) T h e m e a n v e c to r o f e a c h c la s s n e e d e d to im p le m e n t a m in im u m d is ta n c e c la s s ifi e r is g iv e n in th e p r o b le m s ta te m e n t a s th e a v e r a g e le n g th o f e a c h o f th e tw o a x e s fo r e a c h c la s s o f b lo b . If‘ th e y w e r e n o t g iv e n , th e y c o u ld b e o b ta in e d b y m e a s u r in g th e le n g th o f th e a x e s fo r c o m p le te e llip s e s th a t h a v e b e e n c la s s ifi e d a p r io r i a s b e lo n g in g to e a c h o f th e th r e e c la s s e s . T h e g iv e n s e t o f e llip s e s w o u ld th u s c o n s titu te a tr a in in g s e t, a n d le a r n in g w o u ld c o n s is t o f c o m p u tin g th e p r in c ip a l a x e s fo r a ll e llip s e s o f o n e c la s s a n d th e n o b ta in in g th e a v e r a g e . T h is w o u ld b e r e p e a te d fo r e a c h c la s s . A b lo c k d ia g r a m o u tlin in g th e s o lu tio n to th is p r o b le m is s tr a ig h tfo r w a rd . Problem 12.7 ( a ) B e c a u s e it is g iv e n th a t th e p a tte r n c la s s e s a r e g o v e r n e d b y G a u s s ia n d e n s itie s , o n ly k n o w le d g e o f th e m e a n v e c to r a n d c o v a r ia n c e m a tr ix o f e a c h c la s s a r e C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 5 2 x2 6 + d(x) =0 x1 6 F ig u r e P 1 2 .7 r e q u ir e d to s p e c ify th e B a y e s c la s s ifi e r. S u b s titu tin g th e g iv e n p a tte r n s in to E q s . ( 1 2 .2 - 2 2 ) a n d ( 1 2 .2 - 2 3 ) y ie ld s 1 m 1 = 1 m 5 = 2 C 5 = 1 1 0 0 1 − 1 = C 1 a n d C B e c a u s e C 1 = C 2 = d is ta n c e c la s s ifi e r : 1 0 0 1 − 1 = C 2 . I , th e d e c is io n fu n c tio n s a re th e s a m e a s fo r a m in im u m d 1 T (x ) = x m 2 (x ) = x T m 2 1 − 1 a n d d = 2 − 1 2 T m 2 m 1 2 T m m 2 1 = 1 .0 x = 5 .0 x 1 1 + 1 .0 x + 5 .0 x 2 2 − 1 .0 − 2 5 .0 . T h e B a y e s d e c is io n b o u n d a r y is g iv e n b y th e e q u a tio n d (x ) = d o r d (x ) = − 4 .0 x 1 − 4 .0 x 2 + 2 4 .0 = 0 . ( b ) F ig u r e P 1 2 .7 s h o w s a p lo t o f t h e b o u n d a r y . 1 (x ) − d 2 (x ) = 0 , 2 5 3 Problem 12.8 ( a ) A s in P r o b le m 1 2 .7 , m C 1 = 1 1 0 0 2 1 0 1 = m 1 = 0 m ; 0 = 1 0 0 C − 1 0 = 2 1 1 0 0 1 jC 1 j = 0 .2 5 ; a n d C = 2 2 1 0 0 ; 1 − 1 C 2 = 1 2 1 0 0 1 jC 2 j = 4 .0 0 . ; B e c a u s e t h e c o v a r ia n c e m a t r ic e s a r e n o t e q u a l, it fo llo w s fr o m E q . ( 1 2 .2 - 2 6 ) t h a t A 1 1 2 0 T x x d 1 (x ) = − ln (0 .2 5 ) − 0 2 2 2 = 1 − 2 2 ln (0 .2 5 ) − (x 2 + x 1 ) 2 a n d d 2 (x ) = 1 − = ln (4 .0 0 ) − 2 − 1 2 A 1 ln (4 .0 0 ) − x 2 1 4 (x 0 .5 0 T 2 1 2 + x 2 0 0 .5 x ) w h e r e th e te r m ln P (! j ) w a s n o t in c lu d e d b e c a u s e it is th e s a m e fo r b o th d e c is io n fu n c tio n s in th is c a s e . T h e e q u a tio n o f th e B a y e s d e c is io n b o u n d a r y is d (x ) = d 1 (x ) − d 2 (x ) = 1 .3 9 − 4 3 (x 2 1 + x 2 2 ) = 0 . ( b ) F ig u r e P 1 2 .8 s h o w s a p lo t o f t h e b o u n d a r y . Problem 12.9 T h e b a s ic m e c h a n ic s a r e t h e s a m e a s in P r o b le m 1 2 .6 , b u t w e h a v e t h e a d d itio n a l re q u ire m e n t o f c o m p u tin g c o v a r ia n c e m a tr ic e s fr o m th e tr a in in g p a tte r n s o f e a c h c la s s . C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 5 4 x2 d(x) =0 + x1 1.36 F ig u r e P 1 2 .8 Problem 12.10 F r o m b a s ic p r o b a b ility th e o r y , p (c / x )p (x ). p (c ) = x F o r a n y p a tte r n b e lo n g in g to c la s s ! j , p (c / x ) = p (! p (! p (c ) = j j / x ). T h e re fo re , / x )p (x ). x S u b s titu tin g in to th is e q u a tio n th e fo r m u la p (! p (x / ! p (c ) = j j / x ) = p (x / ! )p (! j j )p (! j )/ p (x ) g iv e s ). x B e c m iz fo r th e th e a u s e in g p j = 1 c la s s p ro b th (x ,2 fr a b e a rg u m e n t o f / ! j )p (! j ) fo r , ..., W , a n d u s o m w h ic h x c a ility o f e r r o r is th e s u m m e a c h j . T h e th e la r g e m e , th e n p m in im iz e io n is p o s itiv e , p (c is , if fo r e a c h x w e v a lu e e a c h tim e a ) w ill b e m a x im iz e d b y th is p r o c e d u re . a t a t s t (c ) is m a x im iz c o m p u te p ( s th e b a s is f d . S in c e p (e e d b y m a x x / ! j )p (! o r s e le c tin ) = 1 − p (c i) j g ), Problem 12.11 ( a ) F o r c la s s ! 1 w e le t y (1 ) = (0 , 0 , 0 , 1 )T , y (2 ) = (1 , 0 , 0 , 1 )T , y (3 ) = (1 , 0 , 1 , 1 )T , y (4 ) = (1 , 1 , 0 , 1 )T . S im ila r ly , fo r c la s s ! 2 , y (5 ) = (0 , 0 , 1 , 1 )T , y (6 ) = (0 , 1 , 1 , 1 )T , y (7 ) = (0 ,1 ,0 ,1 )T , y (8 ) = (1 ,1 ,1 ,1 )T . T h e n , u s in g c = 1 a n d w (1 ) = (− 1 ,− 2 ,− 2 ,0 ) T 2 5 5 it fo llo w s fr o m E q s . ( 1 2 .2 - 3 4 ) t h r o u g h ( 1 2 .2 - 3 6 ) t h a t : w w w w w w w w (1 (2 (3 (4 (5 (6 (7 (8 )T y ( )T y ( )T y ( )T y ( )T y ( )T y ( )T y ( )T y ( 1 ) = 2 ) = 3 ) = 4 ) = 5 ) = 6 ) = 7 ) = 8 ) = 0 , w w w w w w w w 0 , 0 , 2 , 2 , − 2 , 0 , − 3 , (2 ) (3 ) (4 ) (5 ) (6 ) (7 ) (8 ) (9 ) = w = w = w = w = w = w = w = w (1 ) (2 ) (3 ) (4 ) (5 ) (6 ) (7 ) (8 ) + y ( + y ( + y ( = (1 − y ( = (− − y ( = (1 1 ) = 2 ) = 3 ) = ,− 2 5 ) = 1 ,− 7 ) = ,− 3 (− 1 ,− 2 ,− (0 ,− 2 ,− 2 (1 ,− 2 ,− 1 ,− 1 ,3 )T ; (− 1 ,− 2 ,− 2 ,− 2 ,2 )T (1 ,− 3 ,− 2 ,− 2 ,1 )T . 2 ,1 )T ; ,2 )T ; ,3 )T ; 2 ,2 )T ; ; ,1 )T ; A c o m p le te ite r a tio n th r o u g h a ll p a tte r n s w ith n o e r r o r s w a s n o t a c h ie v e d . T h e r e fo r e , th e p a tte r n s a r e r e c y c le d b y le ttin g y (9 ) = y (1 ), y (1 0 ) = y (2 ), a n d s o o n , w h ic h g iv e s w w w w w w w w (9 (1 (1 (1 (1 (1 (1 (1 )T y 0 )T 1 )T 2 )T 3 )T 4 )T 5 )T 6 )T A g a in , a c o m p le s o th e p a tte r n s a g iv e s : w (1 7 w (1 8 w (1 9 w (2 0 w (2 1 (9 y ( y ( y ( y ( y ( y ( y ( ) = 1 0 1 1 1 2 1 3 1 4 1 5 1 6 ) ) ) ) ) ) ) 1 , = = = = = = = w w w w w w w w 2 , 0 , 1 , 1 , − 4 , − 2 , − 2 , (1 (1 (1 (1 (1 (1 (1 (1 0 ) 1 ) 2 ) 3 ) 4 ) 5 ) 6 ) 7 ) = w = w = w = w = w = w = w = w (9 (1 (1 (1 (1 (1 (1 (1 ) = 0 ) 1 ) 2 ) 3 ) 4 ) 5 ) 6 ) (1 ,− (1 , y (1 (2 , y (1 (2 , (2 , (2 , = + = − = = = 3 ,− − 3 , 1 ) = − 3 , 3 ) = − 3 , − 3 , − 3 , 2 ,1 − 2 , (2 , − 1 , (2 , − 2 , − 2 , − 2 , )T ; 1 )T − 3 2 )T − 3 1 )T 1 )T 1 )T ; ,− 1 ,2 )T ; ; ,− 2 ,1 )T ; ; ; . te ite r a tio n o v e r a ll p a tte r n s w ith o u t a n e r r o r w a s n o t a c h ie v e d , r e r e c y c le d b y le ttin g y (1 7 ) = y (1 ), y (1 8 ) = y (2 ), a n d s o o n , w h ic h )T y )T y )T y )T y )T y (1 7 (1 8 (1 9 (2 0 (2 1 ) = 1 ) = 3 ) = 1 ) = 0 ) = 0 , , , , , w w w w w (1 8 (1 9 (2 0 (2 1 (2 2 ) = w ) = w ) = w ) = w ) = w (1 7 (1 8 (1 9 (2 0 (2 1 ) = ( ) = ( ) = ( ) + y ) − y 2 ,− 2 ,− 2 ,− (2 0 (2 1 3 ,− 3 ,− 3 ,− ) = ) = 2 ,1 2 ,1 2 ,1 (3 ,− (3 ,− )T ; )T ; )T ; 2 ,− 2 ,2 )T ; 2 ,− 3 ,1 )T . It is e a s ily v e r ifi e d th a t n o m o r e c o r r e c tio n s ta k e p la c e a fte r th is s te p , s o w (2 2 ) = (3 , − 2 , − 3 , 1 )T is a s o lu tio n w e ig h t v e c to r. (b ) T h e d e c is io n s u r fa c e is g iv e n b y th e e q u a tio n w T y = 3 y 1 − 2 y 2 − 3 y 3 + 1 = 0 . A s e c t io n o f t h is s u r fa c e is s h o w n s c h e m a t ic a lly in F ig . P 1 2 .1 1 . T h e p o s it iv e s id e o f th e s u r fa c e fa c e s th e o r ig in . C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 5 6 F ig u r e P 1 2 .1 1 Problem 12.12 W e s ta r t b y ta k in g th e p a r tia l d e r iv a tiv e o f J w ith re s p e c t to w : @ J = @ w 1 2 y s g n (w T y ) − y w h e re , b y d e fi n itio n , s g n (w T y ) = 1 if w T y > 0 , a n d s g n (w T y ) = − 1 o th e r w is e . S u b s titu tin g th e p a r tia l d e r iv a tiv e in to th e g e n e r a l e x p re s s io n g iv e n in th e p r o b le m s ta te m e n t g iv e s 4 c 3 y (k ) − y (k )s g n w (k )T y (k ) w (k + 1 ) = w (k ) + 2 w h e re y (k ) is th e tr a in in g p a tte r n b e in g c o n s id e re d a t th e k th ite r a tiv e s te p . S u b s titu tin g th e d e fi n itio n o f th e s g n fu n c tio n in to th is r e s u lt y ie ld s w (k + 1 ) = w (k ) + c 0 y (k ) if w (k )T y (k ) o th e r w is e w h e r e c > 0 a n d w (1 ) is a r b itr a r y . T h is e x p r e s s io n a g r e e s w ith th e fo r m u la tio n g iv e n in th e p r o b le m s ta te m e n t. Problem 12.13 L e t th e tr a in in g s e t o f p a tte r n s b e d e n o te d b y y 1 ,y 2 ,... ,y N . It is a s s u m e d th a t th e tr a in in g p a tte r n s o f c la s s ! 2 h a v e b e e n m u ltip lie d b y − 1 . If th e c la s s e s a r e lin e a r ly s e p a r a b le , w e w a n t to p r o v e th a t th e p e r c e p tr o n tr a in in g a lg o r ith m y ie ld s 2 5 7 a s o lu tio n w e ig h t v e c to r, w ∗ , w ith th e p r o p e r ty ∗ T w w h e re T 0 is a n o n r ith m (w ith c = 1 ) w (k ) + y i(k ) o th e r S u p p o s e th a t w (th e s e a r e th e o n ly m a y w r ite n is w e e g a t e x p is e . re ta in d ic y i ≥ T 0 iv e th r e s h o ld . W ith th is n o ta tio n , th e P e r c e p tr o n a lg o re s s e d a s w (k + 1 ) = w (k ) if w T (k )y i (k ) ≥ T 0 o r w (k + 1 ) = in o n ly th e v a lu e s o f k fo r w h ic h a c o r r e c tio n ta k e s p la c e e s o f in te re s t). T h e n , re - a d a p tin g th e in d e x n o ta tio n , w e w (k + 1 ) = w (k ) + y i(k ) a n d T w (k )y i (k ) ≤ T 0 . W ith th e s e s im p lifi c a tio n s in m in d , th e p r o o f o f c o n v e r g e n c e is a s fo llo w s : F r o m th e a b o v e e q u a tio n , w (k + 1 ) = w (1 ) + y i(1 ) + y i(2 ) + ··· + y i(k ). T a k in g th e in n e r p r o d u c t o f th e s o lu tio n w e ig h t v e c to r w ith b o th s id e s o f th is e q u a tio n g iv e s T w E a c h te r m y i T (k + 1 )w ∗ T = w (1 )w ∗ T + y ∗ (1 )w i T + y ∗ (2 )w i T i (k )w ∗ . ( j )w ∗ , j = 1 , 2 , ..., k , is le s s t h a n T 0 , s o w T ∗ (k + 1 )w T ≥ w (1 )w 2 U s in g th e C a u c h y - S c h w a r tz in e q u a lity , k a k T w (k + 1 )w ∗ 2 k b k ∗ + k T 0 . 2 @ @2 @ @2 ≤ @w T ( k + 1 ) @ @w ∗ @ @ @ @w T ( k + 1 ) @2 ≥ A n o th e r lin e o f r e a s o F ro m a b o v e , @ @w ( j + 1 b )2 , r e s u lts in T ≥ (a o r o r + ··· + y w T (k + 1 )w k w ∗k 2 ∗ 2 . @ @2 n i n g l e a d s t o a c o n t r a d i c t i o n r e g a r d i n g @w T ( k + 1 ) @. @ @2 @2 ) @ = @w ( j ) @ + 2 w @ @ @ @ @w ( j + 1 ) @2 − @w ( j ) @2 = 2 w T T @ @2 ( j ) y i ( j ) + @y i ( j ) @ @ @2 ( j ) y i ( j ) + @y i ( j ) @ . C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 5 8 L e t Q = m a x jjy i ( j ) jj2 . T h e n , b e c a u s e w T (j )y i(j ) ≤ i T 0 , @ @ @ @ @w ( j + 1 ) @2 − @w ( j ) @2 ≤ 2 T + Q . 0 A d d in g th e s e in e q u a litie s fo r j = 1 , 2 , . . . , k y ie ld s @ @ @w ( j + 1 ) @2 ≤ k w ( 1 ) k 2 + [2 T @ T h i s i n e q u a l i t y e s t a b l i s h e s a b o u n d o n @w ( j + 1 ) la r g e k w ith th e b o u n d e s ta b lis h e d b y o u r e a r lie r la r g e r th a n k m , w h ic h is a s o lu tio n to th e e q u a tio w T ∗ (k + 1 )w + k T h is e q u a tio n s a y s th a t k m is a lg o r ith m c o n v e r g e s in a fi n ite th e p a tte r n s o f th e tr a in in g s e t N o te : T h e s p e c ia l c a s e w ith U n d e r th is c o n d itio n w e h a v e T T @2 @t h a t c o n fl i c t s f o r s u f fi c i e n t l y in e q u a lity . In fa c t, k c a n b e n o n 2 0 2 = k w (1 )k 2 k w ∗k w m + Q ] k . 0 fi n ite , n u m b a r e lin T 0 = th u s p r o v in e r o f s te p s t e a r ly s e p a r a 0 is p r o v e d ∗ (k + 1 )w T ≥ w + [2 T + Q ] k m . g th a t th e p e rc e p tr o n tr a in in g o a s o lu tio n w e ig h t v e c to r w ∗ if b le . in a s lig h tly d iffe r e n t m a n n e r. ∗ (1 )w 0 + k a w h e re a = m in y i T i ∗ (j )w . B e c a u s e , b y h y p o th e s is , w ∗ is a s o lu tio n w e ig h t v e c to r, w e k n o w th a t 0 . A ls o , b e c a u s e w T ( j )y i ( j ) ≤ (T = 0 ), @ @ @ @ @w ( j + 1 ) @2 − @w ( j ) @2 ≤ y i T (j )w ∗ ≥ @ @ @y i ( j ) @2 ≤ Q . T h e re s t o f th e p r o o f re m a in s th e s a m e . T h e b o u n d o n th e n u m b e r o f s te p s is th e v a lu e o f k m th a t s a tis fi e s th e fo llo w in g e q u a tio n : w T (1 )w ∗ + k k w ∗k 2 m a 2 = k w (1 )k 2 + Q k m . 2 5 9 Problem 12.14 T h e s in g le d e c is io n fu n c tio n th a t im p le m e n ts a m in im u m d is ta n c e c la s s ifi e r fo r tw o c la s s e s is o f th e fo r m 1 d ij (x ) = x T (m i − m j) − ( m Ti m i − m Tj m j ) . 2 T h u s , fo a n d , w h a re o n t (m i − m fu n c tio n r a p a r tic u la r e n d ij(x ) < 0 h e b o u n d a r y j ) a n d w n + 1 in th e fo r m p a tte r n v e c to , x is a s s ig n e d (h y p e r p la n e ) = − 12 ( m Ti m i − r x , w h e n d ij (x ) > to c la s s ! 2 . V a lu s e p a r a tin g th e t m Tj m j ) , w e c a n T d (x ) = w x − w n + 1 0 , x is e s o f x w o c la e x p re s a s s fo r s s e s s th ig w . e n e d h ic B y a b o to c la s s ! 1 h d ij (x ) = 0 le ttin g w = v e d e c is io n . T h is is r e c o g n iz e d a s a lin e a r d e c is io n fu n c tio n in n d im e n s io n s , w h ic h is im p le m e n te d b y a s in g le la y e r n e u r a l n e tw o r k w ith c o e ffi c ie n ts w k = (m i k − m n + 1 = − a n d θ = w ) j k 1 k = 1 ,2 ,... ,n T (m 2 m i i T j − m m j ). Problem 12.15 T h e T h e th e n fo r t a p p r id e a e q u w o p d o a c is t a te a tte i j h to o c o c o e r n c (x ) s o lv in g th is p r m b in e th e d e c ffi c ie n ts . F o r e la s s e s is o b ta in = d − (x ) = ln P (! i ) − ln P (! (x ) − d i 1 2 (m i o b le m is b a s ic a lly th e s a m e a s in P r o b le m 1 2 .1 4 . is io n fu n c tio n s in th e fo r m o f a h y p e r p la n e a n d q u a l c o v a r ia n c e m a tr ic e s , th e d e c is io n fu n c tio n e d E q . ( 1 2 .2 - 2 7 ) : j − m j )T C − 1 (m j ) + x T C − 1 (m i − m j ) − m j). i A s in P r o b le m 1 2 .1 4 , t h is is r e c o g n iz e d a s a lin e a r d e c is io n fu n c t io n o f t h e fo r m T d (x ) = w x − w n + 1 w h ic h is im p le m e n te d b y a s in g le la y e r p e r c e p tr o n w ith c o e ffi c ie n ts w k = v k = 1 ,2 ,... ,n k a n d θ = w w h e re th e v k n + 1 = ln P (! i ) − ln P (! j ) + x a r e e le m e n ts o f th e v e c to r v = C − 1 (m i − m j). T C − 1 (m i − m j) C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 6 0 F ig u r e P 1 2 .1 7 Problem 12.16 (a ) W h e n P (! i) = P (! (b ) N o . T h e m in im u th e p e r p e n d ic u la r b d e n s itie s a re k n o w n m u m d e c is io n fu n c d e lta r u le fo r tr a in in it c a n n o t b e e x p e c te j m is e , t tio g a d t ) a n d C = I. d is ta c to r h e B n in n e u o y ie n c e c la s s ifi e r im p le m e n ts a d e c is io n fu n c tio n th a t is o f th e lin e jo in in g th e tw o m e a n s . If th e p r o b a b ility a y e s c la s s ifi e r is g u a r a n te e d to im p le m e n t a n o p tith e m in im u m a v e r a g e lo s s s e n s e . T h e g e n e r a liz e d r a l n e tw o r k s a y s n o th in g a b o u t th e s e tw o c r ite r ia , s o ld t h e d e c is io n fu n c t io n s in P r o b le m s 1 2 .1 4 o r 1 2 .1 5 . Problem 12.17 T h e c la s s e s a n d b o u n d a r y n e e d e d t o s e p a r a t e t h e m a r e s h o w n in F ig . P 1 2 .1 7 ( a ) . T h e b o u n d a r y o f m in im u m c o m p le x ity in th is c a s e is a tr ia n g le , b u t it w o u ld b e s o tig h t in th is a r r a n g e m e n t th a t e v e n s m a ll p e r tu r b a tio n s in th e p o s itio n o f th e p a tte r n s c o u ld r e s u lt in c la s s ifi c a tio n e r r o r s . T h u s , w e u s e a n e tw o r k w ith th e c a p a b ility to im p le m e n t 4 s u r fa c e s (lin e s ) in 2 D . T h e n e tw o r k , s h o w n in F ig . P 1 2 .1 7 ( b ) , is a n e x t e n s io n o f t h e c o n c e p t s d is c u s s e d in t h e t e x t in c o n n e c t io n w it h F ig . 1 2 .2 2 . In t h is c a s e , t h e o u t p u t n o d e a c t s lik e a n A N D g a t e w it h 4 in p u t s . T h e o u tp u t n o d e o u tp u ts a 1 (h ig h ) w h e n th e o u tp u ts o f th e p re c e d in g 4 n o d e s a r e a ll h ig h s im u lta n e o u s ly . T h is c o r r e s p o n d s to a p a tte r n b e in g o n th e + s id e o f a ll 4 lin e s a n d , th e r e fo r e , b e lo n g in g to c la s s ! 1 . A n y o th e r c o m b in a tio n y ie ld s a 0 (lo w ) o u tp u t, in d ic a tin g c la s s ! 2 1 . Problem 12.18 A ll th (x 1 ,x n o r a u s e d (B e c a a t T 2 ) x is to u s is n e e d e d , w h e re x 1 o f th e b lo tr a in a n e e th e p a tte is is b s u r r n to th c o a l s a g e n e e le n m p r n e tw re in ra te fo r e g th o f th e is in g th e o r k u s in g 2 D , it is u a c h c la s s tr a in in g v e c to r s o f th m a jo r a x is a n d x 2 is th e le n g th tr a in in g s e t. T h e s e v e c to r s w o u , fo r e x a m p le , th e g e n e r a liz e d s e fu l to p o in t o u t to s tu d e n ts th e fo r m x = o f th e m ild th e n b e d e lta r u le . a t th e n e u - 2 6 1 r a l n e tw o r k c o u ld b e d e b e p lo tte d , th e d e c is io n its c o e ffi c ie n ts u s e d to s a p a r t w ith re s p e c t to th m e n tin g a lin e a r d e c is io s ig n e d b y in b o u n d a r y o p e c ify th e n e e ir s p re a d , s n fu n c tio n c s p e c tio n in th e s f m in im u m c o m u ra l n e tw o rk . In o m o s t lik e ly a s o u ld d o t h e jo b .) e n s e th a p le x ity o th is c a s e in g le la y t th e c la s s e s c o u ld b ta in e d , a n d th e n th e c la s s e s a r e fa r e r n e tw o r k im p le - Problem 12.19 T h is p r o b le m , a lth o u g h it is a s im p le e x e r c is e in d iffe r e n tia tio n , is in te n d e d to h e lp th e s tu d e n t fi x in m in d th e n o ta tio n u s e d in th e d e r iv a tio n o f th e g e n e r a liz e d d e lt a r u le . F r o m E q . ( 1 2 .2 - 5 0 ) , w it h θ 0 = 1 , h j (I j ) = 1 + e 1 $2 − N K k = 1 w O j k %. + θ k j B e c a u s e , fr o m E q . ( 1 2 .2 - 4 8 ) , N I K = j w O j k k k = 1 it fo llo w s th a t h j 1 (I j ) = [ − 1 + e I j + θ . ] j T a k in g th e p a r tia l d e r iv a tiv e o f th is e x p re s s io n w ith re s p e c t to I h 0 j @ h (I j ) = (I j ) j @ I j = [ − e $ 1 + e I j + θ − [ j ] I j + θ j ] F r o m E q . ( 1 2 .2 - 4 9 ) O j = h j (I j ) = 1 [ − 1 + e I j + θ ] j . It is e a s ily s h o w n th a t O j (1 − O j) = e $ 1 + e − [ − I j + θ [ I j + θ s o h T h is c o m p le te s th e p r o o f. 0 j j (I j ) = O j (1 − O j). ] j ] %2 %2 . j g iv e s C H A P T E R 1 2 . P R O B L E M S O L U T IO N S 2 6 2 Problem 12.20 T h e fi rs n o n -n e fa c t th a T o p t p g a t k ro a r tiv is v e t o e , in th f E q . (1 2 s o D (A , fi n ite w e th ird p .3 - 3 B ) = h e n a r t ) is p r o 1 / k ≥ (a n d o w e u s e v e d 0 . n ly th e b y n o tin S im ila r ly w h e n ) th d e fi n itio g th a t t , th e s e e s h a p n o f D h e c o e s to d e n d a re w r g r e e o f s im ila r ity , k , is p a r t fo llo w s fr o m th e id e n tic a l. ite D (A ,C ) ≤ m a x [D (A , B ),D (B ,C )] a s 1 k ≤ m a x a c k 1 , a b k 1 b c o r, e q u iv a le n tly , k a c ≥ m in [k a b ,k b c ] w h e r e k i j is th e d e g r e e o f s im ila r ity b e tw e e n s h a p e i a n d s h a p e j . R e c a ll fr o m th e d e fi n itio n th a t k is th e la r g e s t o r d e r fo r w h ic h th e s h a p e n u m b e r s o f s h a p e i a n d s h a p e j s t ill c o in c id e . A s F ig . 1 2 .2 4 ( b ) illu s t r a t e s , t h is is t h e p o in t a t w h ic h th e fi g u re s ” s e p a r a te ” a s w e m o v e fu r th e r d o w n th e tre e (n o te th a t k in c re a s e s a s w e m o v e fu r th e r d o w n th e tre e ). W e p r o v e th a t k a c ≥ m in [k a b ,k b c ] b y c o n tr a d ic tio n . F o r k a c ≤ m in [k a b , k b c ] to h o ld , s h a p e A h a s to s e p a r a te fr o m s h a p e C b e fo re (1 ) s h a p e A s e p a ra te s fro m s h a p e B , a n d (2 ) b e fo re s h a p e B s e p a ra te s fr o m s h a p e C , o th e r w is e k a b ≤ k a c o r k b c ≤ k a c , w h ic h a u to m a tic a lly v io la t e s t h e c o n d it io n k a c < m in [k a b , k b c ]. B u t , if ( 1 ) h a s t o h o ld , t h e n F ig . P 1 2 .2 0 s h o w s th e o n ly w a y th a t A c a n s e p a r a te fr o m C b e fo r e s e p a r a tin g fr o m B . T h is , h o w e v e r, v io la te s (2 ), w h ic h m e a n s th a t th e c o n d itio n k a c < m in [k a b , k b c ] is v io la te d (w e c a n a ls o s e e th is in th e fi g u r e b y n o tin g th a t k a c = k b c w h ic h , s in c e k b c < k a b , v io la te s th e c o n d itio n ). W e u s e a s im ila r a r g u m e n t to s h o w th a t if (2 ) h o ld s th e n (1 ) is v io la te d . T h u s , w e c o n c lu d e th a t it is im p o s s ib le fo r th e c o n d itio n k a c < m in [k a b , k b c ] to h o ld , th u s p r o v in g th a t k a c ≥ m in [k a b , k b c ] o r, e q u iv a le n tly , th a t D (A ,C ) ≤ m a x [D (A , B ), D ( B ,C )]. Problem 12.21 Q = 0 im p lie s t h a t m a x ( jA j , jB j) = M . S u p p o s e t h a t jA j > jB j. t h a t jA j = M a n d , t h e r e f o r e , t h a t M > jB j. B u t M is o b t a in e d B , s o it m u s t b e b o u n d e d b y M ≤ m in (jA j , jB j). B e c a u s e w e jA j > jB j, t h e c o n d it io n M ≤ m in ( jA j , jB j) im p lie s M ≤ jB j. t h e a b o v e r e s u lt , s o t h e o n ly w a y f o r m a x ( jA j , jB j) = M t o T h is , in tu r n , im p lie s th a t A a n d B m u s t b e id e n tic a l s tr in jA j = jB j = M m e a n s t h a t a ll s y m b o ls o f A a n d B m a t c h . T h e if A ≡ B th e n Q = 0 fo llo w s d ir e c tly fr o m th e d e fi n itio n o f Q . T h e n , it m u s t b y m a tc h in g h a v e s tip u la te B u t th is c o n tr h o ld is if jA j g s (A ≡ B ) b e c o n v e rs e re s u fo llo w A a n d d th a t a d ic ts = jB j. c a u s e lt th a t 2 6 3 F ig u r e P 1 2 .2 0 Problem 12.22 T h s h to b y v a s o e r e a r e v a r io u s p o s s ib le a p p r o a c h e s to th is p r o b le m , a n d o u r s tu d e n ts h a v e o w n o v e r th e y e a r s a te n d e n c y to s u r p r is e u s w ith n e w a n d n o v e l a p p r o a c h e s p r o b le m s o f th is ty p e . W e g iv e h e r e a s e t o f g u id e lin e s th a t s h o u ld b e s a tis fi e d m o s t p r a c tic a l s o lu tio n s , a n d a ls o o ffe r s u g g e s tio n s fo r s p e c ifi c s o lu tio n s to r io u s p a r ts o f th e p r o b le m . D e p e n d in g o n th e le v e l o f m a tu r ity o f th e c la s s , m e o f th e s e m a y b e o ffe r e d a s ” h in ts ” w h e n th e p r o b le m is a s s ig n e d . B e c a u s e s p e e d a n d c o s t a r e e s s e n tia l s y s te m s p e c ifi c a tio n s , w e c o n c e p tu a liz e a b in a r y a p p r o a c h in w h ic h im a g e a c q u is itio n , p re p r o c e s s in g , a n d s e g m e n ta tio n a r e c o m b in e d in to o n e b a s ic o p e r a tio n . T h is a p p r o a c h le a d s u s to g lo b a l th r e s h o ld in g a s th e m e th o d o f c h o ic e . In th is p a r tic u la r c a s e th is is p o s s ib le b e c a u s e w e c a n s o lv e th e in s p e c tio n p r o b le m b y c o n c e n tr a tin g o n th e w h ite p a r ts o f th e fl a g (s ta r s a n d w h ite s tr ip e s ). A s d is c u s s e d in C h a p te r 1 0 , u n ifo r m illu m in a tio n is e s s e n tia l, e s p e c ia lly w h e n g lo b a l th r e s h o ld in g is u s e d fo r s e g m e n ta tio n . T h e s tu d e n t s h o u ld m e n tio n s o m e th in g a b o u t u n ifo r m illu m in a tio n , o r c o m p e n s a tio n fo r n o n u n ifo r m illu m in a tio n . A d is c u s s io n b y th e s tu d e n t o f c o lo r fi lte r in g to im p r o v e c o n tr a s t b e tw e e n w h ite a n d (r e d / b lu e / b a c k g r o u n d ) p a r ts o f a n im a g e is a p lu s in th e d e s ig n . T h e fi r s t s te p is to s p e c ify th r e q u ir e d to d e te c t th e s m a lle s t c o c a u s e th e im a g e s a re m o v in g a n d is n e c e s s a r y to s p e c ify a fi e ld o f c o n ta in a t le a s t o n e c o m p le te fl e n o u g h s o th a t n o fl a g s a re m is s e T h e fi e ld o f v ie w h a s to b e w id e a c r o s s th a n tw o fl a g s p lu s th e m w id th , W , o f th e v ie w in g a re a m u e s iz e o f th e v ie w in g a r e a , a n d th e r e s o lu tio n m p o n e n ts o f in te re s t, in th is c a s e th e s ta r s . B e th e e x a c t lo c a tio n o f e a c h fl a g is n o t k n o w n , it v ie w th a t w ill g u a r a n te e th a t e v e r y im a g e w ill a g . In a d d itio n , th e fr a m e r a te m u s t b e fa s t d . T h e fi r s t p a r t o f th e p r o b le m is e a s y to s o lv e . e n o u g h to e n c o m p a s s a n a r e a s lig h tly g r e a te r a x im u m s e p a r a tio n b e tw e e n th e m . T h u s , th e s t b e a t le a s t W = 2 (5 ) + 2 .0 5 = 1 2 .1 in . If w e u s e 2 6 4 C H A P T E R 1 2 . P R O B L E M S O L U T IO N S a s t a n d a r d C C D c a m e r a o f r e s o lu t io n 6 4 0 × 4 8 0 e le m e n t s a n d v ie w a n a r e a 1 2 .8 in . w id e , th is w ill g iv e u s a s a m p lin g r a te o f a p p r o x im a te ly 5 0 p ix e ls / in c h , o r 2 5 0 p ix e ls a c r o s s a s in g le fl a g . V is u a l in s p e c tio n o f a ty p ic a l fl a g w ill s h o w th a t th e b lu e p o r tio n o f a fl a g o c c u p ie s a b o u t 0 .4 tim e s th e le n g th o f th e fl a g , w h ic h in th is c a s e g iv e s u s a b o u t 1 0 0 p ix e ls p e r lin e in th e b lu e a r e a . T h e r e is a m a x im u m o f s ix s ta r s p e r lin e , a n d t h e b lu e s p a c e b e tw e e n th e m is a p p r o x im a te ly 1 .5 tim e s t h e w id t h o f a s t a r, s o t h e n u m b e r o f p ix e ls a c r o s s a s t a r is 1 0 0 / ([1 + 1 .5 ] × 6 ) ' 6 p ix e ls / s ta r. T h e n e x t tw o p r o b le m s a r e to d e te r m in e th e s h u tte r s p e e d a n d th e fr a m e r a te . B e c a u s e th e n u m b e r o f p ix e ls a c r o s s e a c h o b je c t o f in te r e s t is o n ly 6 , w e fi x th e b lu r a t le s s th a n o n e p ix e l. F o llo w in g th e a p p r o a c h u s e d in th e s o lu tio n o f P r o b le m 1 0 .4 9 , w e fi r s t d e t e r m in e t h e d is t a n c e b e t w e e n p ix e ls a s (1 2 .8 in ) / 6 4 0 p ix e ls = 0 .0 2 in / p ix e l. T h e m a x im u m s p e e d o f t h e fl a g s is 2 1 in / s e c . A t t h is s p e e d , t h e fl a g s t r a v e l 2 1 / 0 .0 2 = 1 , 0 5 0 p ix e ls / s e c . W e a r e r e q u ir in g t h a t a fl a g n o t t r a v e l m o r e th a n o n e p ix e l d u r in g e x p o s u r e ; th a t is (1 , 0 5 0 p ix e ls / s e c ) × T s e c ≤ 1 p ix e l. S o , T ≤ 9 .5 2 × 1 0 − 4 s e c is t h e s h u t t e r s p e e d n e e d e d . T h e fr a m e r a te m u s t b e fa s t e n o u g h to c a p tu re a n im a g e o f e v e r y fl a g th a t p a s s e s t h e in s p e c t io n p o in t . It t a k e s a fl a g (2 1 in / s e c )/ (1 2 .8 in ) ' 0 .6 s e c t o c r o s s th e e n tir e fi e ld o f v ie w , s o w e h a v e t o c a p tu r e a fr a m e e v e r y 0 .3 s e c in o r d e r to g u a r a n te e th a t e v e r y im a g e w ill c o n ta in a w h o le fl a g , a n d th a t n o fl a g w ill b e m is s e d . W e a s s u m e th a t th e c a m e r a is c o m p u te r c o n tr o lle d to fi r e fr o m a c lo c k s ig n a l. W e a ls o m a k e th e s ta n d a r d a s s u m p tio n th a t it ta k e s 1 / 3 0 s e c ' 3 3 0 × 1 0 − 4 s e c to re a d a c a p tu re d im a g e in to a fr a m e b u ffe r. T h e re fo re , th e to ta l tim e n e e d e d t o a c q u ir e a n im a g e is (3 3 0 + 9 .5 ) × 1 0 − 4 ' 3 4 0 × 1 0 − 4 s e c . S u b t r a c t in g t h is q u a n t it y fr o m t h e 0 .3 s e c fr a m e r a t e le a v e s u s w it h a b o u t 0 .2 7 s e c to d o a ll th e p r o c e s s in g re q u ire d fo r in s p e c tio n , a n d to o u tp u t a n a p p r o p r ia te s ig n a l to s o m e o th e r p a r t o f th e m a n u fa c tu r in g p r o c e s s . B e c a u s e a g lo b a l th r e s h o ld in g fu n c tio n c a n b e in c o r p o r a te d in m o s t d ig itiz e r s a s p a r t o f th e d a ta a c q u is itio n p r o c e s s , n o a d d itio n a l tim e is n e e d e d to g e n e r a te a b in a r y im a g e . T h a t is , w e a s s u m e th a t th e d ig itiz e r o u tp u ts th e im a g e in b in a r y fo r m . T h e n e x t s te p is to is o la te th e d a ta c o r r e s p o n d in g to a c o m p le te fl a g . G iv e n th e im a g in g g e o m e tr y a n d fr a m e r a te d is c u s s e d a b o v e , fo u r b a s ic b in a r y im a g e c o n fi g u r a tio n s a r e e x p e c te d : (1 ) p a r t o f a fl a g o n th e le ft o f th e im a g e , fo llo w e d b y a w h o le fl a g , fo llo w e d b y a n o th e r p a r tia l fl a g ; (2 ) o n e e n tir e fl a g to u c h in g th e le ft b o r d e r, fo llo w e d b y a s e c o n d e n tir e fl a g , a n d th e n a g a p b e fo r e th e r ig h t b o rd e r ; (3 ) th e o p p o s ite o f (2 ); a n d (4 ) tw o e n tire fl a g s , w ith n e ith e r fl a g to u c h in g th e b o u n d a r y o f th e im a g e . C a s e s (2 ), (3 ), a n d (4 ) a r e n o t lik e ly to o c c u r w ith a n y s ig n ifi c a n t fr e q u e n c y , b u t w e w ill c h e c k fo r e a c h o f th e s e c o n d itio n s . A s w ill b e s e e n b e lo w , C a s e s (2 ) a n d (3 ) c a n b e h a n d le d th e s a m e a s C a s e (1 ), b u t, g iv e n th e tig h t b o u n d s o n p r o c e s s in g tim e , th e o u tp u t e a c h tim e C a s e (4 ) o c c u r s 2 6 5 w ill b e to r e je c t b o th fl a g s . T o h a n d le C a s e (1 ) w e h a v e to id e n tify a w h o le fl a g ly in g b e tw e e n tw o p a r tia l fl a g s . O n e o f th e q u ic k e s t w a y s to d o th is is to r u n a w in d o w a s lo n g a s th e im a g e v e r tic a lly , b u t n a r r o w in th e h o r iz o n ta l d ir e c tio n , s a y , c o r r e s p o n d in g to 0 .3 5 in . ( b a s e d o n t h e w in d o w s iz e 1 / 2 o f [1 2 .8 − 1 2 .1 ]) , w h ic h is a p p r o x im a t e ly (0 .3 5 )(6 4 0 )/ 1 2 .8 ' 1 7 p ix e ls w id e . T h is w in d o w is u s e d lo o k fo r a s ig n ifi c a n t g a p b e t w e e n a h i g h c o u n t o f 1 ’s , a n d i t i s n a r r o w e n o u g h t o d e t e c t C a s e ( 4 ) . F o r C a s e (1 ), th is a p p r o a c h w ill p r o d u c e h ig h c o u n ts s ta r tin g o n th e le ft o f th e im a g e , th e n d r o p to v e r y fe w c o u n ts (c o r re s p o n d in g to th e b a c k g r o u n d ) fo r a b o u t tw o in c h e s , p ic k u p a g a in a s th e c e n te r (w h o le fl a g ) is e n c o u n te r e d , g o lik e th is fo r a b o u t fi v e in c h e s , d r o p a g a in fo r a b o u t tw o in c h e s a s th e n e x t g a p is e n c o u n t e r e d , t h e n p i c k u p a g a i n u n t i l t h e r i g h t b o r d e r i s e n c o u n t e r e d . T h e 1 ’s b e t w e e n th e tw o in n e r g a p s c o r r e s p o n d to a c o m p le te fl a g a n d a r e p r o c e s s e d fu r th e r b y t h e m e t h o d s d i s c u s s e d b e l o w ; t h e o t h e r 1 ’s a r e i g n o r e d . ( A m o r e e l e g a n t a n d p o te n tia lly m o r e r u g g e d w a y is to d e te r m in e a ll c o n n e c te d c o m p o n e n ts fi r s t, a n d th e n lo o k fo r v e r tic a l g a p s , b u t tim e a n d c o s t a r e fu n d a m e n ta l h e r e ). C a s e s (2 ) a n d (3 ) a r e h a n d le d in a s im ila r m a n n e r w ith s lig h tly d iffe r e n t lo g ic , b e in g c a r e fu l t o is o la t e t h e d a t a c o r r e s p o n d in g t o a n e n t ir e fl a g ( i.e ., t h e fl a g w it h a g a p o n e a c h s id e ). C a s e (4 ) c o r re s p o n d s to a g a p - d a ta - g a p - d a ta - g a p s e q u e n c e , b u t, a s m e n tio n e d a b o v e , it is lik e ly th a t tim e a n d c o s t c o n s tr a in ts w o u ld d ic ta te r e je c tin g b o th fl a g s a s a m o r e e c o n o m ic a l a p p r o a c h th a n in c r e a s in g th e c o m p le x ity o f th e s y s te m to h a n d le th is s p e c ia l c a s e . N o te th a t th is a p p r o a c h to e x tr a c tin g 1 ’s i s b a s e d o n t h e a s s u m p t i o n t h a t t h e b a c k g r o u n d i s n o t e x c e s s i v e l y n o i s y . I n o th e r w o r d s , th e im a g in g s y s te m m u s t b e s u c h th a t th e b a c k g r o u n d is r e lia b ly s e g m e n te d a s b la c k , w ith a c c e p ta b le n o is e . W ith r e fe r e n c e to F ig . 1 .2 3 , th e p r e c e d in g d is c u s s io n h a s c a r r ie d u s th r o u g h th e s e g m e n ta tio n s ta g e . T h e a p p r o a c h fo llo w e d h e r e fo r d e s c r ip tio n , r e c o g n itio n , a n d th e u s e o f k n o w le d g e , is tw o fo ld . F o r th e s ta r s w e u s e c o n n e c te d c o m p o n e n t a n a ly s is . F o r th e s tr ip e s w e u s e s ig n a tu r e a n a ly s is . T h e s y s te m k n o w s th e c o o r d in a te s o f tw o v e r tic a l lin e s w h ic h c o n ta in th e w h o le fl a g b e tw e e n th e m . F ir s t, w e d o a c o n n e c te d c o m p o n e n ts a n a ly s is o n th e le ft h a lf o f th e r e g io n (to s a v e tim e ) a n d fi lte r o u t a ll c o m p o n e n ts s m a lle r a n d la r g e r th a n th e e x p e c te d s iz e o f s ta r s , s a y (to g iv e s o m e fl e x ib ility ), a ll c o m p o n e n ts le s s th a n 9 (3 × 3 ) p ix e ls a n d la r g e r th a n 6 4 (8 × 8 ) p ix e ls . T h e s im p le s t te s t a t th is p o in t is to c o u n t th e n u m b e r o f re m a in in g c o n n e c te d c o m p o n e n ts (w h ic h w e a s s u m e to b e s ta r s ). If th e n u m b e r is 5 0 w e c o n tin u e w ith th e n e x t te s t o n th e s tr ip e s . O th e r w is e , w e r e je c t th e fl a g . O f c o u r s e , th e lo g ic c a n b e m a d e m u c h m o r e c o m p lic a te d th a n th is . F o r in s ta n c e , it c o u ld in c lu d e a r e g u la r ity a n a ly s is in w h ic h th e r e la tiv e lo c a tio n s o f th e c o m p o n e n ts a r e a n a ly z e d . T h e r e a r e lik e ly to b e a s m a n y a n s w e r s h e r e a s th e r e a r e s tu d e n ts in th e c la s s , b u t th e k e y o b je c tiv e s h o u ld b e to b a s e 2 6 6 C H A P T E R 1 2 . P R O B L E M S O L U T IO N S th e a n a ly s is o n a r u g g e d m e th o d s u c h a s c o n n e c te d c o m p o n e n t a n a ly s is . T o a n a ly z e th e s tr ip e s , w e a s s u m e th a t th e fl a g s a r e p r in te d o n w h ite s to c k m a te r ia l. T h u s , “ d r o p p in g a s tr ip e ” m e a n s c r e a tin g a w h ite s tr ip e tw ic e a s w id e a s n o r m a l. T h is is a s im p le d e fe c t d e te c ta b le b y r u n n in g a v e r tic a l s c a n lin e in a n a r e a g u a r a n te e d to c o n ta in s tr ip e s , a n d th e n lo o k in g a t th e in te n s ity s ig n a tu r e fo r th e n u m b e r o f p u ls e s o f th e r ig h t h e ig h t a n d d u r a tio n . T h e fa c t th a t th e d a ta is b in a r y h e lp s in th is r e g a r d , b u t th e s c a n lin e s h o u ld b e p r e p r o c e s s e d to b r id g e s m a ll g a p s d u e to n o is e b e fo r e it is a n a ly z e d . In s p ite o f th e ± 1 5 ◦ v a r ia tio n in d ir e c tio n , a r e g io n , s a y , 1 in . to th e r ig h t o f th e b lu e r e g io n is in d e p e n d e n t e n o u g h o f th e r o ta tio n a l v a r ia tio n in te r m s o f s h o w in g o n ly s tr ip e s a lo n g a s c a n lin e r u n v e r tic a lly in th a t r e g io n . It is im p o r ta n t th a t a n y a n s w e r to th is p r o b le m s h o w a w a r e n e s s o f th e lim its in a v a ila b le c o m p u ta tio n tim e . B e c a u s e n o m e n tio n is m a d e in th e p r o b le m s ta te m e n t a b o u t a v a ila b le p r o c e s s o r s , it is n o t p o s s ib le to e s ta b lis h w ith a b s o lu te c e r ta in ty if a s o lu tio n w ill m e e t th e r e q u ir e m e n ts o r n o t. H o w e v e r, th e s tu d e n t s h o u ld b e e x p e c te d to a d d r e s s th is is s u e . T h e g u id e lin e s g iv e n in th e p r e c e d in g s o lu tio n a r e a m o n g th e fa s te s t w a y s to s o lv e th e p r o b le m . A s o lu tio n a lo n g th e s e lin e s , a n d a m e n tio n th a t m u ltip le s y s te m s m a y b e r e q u ir e d if a s in g le s y s te m c a n n o t m e e t th e s p e c ifi c a tio n s , is a n a c c e p ta b le s o lu tio n to th e p r o b le m .