/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h i s   w o r k   i s   b a s e d   o n   t h e   o r i g i n a l   A R T o o l K i t   d e v e l o p e d   b y 
 
   *       H i r o k a z u   K a t o 
 
   *       M a r k   B i l l i n g h u r s t 
 
   *       H I T L a b ,   U n i v e r s i t y   o f   W a s h i n g t o n ,   S e a t t l e 
 
   *   h t t p : / / w w w . h i t l . w a s h i n g t o n . e d u / a r t o o l k i t / 
 
   * 
 
   *   T h e   N y A R T o o l k i t C S   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m ; 
 
 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e 
 
 { 
 
 
 
 
 
 
 
 
 
 
 
 
 
         / * * 
 
           *   S0n0000o000000000n0]R;uP0<h
}W0~0Y00
 
           *   ]R;uPo00p [ i ] = ( ( 2 5 5 - ;u }[ i ] ) - ;uPhQSOn0s^GW$P) n00000g0ibU00f0D000s^GW$Ph0n0]R$Pg0Y00
 
           *   { @ l i n k   N y A R M a t c h P a t t _ B l a c k W h i t e } n0eQR$Ph0OD0~0Y00
 
           *   < p > OD0e  -   
 
           *   { @ l i n k   # s e t R a s t e r } peg00]R;uP0\ObW0000000S_peg0]0n0`1X0_~0Y00
 
           *   < / p > 
 
           * / 
 
         p u b l i c   c l a s s   N y A R M a t c h P a t t D e v i a t i o n B l a c k W h i t e D a t a 
 
         { 
 
                 p r i v a t e   i n t [ ]   _ d a t a ; 
 
                 p r i v a t e   d o u b l e   _ p o w ; 
 
                 / / 
 
                 p r i v a t e   i n t   _ n u m b e r _ o f _ p i x e l s ; 
 
                 / * * 
 
                   *   [ r e a d o n l y ] S0n0peo00;u }0000<h
}W0_0MR0ԏW0~0Y00
 
                   *   { @ l i n k   N y A R M a t c h P a t t _ B l a c k W h i t e # e v a l u a t e } peK00OD0~0Y00
 
                   * / 
 
                 p u b l i c   i n t [ ]   g e t D a t a ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ d a t a ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00]R;uPn07_^$P0ԏW0~0Y00
 
                   *   7_^$Po00]R;uPn0;u }0NWNW0_0$Pn0Tg0Y00
 
                   *   @ r e t u r n 
 
                   *   0 & l t ; n n07_^$P0
 
                   * / 
 
                 p u b l i c   d o u b l e   g e t P o w ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ p o w ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   ]R;uPn00000c[W0f000000000ubW0~0Y00
 
                   *   @ p a r a m   i _ w i d t h 
 
                   *   ]R;uPn0000
 
                   *   @ p a r a m   i _ h e i g h t 
 
                   *   ]R;uPn0000
 
                   * / 
 
                 p u b l i c   N y A R M a t c h P a t t D e v i a t i o n B l a c k W h i t e D a t a ( i n t   i _ w i d t h ,   i n t   i _ h e i g h t ) 
 
                 { 
 
                         t h i s . _ n u m b e r _ o f _ p i x e l s   =   i _ h e i g h t   *   i _ w i d t h ; 
 
                         t h i s . _ d a t a   =   n e w   i n t [ t h i s . _ n u m b e r _ o f _ p i x e l s ] ; 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000K00]R;uP0ubW0f00<h
}W0~0Y00
 
                   *   6RPNh0W0f00{ @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ X 8 R 8 G 8 B 8 _ 3 2 } b__n0000n000eQRg0M0~0Y00
 
                   *   @ p a r a m   i _ r a s t e r 
 
                   *   ]R;uPn0CQ;uP0000o00S0n0000000h0TX0g0B00_L0B00~0Y00
 
                   * / 
 
                 p u b l i c   v o i d   s e t R a s t e r ( I N y A R R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         / / i _ b u f f e r [ X R G B ] !]R[ B W ] 	Yc	 	 	 
 
                         i n t   i ; 
 
                         i n t   a v e ; / / < P V / > 
 
                         i n t   r g b ; / / < P V / > 
 
                         i n t [ ]   l i n p u t   =   t h i s . _ d a t a ; / / < P V / > 
 
                         i n t [ ]   b u f   =   ( i n t [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 
 
                         / /   i n p u t MRn0000h0w h 0fe/ /   i n p u t = n e w   i n t [ h e i g h t ] [ w i d t h ] [ 3 ] ; 
 
                         i n t   n u m b e r _ o f _ p i x e l s   =   t h i s . _ n u m b e r _ o f _ p i x e l s ; 
 
 
 
                         / / < s^GW$P{( F O R n01 / 8 U\) / > 
 
                         a v e   =   0 ; 
 
                         f o r   ( i   =   n u m b e r _ o f _ p i x e l s   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 r g b   =   b u f [ i ] ; 
 
                                 a v e   + =   ( ( r g b   > >   1 6 )   &   0 x f f )   +   ( ( r g b   > >   8 )   &   0 x f f )   +   ( r g b   &   0 x f f ) ; 
 
                         } 
 
                         a v e   =   ( n u m b e r _ o f _ p i x e l s   *   2 5 5   *   3   -   a v e )   /   ( 3   *   n u m b e r _ o f _ p i x e l s ) ; 
 
                         / / 
 
                         i n t   s u m   =   0 ,   w _ s u m ; 
 
 
 
                         / / < ]R$P{/ > 
 
                         f o r   ( i   =   n u m b e r _ o f _ p i x e l s   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 r g b   =   b u f [ i ] ; 
 
                                 w _ s u m   =   ( ( 2 5 5   *   3   -   ( r g b   &   0 x f f )   -   ( ( r g b   > >   8 )   &   0 x f f )   -   ( ( r g b   > >   1 6 )   &   0 x f f ) )   /   3 )   -   a v e ; 
 
                                 l i n p u t [ i ]   =   w _ s u m ; 
 
                                 s u m   + =   w _ s u m   *   w _ s u m ; 
 
                         } 
 
                         d o u b l e   p   =   M a t h . S q r t ( ( d o u b l e ) s u m ) ; 
 
                         t h i s . _ p o w   =   p   ! =   0 . 0   ?   p   :   0 . 0 0 0 0 0 0 1 ; 
 
                         r e t u r n ; 
 
                 } 
 
         } 
 
 } 
 
 