Porter Duff

  • Upload
    maxbyz

  • View
    239

  • Download
    0

Embed Size (px)

Citation preview

  • 7/29/2019 Porter Duff

    1/7

    Computer Graph ics Volum e18, Num ber 3 July 1984

    C o m p o s i t i n g D i g i t a l I m a g e sT h o m a s P o r t e rTom D u f f 'f

    C o m p u t e r G r a p h i c s P r o j e c tL u c a s f i l m L t d .

    A B S T R A C TM o s t c o m p u t e r g r a p h i c s p i c t u r e s h a v e b e e n c o m p u t e d a l la t o n c e , s o t h a t t h e r e n d e r i n g p r o g r a m t a k e s c a r e o f al lc o m p u t a t i o n s r e l a t in g t o t h e o v e r l a p o f o b j e c t s . T h e r e ares e v e r a l a p p l ic a t i o n s, h o w e v e r , w h e r e e l e m e n t s must ber e n d e r e d s e p a r a t e l y , r e l y i n g o n e o m p o s i t i n g t e c h n i q u e s f o rt h e a n t i - a l i a s e d a c c u m u l a t i o n o f t h e f u l l i m a g e . T h i s paperp r e s e n t s t h e c a s e f o r fo u r - c h a n n e l p i c t u r e s , demonstratingt h a t a m a t t e c o m p o n e n t c a n b e c o m p u t e d s i m i l a r l y t o t h ec o l o r ch a n n e l s . T h e p a p e r d i s c u s s e s g u i d e l i n e s f o r theg e n e r a t i o n o f e l e m e n t s a n d th e a r i t h m e t i c f o r t h e i r a rb i -t r a r y c o m p o s i t i n g .

    C R C a t e g o r i e s an d S u b j e c t D e s c r i p t o r s : 1 .3 .3 [ C o m -p u t e r G r a p h i c s ] : P i c t u r e / I m a g e G e n e r a t i o n s - -D i s p l a y a l g o r i t h m s ; 1 . 3 . 4 [ C o m p u t e r G r a p h i c s ] :G r a p h i c s U t i l i t ie s - - S o f t w a r e s u p p o r t ; 1 .4 .1 [ I m a g eP r o c e s s i n g ] : D i g i t i z a t i o n - - S a m p l i n g .

    G e n e r a l T e r m s : A l g o r i t h m sA d d i t i o n a l K e y W o r d s a n d P h r a s es : c o m p o s i ti n g , m a t t ec h a n n e l , m a t t e a l g e b r a , v i s i b l e s u r f a c e a l g o r i t h m s ,g r a p h i c s s y s t e m s

    f Autho r's current ~ddress: AT&T Bell Laboratories, Murray Hill, NJ 07074, Room 2C46S

    P ermiss ion to copy wi thout fee all or pa rt of this material is grantedprov ided tha t the copies are no t made or d i s tr ibuted for d irectcommercia l advantage , the A CM copyright no t ice and the t i t l e o f thepubl icat ion and i ts da te appear , and not ice i s g iven tha t copy ing i s bypermission of t h e A s s o c i a t i o n f o r C o m p u t i n g Machinery. To c o p yotherwise, or to republish, requires a fee and/or speci f i c permiss ion .

    1 9 8 4 A C M 0 - 8 9 7 9 1 - 1 3 8 - 5 / 8 4 / 0 0 7 / 0 2 5 3 $ 0 0 . 7 5

    1 . I n t r o d u c t i o nI n c r e a s i n g l y , w e f i n d t h a t a c o m p l e x t h r e e d i m e n s i o n a ls c e n e c a n n o t b e f u l l y r e n d e r e d b y a s in g l e p r o g r a m . T h ew e a l t h o f l i t e r a t u r e o n r e n d e r i n g p o l y g o n s a n d c u r v e ds u r f ac e s , h a n d l i n g t h e s p e c i a l c a s e s o f f r a c t a l s a n d s p h e r e sa n d q u a d r i c s a n d t r i a n g l e s , i m p l e m e n t i n g r e f i n e m e n t s fo rt e x t u r e m a p p i n g a n d b u m p m a p p i n g , n o t i n g s p e e d -u p s ont h e b a s i s o f c o h e r e n c e o r d e p t h c o m p l e x i t y i n t h e s c e n e ,s u g g e s t s t h a t m u l t i p l e p r o g r a m s a r e n ec e s s a r y .I n f a c t , r e l i a n c e o n a s i n g l e p r o g r a m f o r r e n d e r i n g a ne n t i r e s c e n e i s a p o o r s t r a t e g y f o r m i n i m i z i n g t h e c o s t o fs m a l l m o d e l i n g e rr o r s . E x p e r i e n c e h a s t a u g h t u s t o b r e a kd o w n l a r g e b o d i e s o f s o u r c e c o de i n t o s e p a r a t e m o d u l e s i no r d e r t o s a v e c o m p i l a t i o n t i m e . A n e r r o r i n o n e r o u t i n ef o r c e s o n l y t h e r e c o m p i l a t i o n o f i t s m o d u l e a n d t h e r e l a -t i v e l y q u i c k r e l o a d i n g o f t h e e n t i r e p r o g r a m . S i m i l a r l y ,s m a l l e r r o r s i n c o l o r a t i o n o r d e s i g n i n o n e o b j e c t s h o u l dn o t f o r c e t h e " r e c o m p i l a t i o n " o f a n e n t i r e i m a g e .S e p a r a t i n g t h e i m a g e i n t o e l e m e n t s w h i c h c a n b ei n d e p e n d e n t l y r e n d e r e d s a v e s e n o r m o u s t i m e . E a c h e l e -m e n t h a s a n a s s o c i a t e d m a t t e , c o v e r a g e i n f o r m a t i o nw h i c h d e s i g n a t e s t h e s h a p e o f t h e e l e m e n t . T h e e o m p o -s i t i n g o f t h o s e e l e m e n t s m a k e s u s e o f t h e m a t t e s t o a c c u -m u l a t e t h e f i n a l i m a g e .T h e c o m p o s i t i n g m e t h o d o l o g y m u s t n o t i n d u c e a l i a s i n g i nt h e i m a g e ; s o f t e d g e s o f t h e e l e m e n t s m u s t b e h o n o r e d i nc o m p u t i n g t h e f i n a l i m a g e . F e a t u r e s s h o u l d b e p r o v i d e dt o e x p l o i t t h e f u l l a s s o c i a t i v i t y o f t h e c o m p o s i t i n g p r o -c e s s; t h i s a f f o r d s f l e x i b i l i t y , f o r e x a m p l e , f o r t h e a c c u m u -l a t i o n o f s e v e r a l f o r e g r o u n d e l e m e n t s i n t o a n a g g r e g a t ef o r e g r o u n d w h i c h c a n b e e x a m i n e d o v e r d i f f e r e n t b a c k -g r o u n d s . T h e c o m p o s i t o r s h o u l d p r o v i d e f ac i l i ti e s f o ra r b i t r a r y d i s s o l v e s a n d f a d e s o f e l e m e n t s d u r i n g a na n i m a t e d s e q u e n c e .S e v e r a l h i g h l y s u c c e s s f u l r e n d e r i n g a l g o r i t h m s h a v ew o r k e d b y r e d u c i n g t h e i r e n v i r o n m e n t s t o p i e ce s t h a t c a nb e c o m b i n e d i n a 2 1 /2 d i m e n s i o n a l m a n n e r , a n d t h e no v e r l a y i n g t h e m e i t h e r f r o n t - t o - b a c k o r b a c k - t o - f r o n t [ 3 ] .W h i t t e d a n d W e i m a r ' s g r a p h i c s t e s t - b e d [ 6] a n d C r o w ' si m a g e g e n e r a t i o n e n v i r o n m e n t [2 ] a r e b o t h d e s i g n e d t od e a l w i t h h e t e r o g e n o u s l y r e n d e r e d e l e m e n t s . W h i t t e d

    25 3

  • 7/29/2019 Porter Duff

    2/7

    @SIGGRAPH'84

    a n d W e i m a r ' s s y s t e m r e d uc e s a l l o b je c t s t o h o r i z o n t a ls p a n s w h i c h a r e e o m p o s i t e d u s i n g a W a r n o c k - l i k e a l g o -r i t h m . I n C r o w ' s s y s t e m a s u p e r v i s o r y p r o c e s s d e c i d e st h e o r d e r i n w h i c h t o c o m b i n e i m a g e s c r e a t e d b y i n d e p e n -d e n t s p e c i a l - p u r p o s e r e n d e r i n g p r o ce s s e s. T h e i m a g i n gs y s t e m o f W a r n o c k a n d W y a t t [5 ] i n c o r p o r a t e s 1 - b i tm a t t e s . T h e H a n n a - B a r b e r a c ar t o o n a n i m a t i o n sy s t e m[4 ] i n c o r p o r a t e s s o f t - e d g e m a t t e s , r e p r e s e n t i n g t h e o p a c i t yi n f o r m a t i o n i n a le s s c o n v e n i e n t m a n n e r t h a n t h a t p r o -p o s e d h er e . T h e p r e s e n t p a p e r p r e s e n t s g u i d e l i n e s f o rr e n d e r i n g e l e m e n t s a n d i n t r o d u c e s t h e a l g e b r a fo r c o m p o -s i t i n g .2 . T h e A l p h a C h a n n e lA s e p a r a t e c o m p o n e n t i s n e e d e d t o r e t a i n t h e m a t t ei n f o r m a t i o n , t h e e x t e n t o f c o v e r a g e o f an e l e m e n t a t ap i x e l. I n a f u l l c o l o r r e n d e r i n g o f a n e l e m e n t , t h e R G Bc o m p o n e n t s r e t a i n o n l y t h e c o l o r. I n o r d e r to p l a c e t h ee l e m e n t o v e r a n a r b i t r a r y b a c k g r o u n d , a m i x i n g f a c t o r i sr e q u i r e d a t e v e r y p i x e l t o c o n t r o l t h e l i n e a r i n t e r p o l a t i o no f f o r e g r o u n d a n d b a c k g r o u n d c o l o rs . I n g e n e r a l, t h e r e isn o w a y t o e n c o d e t h i s c o m p o n e n t a s p a r t o f t h e c o l o ri n f o r m a t i o n . F o r a n t i - a l i a s i n g p u r p o s e s , th i s m i x i n g f a c -t o r n e e d s t o b e o f c o m p a r a b l e r e s o l u t i o n t o t h e c o l o rc h a n n e l s . L e t u s c a ll t h i s a n alpha c h a n n e l , a n d l e t u st r e a t a n a l p h a o f 0 t o i n d i c a t e n o c o v e r a g e , 1 t o m e a n f u l lc o v e r a g e , w i t h f r a c t i o n s c o r r e s p o n d i n g t o p a r t i a l c o v e r -a g e .I n a n e n v i r o n m e n t w h e r e t h e c o m p o s i t i n g o f e l e m e n t s i sr e q u i r e d , w e s e e t h e n e e d f o r a n a l p h a c h a n n e l a s a ni n t e g r a l p a r t o f a l l p i c t u r e s . B e c a u s e m a t t e s a r e n a t u r a l l yc o m p u t e d a l o n g w i t h t h e p i c t u r e , a s e p a r a t e a l p h a c o m -p o n e n t i n t h e f r a m e b u f f e r i s a p p r o p r i a t e . O f f - li n es t o r a g e o f a l p h a i n f o r m a t i o n a l o n g w i t h c o l o r w o r k s c o n -v e n i e n t l y i n t o r u n - l e n g t h e n c o d i n g s c h e m e s b e c a u s e t h ea l p h a i n f o r m a t i o n t e n d s t o a b i d e b y t h e s a m e r u n s .W h a t i s t h e m e a n i n g o f t h e q u a d r u p l e ( r , g , b , a ) a t a p i x e l ?H o w d o w e e x p r e s s t h a t a p i x e l i s h a l f c o v e r e d b y a f u l lr e d o b j e c t ? O n e o b v i o u s s u g g e s t i o n i s t o a s s i g n (1 ,0 ,0 ,. 5}t o t h a t p i x e l: t h e .5 i n d i c a t e s t h e c o v e r a g e a n d t h e ( 1 ,0 , 0)i s t h e c o l o r . T h e r e a r e a fe w r e a s o n s t o d i s m i s s t h i s p r o -p o s a l , t h e m o s t s e v e r e b e i n g t h a t a l l c o m p o s i t i n g o p e r a -t i o n s w i l l i n v o l v e m u l t i p l y i n g t h e 1 in t h e r e d c h a n n e l b yt h e . 5 i n t h e a l p h a c h a n n e l t o c o m p u t e t h e r e d c o n t r i b u -t i o n o f t h i s o b j e c t a t t h i s p i x e l. T h e d e s i r e t o a v o i d t h i sm u l t i p l i c a t i o n p o i n t s u p a b e t t e r s o l u t i o n , s t o r i n g t h ep r e - m u l t i p l i e d v a l u e i n t h e c o l o r c o m p o n e n t , s o t h a t( . 5 , 0 , 0 , . 5 ) w i l l i n d i c a t e a f u l l r e d o b j e c t h a l f c o v e r i n g ap i x e l .T h e q u a d r u p l e ( r , g , b , a ) i n d i c a t e s t h a t t h e p i x e l is ac o v e r e d b y t h e c o l o r ( r / a , g / a , b / a ) . A q u a d r u p l e w h e r et h e a l p h a c o m p o n e n t i s l e ss t h a n a c o l o r c o m p o n e n t i n d i -c a t e s a c o l o r o u t s i d e t h e [ 0 ,1 ] i n t e r v a l , w h i c h i s s o m e w h a tu n u s u a l . W e w i l l s e e l a t e r t h a t l u m i n e s c e n t o b j e c t s c a n b eu s e f u l ly r e p r e s e n t e d in t h i s w a y . F o r t h e r e p r e s e n t a t i o no f n o r m a l o b j e c t s , a n a l p h a o f 0 a t a p i x e l g e n e r a l l yf o r c es t h e c o l o r c o m p o n e n t s t o b e 0 . T h u s t h e R G Bc h a n n e l s r e c o r d t h e t r u e c o l o rs w h e r e a l p h a i s 1 , l i n e a r l y

    d a r k e n e d c o l o r s f o r f r a c t i o n a l a l p h a s a l o n g e d g e s , a n db l a c k w h e r e a l p h a i s 0 . S i l h o u e t t e e d g e s o f R G B A e l e -m e n t s t h u s e x h i b i t t h e i r a n t i - a l ia s e d n a t u r e w h e n v i e w e do n a n R G B m o n i t o r .I t i s i m p o r t a n t t o d i s t i n g u i s h b e t w e e n t w o k e y p i x e lr e p r e s e n t a t i o n s :b lack ~ - (0 ,0 ,0 ,1 ) ;c l e a r - ~ (0 ,0 ,0 ,0 ) .T h e f o r m e r p i x e l i s a n o p a q u e b l a c k ; t h e l a t t e r p i x e l ist r a n s p a r e n t .

    3 . R G B A P i c t u r e sI f w e s u r v e y t h e v a r i e t y o f e l e m e n t s w h i c h c o n t r i b u t e t o ac o m p l e x a n i m a t i o n , w e f i n d m a n y c o m p l e t e b a c k g r o u n di m a g e s w h i c h h a v e a n a l p h a o f 1 e v e r y w h e r e . A m o n gf o r e g r o u n d e l e m e n t s , w e f i n d t h a t t h e c o l o r c o m p o n e n t sr o l l o f f i n s t e p w i t h t h e a l p h a c h a n n e l , l e a v i n g l a r g e a r e a so f t r a n s p a r e n c y . M a t t e s , c o l o r l e s s s t e n c i ls u s e d f o r c o n -t r o l l i n g t h e c o m p o s i t i n g o f o t h e r e l e m e n t s , h a v e 0 i n t h e i rR G B c o m p o n e n t s . O f f- li n e s t o r a g e o f R G B A p i c t u r e ss h o u l d t h e r e f o r e p r o v i d e t h e n a t u r a l d a t a c o m p r e s s i o n f o rh a n d l i n g t h e R G B p i x el s o f b a c k g ro u n d s , R G B A p i x el s o ff o r e g r o u n d s , a n d A p i x e ls o f m a t t e s .T h e r e a r e s o m e o b j e c t io n s t o c o m p u t i n g w i t h t h e seR G B A p i c t u r e s . S t o r a g e o f t h e c o lo r c o m p o n e n t s p r e -m u l t i p l i e d b y t h e a l p h a w o u l d s e e m t o u n d u l y q u a n t i z et h e c o l o r r e s o l u t i o n , e s p e c i a l ly as a l p h a a p p r o a c h e s 0 .H o w e v e r , b e c a u s e a n y c o m p o s i t i n g o f t h e p i c t u r e w i l lr e q u i r e t h a t m u l t i p l i c a t i o n a n y w a y , s t o r a g e o f t h e p r o -d u c t f o r c e s o n l y a v e r y m i n o r l o s s o f p r e c i s i o n i n t h i sr e g a r d . C o l o r e x t r a c t i o n , t o c o m p u t e i n a d if f e r e n t c o l o rs p a c e f o r e x a m p l e , b e c o m e s m o r e d i f f i c u l t . W e m u s tr e c o v e r ( r / a , g / a , b / a ) , a n d o n c e a g a i n, a s a l p h aa p p r o a c h e s 0 , t h e p r e c i s i o n fa l l s o f f s h a r p l y . F o r o u ra p p l i c a t i o n s , t h i s h a s y e t t o a f f e c t u s .4 . T h e A l g e b r a o f C o m p o s i t l n gG i v e n t h i s s t a n d a r d o f R G B A p i c t ur e s , le t u s e x am i n eh o w c o m p o s i t i n g w o r k s . W e s h a l l d o t h i s b y e n u m e r a t i n gt h e c o m p l e t e s e t o f b i n a r y c o m p o s i t i n g o p e r a t i o n s . F o re a c h o f t h e s e , w e s h a l l p r e s e n t a f o r m u l a f o r c o m p u t i n gt h e c o n t r i b u t i o n o f e a c h o f t w o i n p u t p i c t u r e s t o t h e o u t -p u t c o m p o s i t e a t e a c h p ix e l . W e s h a ll p a y p a r t i c u l a ra t t e n t i o n t o t h e o u t p u t p i xe ls , t o s e e t h a t t h e y r e m a i np r e - m u l t i p l i e d b y t h e i r a l p h a .

    4 . 1 . A s s u m p t i o n sW h e n b l e n d i n g p i c t u r e s t o g e t h e r , w e d o n o t h a v e i n f o r -m a t i o n a b o u t o v e r l a p o f c o v e r a g e in f o r m a t i o n w i t h i n ap i x e l; a ll w e h a v e i s a n a l p h a v a l u e . W h e n w e c o n s i d e rt h e m i x i n g o f t w o p i c t u r e s a t a p i x e l , w e m u s t m a k e s o m ea s s u m p t i o n a b o u t t h e i n t e r p l a y o f t h e t w o a l p h a v a lu e s .I n o r d e r t o e x a m i n e t h a t i n t e r p l a y , l e t u s f i r s t c o n s i d e rt h e o v e r l a p o f t w o s e m i - t r a n s p a r e n t e l e m e n t s l i k e h a z e ,t h e n c o n s i d e r t h e o v e r l a p o f tw o o p a q u e , h a r d - e d g e d e l e-m e n t s .

    25 4

  • 7/29/2019 Porter Duff

    3/7

    Computer Graphics Volum e18, Num ber 3 July 1984

    I f a A a n d a B r e p r e s e n t t h e o p a q u e n e s s o f s e m i -t r a n s p a r e n t o b j e c t s w h i c h f u l l y c o v e r t h e p i x e l , t h e c o m -p u t a t i o n i s w e l l k n o w n . E a c h o b j e c t l e ts ( l - a ) o f t h eb a c k g r o u n d t h r o u g h , s o t h a t t h e b a c k g r o u n d s h o w st h r o u g h o n l y ( 1 - a A ) ( 1 - a B ) o f t h e p ix e l , a A ( l - a ~ ) o f t h eb a c k g r o u n d i s b l o c k e d b y o b j e c t A a n d p a s s e d b y o b j e c tB ; ( 1 - ~ A ) a B o f t h e b a c k g r o u n d i s p a s s e d b y A a n db l o c k e d b y B . T h i s l e a v es OlAOlB o f t h e p i x e l w h i c h w ec a n c o n s i d e r t o b e b l o c k e d b y b o t h .I f o lA a n d a B r e p r e s e n t s u b p i x e l a r e a s c o v e r e d b y o p a q u eg e o m e t r i c o b j e c t s , t h e o v e r l a p o f o b j e c t s w i t h i n t h e p i x e li s q u i t e a r b i t r a r y . W e k n o w t h a t o b j e c t A d i v i d e s t h ep i x e l i n t o t w o s u b p i x e l a r e a s o f r a t i o C~A:l -a A. W e k n o wt h a t o b j e c t B d i v i d e s t h e p i x e l i n t o t w o s u b p i x e l a r e a s o fr a t i o crB:l-cr13. L a c k i n g f u r t h e r i n f o r m a t i o n , w e m a k e t h ef o l l o w i n g a s s u m p t i o n : t h e r e i s n o t h i n g s p e c i a l a b o u t t h es h a p e o f t h e p ix e l ; w e e x p e c t t h a t o b j e c t B w i l l d i v i d e e a c ho f th e s u b p i x e l a r e a s i n s i d e a n d o u t s i d e o f o b j e c t A i n t ot h e s a m e r a t i o a / 3 : l - a B . T h e r e s u l t o f t h e a s s u m p t i o n i st h e s a m e a r i t h m e t i c a s w i t h s e m i - t r a n s p a r e n t o b j e c t s a n di s s u m m a r i z e d i n t h e f o l l ow i n g ta b l e :

    d e s c r i p t i o n a r e aA ( ' ] B ( l - a t ) ( 1 - a B )A ~ B O t A ( 1 - o t B )A O B ( 1 - a A ) a BA f ' ] B C~A a B

    T h e a s s u m p t i o n i s q u i t e g o o d f o r m o s t m a t t e s , t h o u g h i tc a n b e i m p r o v e d i f w e k n o w t h a t t h e c o v e r a g e s e ld o mo v e r l a p s ( a d j a c e n t s e g m e n t s o f a c o n t i n u o u s l i n e ) o ra l w a y s o v e r l a p s ( r e p e a t e d a p p l i c a t i o n o f a p i c tu r e ) . F o re a s e i n p r e s e n t a t i o n t h r o u g h o u t t h i s p a p e r , l e t u s m a k et h i s a s s u m p t i o n a n d c o n s i d e r t h e a l p h a v a l u e s a sr e p r e s e n t i n g s u b p i x e l c o v e r a g e o f o p a q u e o b j e c t s .

    4 .2 . C o m p o s i t i n g O p e r a t o r sC o n s i d e r t w o p i c t u r e s A a n d B . T h e y d i v i d e ea c h p ix e li n t o t h e 4 s u b p i x e l a r e a s

    B A n a m e d e s c r i p t i o n c h o ic e s0 0 0 mf " ]B_ 00 1 A A _ ~ B O , A1 0 B A A B O , B1 1 A B A N B O , A , B

    l i s t e d i n t h i s t a b l e a l o n g w i t h t h e c h o i c e s i n e a c h a r e a f o rc o n t r i b u t i n g t o t h e c o m p o s i t e . I n t h e l a s t a r e a , f o r e x a m -p l e , b e c a u s e b o t h i n p u t p i c t u r e s e x i s t t h e r e , e i t h e r c o u l ds u r v i v e t o t h e c o m p o s i te . A l t e r n a t i v e l y , t h e c o m p o s i t ec o u l d b e c l e a r i n t h a t a r e a .A p a r t i c u l a r b i n a r y c o m p o s i t i n g o p e r a t i o n c a n b ei d e n t i fi e d a s a q u a d r u p l e i n d i c a t i n g t h e i n p u t p i c t u r ew h i c h c o n t r i b u t e s t o t h e c o m p o s i t e i n e ac h o f t h e f o u rs u b p i x e l a r e a s 0 , A , B , A B o f t h e t a b l e a b o v e . W i t ht h r e e c h o i c e s w h e r e t h e p i c t u r e s i n t e r s e c t , t w o w h e r e o n l yo n e p i c t u r e e x i s t s a n d o n e o u t s i d e t h e t w o p i c t u r e s , t herea r e 3 X 2 X 2 X 1 ~- -- 12 d i s t i n c t c o m p o s i t i n g o p e r a t i o n s l i s t e d

    i n t h e t a b l e b e l ow . N o t e t h a t p i c t u r e s A a n d B a r ed i a g r a m m e d a s c o v e r i n g t h e p i x el w i t h t r i a n g u l a r w e d g e sw h o s e o v e r l a p c o n f o r m s t o t h e a s s u m p t i o n a b o v e .

    o p e r a t i o n q u a d r u p l e d i a g r a m F A FI?c l e a r (0 ,0 ,0 ,0) 0 0

    A ( 0 , A , 0 , A )

    B ( O , O , B , B )

    A o v e r B ( 0 , A , B , A )

    B o v e r A ( 0 , A , B , B )

    A in B (0 ,0 , 0, A)

    B in A (0,0,0,B)

    1 0

    1 1 - a A

    1 - a B 1

    V

    A o u t B (0 ,A,0 ,0 )

    B o u t A (0 ,0 ,B,0 )

    a B 0

    0 a A

    1 - a B 0

    0 l - a A

    A a t o p B ( 0 , 0 ,B , A ) ~ ~ B 1 - a A

    B a t o p A ( 0 , A , 0 , B ) ~ 1 - a B o~A

    A x o r B ( 0, A ,B ,0 ) ~ l - a B 1 - a A

    U s e f u l o p e r a t o r s i n c l u d e A o v e r / 5 , A i n B , a n d A h e l do u t b y B . A o v e r B i s t h e p l a c e m e n t o f f o r e g r o u n d A i nf r o n t of b a c k g r o u n d B . A in B r e f e rs o n l y t o t h a t p a r t o fA i n s i d e p i c t u r e B . A h e l d o u t b y B, n o r m a l l y s h o r -t e n e d t o A o u t B , r e f e rs o n l y t o t h a t p a r t o f A o u t s i d ep i c t u r e B . F o r c o m p l e t e n e s s , w e i n c l u d e t h e l es s u s e f u lo p e r a t o r s A a t o p B a n d A x o r B . A a t o p B i s t h e u n i o no f A in B a n d B o u t A . T h u s , p a p e r a t o p t a b l e i n c l u d e sp a p e r w h e r e i t i s o n t o p o f table, a n d t a b l e o t h e r w i s e ; a r e ab e y o n d t h e e d g e o f t h e t a b l e i s o u t o f t h e p i c t u r e .A x o r B i s t h e u n i on o f A o u t B a n d B o u t A .

    25 5

  • 7/29/2019 Porter Duff

    4/7

    @SI6GRAPH'84i

    4 .3 . C o m p o s i t i n g A r i t h m e t i cF o r e a c h o f t h e c o m p o s i t i n g o p e r a t i o n s , w e w o u l d l i k e t oc o m p u t e t h e c o n t r i b u t i o n o f e a c h i n p u t p i c t u r e a t e a c hp i x e l. T h i s i s q u i te e a s i l y so l v e d b y r e c o g n i z in g t h a t e a c hi n p u t p i c t u r e s u r v i v e s i n t h e c o m p o s i t e p i x e l o n l y w i t h i ni t s o w n m a t t e . F o r e a c h i n p u t p i c t u r e , w e a r e l o o k i n g f o rt h a t f r a c t i o n o f i ts o w n m a t t e w h i c h p r e v a i l s i n t h e o u t -p u t . B y d e f i n i t io n t h e n , t h e a l p h a v a l u e o f t h e c o m p o s i t e ,t h e t o t a l a r e a o f t h e p i x e l c o v e r e d , c a n b e c o m p u t e d b ya d d i n g a A t i m e s i t s f r a c t i o n F A t o a B t i m e s i t s f r a c t i o n

    T h e c o l o r o f t h e c o m p o s i t e c a n b e c o m p u t e d o n a c o m -p o n e n t b a s i s b y a d d i n g t h e c o l o r o f t h e p i c t u r e A t i m e si t s f r a c t i o n t o t h e c o l o r o f p i c t u r e B t i m e s i t s f r a c t i o n .T o s e e t h i s , l e t CA, cB, a n d c o b e s o m e c o l o r c o m p o n e n to f p i c tu r e s A , B a n d t h e c o m p o s i t e , a n d l e t C A , C B , a n dC o b e t h e t r u e c o l o r c o m p o n e n t b e f o r e p r e - m u l t i p l i c a t i o nb y a lp h a . T h e n w e h a v e

    C 0 ~ OLoCN o w C o c a n b e c o m p u t e d b y a v e r a g in g c o n t r ib u t i o n sm a d e b y C A a n d C B , s o

    O I A F A C A - I - O e B F B CBCo = o~o . a A F A + O ~ B F B

    b u t t h e d e n o m i n a t o r i s j u s t a o , s o~o = "AFACa + .BF ,%

    CA CB

    : C A F A - F C B F B (1 )B e c a u s e e a c h o f t h e i n p u t c o l o r s i s p r e - m u l t i p l i e d b y i t sa l p h a , a n d w e a r e a d d i n g c o n t r i b u t i o n s f r o m n o n -o v e r l a p p i n g a r e a s , t h e s u m w i l l b e e f fe c t iv e l y p r e -m u l t i p l i e d b y t h e a l p h a v a l u e o f t h e c o m p o s i t e j u s t c o m -p u t e d . T h e p l e a s a n t r e s u l t t h a t t h e c o l o r c h a n n e l s a reh a n d l e d w i t h t h e s a m e c o m p u t a t i o n a s a l p h a c a n b et r a c e d b a c k t o o u r d e c is i on t o s t o r e p r e - m u l t i p l ie d R G B Aq u a d r u p l e s . T h u s t h e p r o b l e m i s r e d u c e d t o fi n d i n g at a b l e o f f r a c t i o n s F A a n d F B w h i c h i n d i c a t e t h e e x t e n t o fc o n t r i b u t i o n o f A a n d B , p l u g g i n g t h e s e v a l u e s in t o e q u a -t i o n 1 fo r b o t h t h e c o l o r a n d t h e a l p h a c o m p o n e n t s .B y o u r a s s u m p t i o n s a b o v e , t h e f r a c t i o n s a r e q u i c k l yd e t e r m i n e d b y e x a m i n i n g t h e p i x e l d i a g r a m i n c l u d e d int h e t a b l e o f o p e r a t i o n s . T h o s e f r a c t i o n s a r e l i s t e d i n t h eF A a n d F B c o l u m n s o f t h e t a b l e . F o r e x a m p l e , i n t h eA o v e r B c a s e , p i c t u r e A s u r v i v e s e v e r y w h e r e w h i l e p i c -t u r e B s u r v i v e s o n l y o u t s i d e p i c t u r e A , s o t h e c o r r e s p o n d -i n g f ra c t i o n s a r e 1 a n d ( 1 - ~ A ) . S u b s t i t u t i n g i n t o e q u a -t i o n 1 , w e f i n d

    c o : C A X l + c B X ( 1 -a A ) .T h i s i s a l m o s t t h e w e l l u s e d l i n e a r i n t e r p o l a t i o n o f f o r e -g r o u n d F w i t h b a c k g r o u n d B

    / ~ = F X c ~ + B x ( 1 - a ) ,e x c e p t t h a t o u r f o r e g r o u n d i s p r e - m u l t i p l i e d b y a l p h a .

    4 .4 . U n a r y o p e r a t o r sT o a s s i s t u s i n d i s s o l v in g a n d i n b a l a n c i n g c o l o r b r i g h t -n e s s o f e l e m e n t s c o n t r i b u t i n g t o a c o m p o s i t e , i t i s u s e f u lt o i n t r o d u c e a d a r k e n f a c t o r a n d a d i s s o l ve f a c t o r 6:

    d a r k e n ( A , ) = ( r A ,~ g A,d P bA ,O l A ). d l s s o l v e ( A , 6 ) - - - - ( 6 r A , 6 g A , 6b A , 6 O t A ) .N o r m a l l y , 0 < ~ , 6 _ ~ 1 a l t h o u g h n o n e o f t h e t h e o r y r e q u i re si t.

    A s ~ v a r i e s f r o m 1 t o 0 , t h e e l e m e n t w i l l c h a n g e f r o mn o r m a l t o c o m p l e t e b l a c kn e s s . I f 4 > 1 t h e e l e m e n t w i l lb e b r i g h t e n e d . A s 6 g o e s f r o m 1 t o 0 t h e e l e m e n t w i l lg r a d u a l l y f a d e f r o m v i e w .L u m i n e s c e n t o b j e c t s , w h i c h a d d c o l o r i n f o r m a t i o nw i t h o u t o b s c u r i n g t h e b a c k g r o u n d , c a n b e h a n d l e d w i t ht h e i n t r o d u c t i o n o f a o p a q u e n e s s f a c t o r w , 0 < w < 1 :

    o p a q u e ( A , w ) - - - - ( r A ,g A , b A , W tA ) A s w v a r ie s f r o m 1 t o 0 , t h e e l e m e n t w i l l c h a n g e f r o mn o r m a l c o v e r a g e o v e r t h e b a c k g r o u n d t o n o o b s c u r a t i o n .T h i s s c a l i n g o f t h e a l p h a c h a n n e l a l o n e w i l l c a u se p i x e lq u a d r u p l e s w h e r e (~ i s l e s s t h a n a c o l o r c o m p o n e n t , i n d i -c a t i n g a r e p r e s e n t a t i o n o f a c o l o r o u t s i d e o f t h e n o r m a lr a n g e . T h i s p o s s i b i l i t y f o r c es u s t o c l ip t h e o u t p u t c o m p o -s i t e t o t h e [ 0 , 1] r a n g e .A n w o f 0 w i ll p r o d u c e q u a d r u p l e s ( r , g , b , O ) w h i c h d o h a v em e a n i n g . T h e c o l o r c h a n n e l s , p r e - m u l t i p l i e d b y t h e o ri g i -n a l a l p h a , c a n b e p l u g g e d i n t o e q u a t i o n 1 a s a lw a y s . T h ea l p h a c h a n n e l o f 0 in d i c a t e s t h a t t h i s p i x e l w i l l o b s c u r en o t h i n g . I n t e r m s o f o u r m e t h o d o l o g y f o r e x a m i n i n g s u b -p i x e l a r e a s , w e s h o u l d u n d e r s t a n d t h a t u s i n g t h e o p a q u eo p e r a t o r c o r r e s p o n d s t o s h r i n k i n g t h e m a t t e c o v e r a g ew i t h r e g a r d t o t h e c o l o r c o v e r a g e .

    4 .5 . T h e P L U S o p e r a t o rW e f i n d i t u s e f u l t o i n c l u d e o n e f u r t h e r b i n a r y c o m p o s i t -i n g o p e r a t o r p l u s . T h e e x p r e s s i o n A p l u s B h o l d s n on o t i o n o f p r e c e d e n c e i n a n y a r e a c o v e r e d b y b o t h p i c -t u r e s ; t h e c o m p o n e n t s a r e s i m p l y a d d e d . T h i s a l l o w s u st o d i s s o l v e f r o m o n e p i c t u r e t o a n o t h e r b y s p e c i f y i n g

    d l s s o l v e ( A , ~ ) p l u s d i s s o l v e ( B , l - ( ~ ) .I n t e r m s o f t h e b i n a r y o p e r a t o r s a b o v e , p l u s a l l o w sb o t h p i c t u r e s t o s u r v i v e i n t h e s u b p i x e l a r e a A B . T h eo p e r a t o r t a b l e a b o v e s h o u l d b e a p p e n d e d :

    o p e r a t i o n d i a g r a m F A F B(0 ,A ,B ,A B ) ~ ~ 1 IA p l u s B

    25 6

  • 7/29/2019 Porter Duff

    5/7

    Computer Graphics Vo lum e18, Num ber 3 July 1984

    5 . ExamplesThe operations on one and two pictures are presented asa basis for handling compositing expressions involvingseveral pictures. A norma l case involving three picturesis the compositing of a foreground picture A over a back-ground picture B, with regard to an independent matteC. The expression for this compositing operation is

    ( A in C ) o v e r B .Using equation 1 twice, we find that the composite in thiscase is computed at each pixel by

    co = ea~e+ edl -~A ~C).As an example of a complex compositing expression, letus consider a subwindow of Rob Cook's picture R o a d t o

    P o i n t R e y e s [1]. This still frame was assembled frommany elements according to the following rules:F o r e g r o u n d - -- - F r g d G r a s s over R o c k over F e n c eo v e r S h a d o w over B k g d G r a s s ;G I o s s y R o a d ~ P u d d l e over ( P o s t R e f l e e t i o n atop( P l a n t R e f l e e t i o n atop R o a d ) ) ;

    H i l ls i d e ~ P l a n t over G l o s s y R o a d over Hill;B a c k g r o u n d - ~- R a i n b o w p l u s D a r k b o w overM o u n t a i n s over Sky;,

    P t . R e y e s = F o r e g r o u n d over Hi l l s i d e over B a c k g r o u n d .Figure 1 shows three intermediate composites and thefinal picture.

    F o r e g r o u n d ~ F r g d G r a s s over R o c k over F e n c eover S h a d o w over B k g d G r a s s ; H i l ls i d e ~ P l a n t over G l o s s y R o a d over Hill;

    B a c k g r o u n d = R a i n b o w p l u s D a r k b o w overM o u n t a i n s over Sky;,Figure 1

    P t . R e y e s ~ - - F o r e g r o u n d over Hi l l s i d e over B a c k g r o u n d .

    25 7

  • 7/29/2019 Porter Duff

    6/7

    Stars

    @SIGGRAPH'84

    BFire

    !

    Planet

    FFire"(BFire out Planet Composite

    Figure 2

    2 5 8

  • 7/29/2019 Porter Duff

    7/7

    Computer Graph ics Volum e18, Num ber 3 July 1984

    A f u r t h e r e x a m p l e d e m o n s t r a t es t h e p r o b l e m o f corre-lated mat tes . I n F i g u r e 2 , w e h a v e a s t a r f i e l d b a c k -g r o u n d , a p l a n e t e l e m e n t , f i e ry p a r t i c le s b e h i n d t h ep l a n e t , a n d f i er y p a r t i c l e s in f r o n t o f th e p l a n e t . W e w i s ht o a d d t h e l u m i n o u s f i r es , o b s c u r e t h e p l a n e t , d a r k e n e df o r p r o p e r b a l a n c e , w i t h t h e a g g r e g a t e f ir e m a t t e , a n dp l a c e t h a t o v e r t h e s t a r f i e ld . A n e x p r e s s io n fo r t h is e o m -p o s i t i n g i s(FFire p l u s ( B F i r e u t Planet) )

    o v e r darken(P lane t , . 8 ) o v e r S t a r s .W e m u s t r e m e m b e r t h a t o u r b a s i c a s s u m p t i o n a b o u t t h ed i v i s i o n o f s u b p i x e l a r e a s b y g e o m e t r i c o b j e c t s b r e a k sd o w n i n t h e f a c e o f i n p u t p i c t u r e s w i t h c o r r e l a t e d m a t t e s .W h e n o n e p i c t u r e a p p e a r s t w i c e in a c o m p o s i t i n g e x p re s -s i o n , w e m u s t t a k e c a r e w i t h o u r c o m p u t a t i o n s o f F A a n dF B . T h o s e l i s t e d i n t h e t a b l e a r e c o r r e c t o n l y f o r u n e o r r e -l a t e d p i c t u r e s .T o s o l v e t h e p r o b l e m o f c o r r e l a t e d m a t t e s , w e m u s te x t e n d o u r m e t h o d o l o g y t o h a n d l e n p i c t u r e s : w e m u s te x a m i n e a l l 2 " s u b a r e a s o f t h e p i x e l , d e c i d i n g w h i c h o ft h e p i c t u r e s s u r v i v e s i n e a ch a r e a , a n d a d d i n g u p a l l c o n -t r i b u t i o n s . M u l t i p l e i n s t a n c e s o f a s i n g l e p i c t u r e o r p i c -t u r e s w i t h c o r r e l a t e d m a t t e s a r e r e s o l v e d b y a l i g n i n g t h e i rp i x e l c o v e r a g e. E x a m p l e 2 ca n b e c o m p u t e d b y b u i l d i n ga t a b l e o f s u r v i v o r s ( sh o w n b e l o w ) t o a c c u m u l a t e t h ee x t e n t t o w h i c h e a c h i n p u t p i c t u r e s u r v i v e s i n t h e c o m p o -s i t e .

    F F i r e B F i r e P l a n e t S t a r s

    6 . C o n c l u s i o n

    S u r v i v o rS t a r sP l a n e t

    P l a n e tB F i r eB F i r eP l a n e tP l a n e tF F i r eF F i r eF F i r eF F i r eF F i r e , B F i r eF F i r e , B F i r eF F i r eF F i r e

    W e h a v e p o i n t e d o u t t h e n e e d f o r m a t t e c h a n n e l s i n s y n -t h e t i c p i c t u r e s , s u g g e s t i n g t h a t f r a m e b u f f e r h a r d w a r es h o u l d o f f e r t h i s f a c i l i t y . W e h a v e s e e n t h e c o n v e n i e n c eo f t he R G B A s c h e m e f o r i n t e g ra t i n g t h e m a t t e c h a n ne l . Al a n g u a g e o f o p e r a t o r s h a s b e e n p r e s e n t e d f o r c o n v e y i n g af u l l r a n g e o f c o m p o s i t i n g e x pr e s s io n s . W e h a v e d i s c u s s e da m e t h o d o l o g y f o r d e c i d i n g c o m p o s i t i n g q u e s t i o n s a t t h es u b p i x e l l e v e l, d e r i v i n g a s i m p l e e q u a t i o n f o r h a n d l i n g a l lc o m p o s i t e s o f t w o p i c t u r e s . T h e m e t h o d o l o g y i s e x t e n d e dt o m u l t i p l e p i c t u r e s , a n d t h e l a n g u a g e i s e m b e l l i s h e d t oh a n d l e d a r k e n i n g , a t t e n u a t i o n , a n d o p a q u e n e s s .

    T h e r e a r e s e v e r a l p r o b l e m s t o b e r e s o l v e d i n r e l a t e da r e a s , w h i c h a r e o p e n f or f u t u r e r e s ea r c h . W e a r ei n t e r e s t e d i n m e t h o d s f o r b r e a k i n g a r b i t r a r y t h r e e d i m e n -s i o n a l s c e n es i n t o e l e m e n t s s e p a r a t e d i n d e p t h . S u c h e l e -m e n t s a r e e q u i v a l e n t t o c l u s t e r s , w h i c h h a v e b e e n a s u b -j e c t o f d i s c u ss i o n s in c e t h e e a r l i e s t a t t e m p t s a t h i d d e ns u r f a c e e li m i n a t i o n . W e a r e in t e r e s t e d i n a p p l y i n g t h ec o m p o s i t i n g n o t i o n s t o Z - b u f f e r a l g o r i t h m s , w h e r e d e p t hi n f o r m a t i o n i s r e t a i n e d a t e a c h p i x e l .

    7 . R e f e r e n c e s1 . C o o k , R . R o a d t o P o i n t R e y e s . Computer GraphicsV o l 1 7 , N o . 3 ( 1 9 8 3) , T i t l e P a g e P i c t u r e .2 . C r o w , F . C . A M o r e F l e x i b l e I m a g e G e n e r a t i o nE n v i r o n m e n t . Computer Graphics Vol . 16 , No . 3(1982) , pp . 9 -18 .3 . N e w e l l , M . G . , N e w e l l , R . G . , a n d S a n e h a , T . L . . AS o l u t i o n t o t h e H i d d e n S u r f a c e P r o b l e m , p p . 4 4 3 -448 . P roceed ings o f the 1 972 AC M N at iona l C on fer -ence .4 . W a l l a c e , B r u c e . M e r g i n g a n d T r a n s f o r m a t i o n o fR a s t e r I m a g e s f o r C a r t o o n A n i m a t i o n . C om puterGraphics Vol . 15 , No . 3 (1981) , pp . 253 .262 .5 . W a r n o e k , J o h n , a n d W y a t t , D o u g l a s . A D e v i c eI n d e p e n d e n t G r a p h i c s I m a g i n g M o d e l f o r U se w i t hR a s t e r D e v i c e s . C om puter G raph ics Vol . 16 , No . 3(1982) , pp . 313 -319 .6 . W h i t t e d , T u r n e r , a n d W e i m e r , D a v i d . A S o f tw a r eT e s t - B e d f or t h e D e v e l o p m e n t o f 3 -D R a s t e r G r a p h -i e s S y s t e m s . C om puter G raph ics Vol . 15 , No . 3(1981) , pp . 271 -277 .8 . A c k n o w l e d g m e n t T h e u s e o f m a t t e s t o c o n t r o l t h e c o m p o s i t i n g o f p i c t u r e si s n o t n e w . T h e g r a p h i c s g r o u p a t t h e N e w Y o r k I n s t i-t u t e o f T e c h n o l o g y h a s b e e n u s in g t h is f o r y e a r s . N Y I Tc o l o r m a p s w e r e d e s i g n e d t o e n c o d e b o t h c o l o r a n d m a t t ei n f o rm a t i o n ; t h a t i d e a w a s e x t e n d ed i n t h e A m p e x A V As y s t e m f o r s t o r i n g m a t t e s w i t h p i c t u r e s . C r e d i t s h o u l d b eg i ve n t o E d C a t m u l l , A l v y R a y S m i t h , a n d I k o n a s G r a p h -i c s S y s t e m s f o r t h e e x i s t e n c e o f an a l p h a c h a n n e l a s a ni n t e g r a l p a r t o f a f r a m e b u f f er , w h i c h h a s p a v e d t h e w a yf o r t h e d e v e l o p m e n t s p r e s e n t e d i n t h i s p a p e r .T h e g r a p h i c s g r o u p a t L u c a s f i l m s h o u l d b e c r e d i t e d w i t hp r o v i d i n g a f i n e t e s t b e d f o r w o r k i n g o u t t h e s e i d e a s .F u r t h e r m o r e , c e r t a i n i d e a s i n c o r p o r a t e d a s p a r t o f t h i sw o r k h a v e t h e i r o r i g i n s a s i d l e c o m m e n t s w i t h i n t h i sg r o u p . T h a n k s a r e a ls o g i v e n t o R o d n e y S t o c k f or c o m -m e n t s o n a n e a r l y d r a f t w h i c h f o r c e d t h e a u t h o r s t o c l a r -i f y t h e m a j o r a s s u m p t i o n s .

    25 9