/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t   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 1 2   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 > 
 
   *   
 
   * / 
 
 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 
 
 { 
 
 
 
 
 
 
 
         / * * 
 
           *   I N y A R H i s t o g r a m F r o m R a s t e r 0ubW0~0Y00
 
           *   [_W0f0D00000o00NNn00g0Y00
 
           *   < u l > 
 
           *   < l i > { @ l i n k   I N y A R G r a y s c a l e R a s t e r } n0}b000< / l i > 
 
           *   < l i > { @ l i n k   I N y A R R g b R a s t e r } n0}b000< / l i > 
 
           *   < l i > { @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ G R A Y _ 8 } b__n000000cd00n0< l i > 
 
           *   < l i > { @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ B I N _ 8 } b__n000000cd00n0< l i > 
 
           * / 
 
         p u b l i c   c l a s s   N y A R H i s t o g r a m F r o m R a s t e r F a c t o r y 
 
         { 
 
                 p u b l i c   s t a t i c   I N y A R H i s t o g r a m F r o m R a s t e r   c r e a t e I n s t a n c e ( I N y A R G r a y s c a l e R a s t e r   i _ r a s t e r )   
 
 	 { 
 
 	 	 s w i t c h ( i _ r a s t e r . g e t B u f f e r T y p e ( ) ) { 
 
 	 	 c a s e   N y A R B u f f e r T y p e . I N T 1 D _ G R A Y _ 8 : 
 
 	 	 c a s e   N y A R B u f f e r T y p e . I N T 1 D _ B I N _ 8 : 
 
 	 	 	 r e t u r n   n e w   N y A R H i s t o g r a m F r o m R a s t e r _ I N T G S 8 ( i _ r a s t e r ) ; 
 
 	 	 d e f a u l t : 
 
 	 	 	 i f ( i _ r a s t e r   i s   I N y A R G r a y s c a l e R a s t e r ) { 
 
 	 	 	 	 r e t u r n   n e w   N y A R H i s t o g r a m F r o m R a s t e r _ A n y G s ( ( I N y A R G r a y s c a l e R a s t e r ) i _ r a s t e r ) ; 
 
 	 	 	 } 
 
                         i f   ( i _ r a s t e r   i s   I N y A R R g b R a s t e r ) 
 
                         { 
 
 	 	 	 	 r e t u r n   n e w   N y A R H i s t o g r a m F r o m R a s t e r _ A n y R g b ( ( I N y A R R g b R a s t e r ) i _ r a s t e r ) ; 
 
 	 	 	 } 
 
                         b r e a k ; 
 
 	 	 } 
 
 	 	 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
 	 } 
 
                 p u b l i c   s t a t i c   I N y A R H i s t o g r a m F r o m R a s t e r   c r e a t e I n s t a n c e ( I N y A R R g b R a s t e r   i _ r a s t e r )   
 
 	 { 
 
                 i f   ( i _ r a s t e r   i s   I N y A R R g b R a s t e r ) 
 
                 { 
 
 	 	 	 r e t u r n   n e w   N y A R H i s t o g r a m F r o m R a s t e r _ A n y R g b ( ( I N y A R R g b R a s t e r ) i _ r a s t e r ) ; 
 
 	 	 } 
 
 	 	 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
 	 } 
 
 
 
         } 
 
 
 
         / / 0000000
 
 
 
         c l a s s   N y A R H i s t o g r a m F r o m R a s t e r _ A n y G s   :   I N y A R H i s t o g r a m F r o m R a s t e r 
 
         { 
 
                 p r i v a t e   I N y A R G r a y s c a l e R a s t e r   _ g s r ; 
 
                 p u b l i c   N y A R H i s t o g r a m F r o m R a s t e r _ A n y G s ( I N y A R G r a y s c a l e R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ g s r   =   i _ r a s t e r ; 
 
                 } 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         N y A R I n t S i z e   s   =   t h i s . _ g s r . g e t S i z e ( ) ; 
 
                         t h i s . c r e a t e H i s t o g r a m ( 0 ,   0 ,   s . w ,   s . h ,   i _ s k i p ,   o _ h i s t o g r a m ) ; 
 
                 } 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ w ,   i n t   i _ h ,   i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         o _ h i s t o g r a m . r e s e t ( ) ; 
 
                         i n t [ ]   d a t a _ p t r   =   o _ h i s t o g r a m . d a t a ; 
 
                         I N y A R G s P i x e l D r i v e r   d r v   =   t h i s . _ g s r . g e t G s P i x e l D r i v e r ( ) ; 
 
                         i n t   p i x _ c o u n t   =   i _ w ; 
 
                         i n t   p i x _ m o d _ p a r t   =   p i x _ c o u n t   -   ( p i x _ c o u n t   %   8 ) ; 
 
                         / / ]
NK001 Le0d0pgW0f0D0O0
 
                         f o r   ( i n t   y   =   i _ h   -   1 ;   y   > =   0 ;   y   - =   i _ s k i p ) 
 
                         { 
 
                                 f o r   ( i n t   x   =   p i x _ c o u n t   -   1 ;   x   > =   p i x _ m o d _ p a r t ;   x - - ) 
 
                                 { 
 
                                         d a t a _ p t r [ d r v . g e t P i x e l ( x ,   y ) ] + + ; 
 
                                 } 
 
                         } 
 
                         o _ h i s t o g r a m . t o t a l _ o f _ d a t a   =   i _ w   *   i _ h   /   i _ s k i p ; 
 
                         r e t u r n ; 
 
                 } 
 
         } 
 
 
 
         c l a s s   N y A R H i s t o g r a m F r o m R a s t e r _ A n y R g b   :   I N y A R H i s t o g r a m F r o m R a s t e r 
 
         { 
 
                 p r i v a t e   I N y A R R g b R a s t e r   _ g s r ; 
 
                 p u b l i c   N y A R H i s t o g r a m F r o m R a s t e r _ A n y R g b ( I N y A R R g b R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ g s r   =   i _ r a s t e r ; 
 
                 } 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         N y A R I n t S i z e   s   =   t h i s . _ g s r . g e t S i z e ( ) ; 
 
                         t h i s . c r e a t e H i s t o g r a m ( 0 ,   0 ,   s . w ,   s . h ,   i _ s k i p ,   o _ h i s t o g r a m ) ; 
 
                 } 
 
                 p r i v a t e   i n t [ ]   t m p   =   n e w   i n t [ 3 ] ; 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ w ,   i n t   i _ h ,   i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         o _ h i s t o g r a m . r e s e t ( ) ; 
 
                         i n t [ ]   d a t a _ p t r   =   o _ h i s t o g r a m . d a t a ; 
 
                         I N y A R R g b P i x e l D r i v e r   d r v   =   t h i s . _ g s r . g e t R g b P i x e l D r i v e r ( ) ; 
 
                         i n t   p i x _ c o u n t   =   i _ w ; 
 
                         i n t   p i x _ m o d _ p a r t   =   p i x _ c o u n t   -   ( p i x _ c o u n t   %   8 ) ; 
 
                         / / ]
NK001 Le0d0pgW0f0D0O0
 
                         f o r   ( i n t   y   =   i _ h   -   1 ;   y   > =   0 ;   y   - =   i _ s k i p ) 
 
                         { 
 
                                 f o r   ( i n t   x   =   p i x _ c o u n t   -   1 ;   x   > =   p i x _ m o d _ p a r t ;   x - - ) 
 
                                 { 
 
                                         d r v . g e t P i x e l ( x ,   y ,   t m p ) ; 
 
                                         d a t a _ p t r [ ( t m p [ 0 ]   +   t m p [ 1 ]   +   t m p [ 2 ] )   /   3 ] + + ; 
 
                                 } 
 
                         } 
 
                         o _ h i s t o g r a m . t o t a l _ o f _ d a t a   =   i _ w   *   i _ h   /   i _ s k i p ; 
 
                         r e t u r n ; 
 
                 } 
 
         } 
 
 
 
 
 
         c l a s s   N y A R H i s t o g r a m F r o m R a s t e r _ I N T G S 8   :   I N y A R H i s t o g r a m F r o m R a s t e r 
 
         { 
 
                 p r i v a t e   I N y A R R a s t e r   _ g s r ; 
 
                 p u b l i c   N y A R H i s t o g r a m F r o m R a s t e r _ I N T G S 8 ( I N y A R R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ g s r   =   i _ r a s t e r ; 
 
                 } 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         N y A R I n t S i z e   s   =   t h i s . _ g s r . g e t S i z e ( ) ; 
 
                         t h i s . c r e a t e H i s t o g r a m ( 0 ,   0 ,   s . w ,   s . h ,   i _ s k i p ,   o _ h i s t o g r a m ) ; 
 
                 } 
 
                 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ w ,   i n t   i _ h ,   i n t   i _ s k i p ,   N y A R H i s t o g r a m   o _ h i s t o g r a m ) 
 
                 { 
 
                         o _ h i s t o g r a m . r e s e t ( ) ; 
 
                         i n t [ ]   i n p u t   =   ( i n t [ ] ) t h i s . _ g s r . g e t B u f f e r ( ) ; 
 
                         N y A R I n t S i z e   s   =   t h i s . _ g s r . g e t S i z e ( ) ; 
 
                         i n t   s k i p   =   ( i _ s k i p   *   s . w   -   i _ w ) ; 
 
                         i n t   p i x _ c o u n t   =   i _ w ; 
 
                         i n t   p i x _ m o d _ p a r t   =   p i x _ c o u n t   -   ( p i x _ c o u n t   %   8 ) ; 
 
                         / / ]
NK001 Le0d0pgW0f0D0O0
 
                         i n t   p t   =   ( i _ t   *   s . w   +   i _ l ) ; 
 
                         i n t [ ]   d a t a   =   o _ h i s t o g r a m . d a t a ; 
 
                         f o r   ( i n t   y   =   i _ h   -   1 ;   y   > =   0 ;   y   - =   i _ s k i p ) 
 
                         { 
 
                                 i n t   x ; 
 
                                 f o r   ( x   =   p i x _ c o u n t   -   1 ;   x   > =   p i x _ m o d _ p a r t ;   x - - ) 
 
                                 { 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                 } 
 
                                 f o r   ( ;   x   > =   0 ;   x   - =   8 ) 
 
                                 { 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                         d a t a [ i n p u t [ p t + + ] ] + + ; 
 
                                 } 
 
                                 / / 0000
 
                                 p t   + =   s k i p ; 
 
                         } 
 
                         o _ h i s t o g r a m . t o t a l _ o f _ d a t a   =   i _ w   *   i _ h   /   i _ s k i p ; 
 
                         r e t u r n ; 
 
                 } 
 
         } 
 
 } 
 
 
 
 
 
 
 
 
 
 
 
 / / c l a s s   N y A R R a s t e r T h r e s h o l d A n a l y z e r _ H i s t o g r a m _ I N T 1 D _ X 8 R 8 G 8 B 8 _ 3 2   i m p l e m e n t s   N y A R R a s t e r A n a l y z e r _ H i s t o g r a m . I F i l t e r 
 
 / / { 
 
 / / 	 p u b l i c   b o o l e a n   i s S u p p o r t ( I N y A R R a s t e r   i _ r a s t e r ) 
 
 / / 	 { 
 
 / / 	 	 r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( 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 ) ; 
 
 / / 	 } 
 
 / / 	 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( I N y A R R a s t e r   i _ r a s t e r , i n t   i _ l , i n t   i _ t , i n t   i _ w , i n t   i _ h ,   i n t [ ]   o _ h i s t o g r a m , i n t   i _ s k i p ) 
 
 / / 	 { 
 
 / / 	 	 D e b u g . A s s e r t   ( i _ r a s t e r . i s E q u a l B u f f e r T y p e (   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 ) ) ; 
 
 / / 	 	 f i n a l   i n t [ ]   i n p u t = ( i n t [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 / / 	 	 N y A R I n t S i z e   s = i _ r a s t e r . g e t S i z e ( ) ; 
 
 / / 	 	 i n t   s k i p = ( i _ s k i p * s . w - i _ w ) ; 
 
 / / 	 	 f i n a l   i n t   p i x _ c o u n t = i _ w ; 
 
 / / 	 	 f i n a l   i n t   p i x _ m o d _ p a r t = p i x _ c o u n t - ( p i x _ c o u n t % 8 ) ; 	 	 	 
 
 / / 	 	 / / ]
NK001 Le0d0pgW0f0D0O0
 
 / / 	 	 i n t   p t = ( i _ t * s . w + i _ l ) ; 
 
 / / 	 	 f o r   ( i n t   y   =   i _ h - 1 ;   y   > = 0   ;   y - = i _ s k i p ) { 
 
 / / 	 	 	 i n t   x , v ; 
 
 / / 	 	 	 f o r   ( x   =   p i x _ c o u n t - 1 ;   x   > = p i x _ m o d _ p a r t ;   x - - ) { 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 f o r   ( ; x > = 0 ; x - = 8 ) { 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v = i n p u t [ p t + + ] ; o _ h i s t o g r a m [ ( ( v &   0 x f f ) + ( v &   0 x f f ) + ( v &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 / / 0000
 
 / / 	 	 	 p t + = s k i p ; 
 
 / / 	 	 } 
 
 / / 	 	 r e t u r n ; 	 	 	 
 
 / / 	 } 	 
 
 / / } 
 
 / / 
 
 / / 
 
 / / c l a s s   N y A R R a s t e r T h r e s h o l d A n a l y z e r _ H i s t o g r a m _ B Y T E 1 D _ R G B _ 2 4   i m p l e m e n t s   N y A R R a s t e r A n a l y z e r _ H i s t o g r a m . I F i l t e r 
 
 / / { 
 
 / / 	 p u b l i c   b o o l e a n   i s S u p p o r t ( I N y A R R a s t e r   i _ r a s t e r ) 
 
 / / 	 { 
 
 / / 	 	 r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ B 8 G 8 R 8 _ 2 4 )   | |   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ R 8 G 8 B 8 _ 2 4 ) ; 
 
 / / 	 } 
 
 / / 	 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( I N y A R R a s t e r   i _ r a s t e r , i n t   i _ l , i n t   i _ t , i n t   i _ w , i n t   i _ h ,   i n t [ ]   o _ h i s t o g r a m , i n t   i _ s k i p ) 
 
 / / 	 { 
 
 / / 	 	 D e b u g . A s s e r t   ( 
 
 / / 	 	 	 	 i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ B 8 G 8 R 8 _ 2 4 ) | | 
 
 / / 	 	 	 	 i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ R 8 G 8 B 8 _ 2 4 ) ) ; 
 
 / / 	 	 f i n a l   b y t e [ ]   i n p u t = ( b y t e [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 / / 	 	 N y A R I n t S i z e   s = i _ r a s t e r . g e t S i z e ( ) ; 
 
 / / 	 	 i n t   s k i p = ( i _ s k i p * s . w - i _ w ) * 3 ; 
 
 / / 	 	 f i n a l   i n t   p i x _ c o u n t = i _ w ; 
 
 / / 	 	 f i n a l   i n t   p i x _ m o d _ p a r t = p i x _ c o u n t - ( p i x _ c o u n t % 8 ) ; 	 	 	 
 
 / / 	 	 / / ]
NK001 Le0d0pgW0f0D0O0
 
 / / 	 	 i n t   p t = ( i _ t * s . w + i _ l ) * 3 ; 
 
 / / 	 	 f o r   ( i n t   y   =   i _ h - 1 ;   y   > = 0   ;   y - = i _ s k i p ) { 
 
 / / 	 	 	 i n t   x ; 
 
 / / 	 	 	 f o r   ( x   =   p i x _ c o u n t - 1 ;   x   > = p i x _ m o d _ p a r t ;   x - - ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 3 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 f o r   ( ; x > = 0 ; x - = 8 ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 3 * 8 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 / / 0000
 
 / / 	 	 	 p t + = s k i p ; 
 
 / / 	 	 } 
 
 / / 	 	 r e t u r n ; 	 
 
 / / 	 } 
 
 / / } 
 
 / / 
 
 / / c l a s s   N y A R R a s t e r T h r e s h o l d A n a l y z e r _ H i s t o g r a m _ B Y T E 1 D _ B 8 G 8 R 8 X 8 _ 3 2   i m p l e m e n t s   N y A R R a s t e r A n a l y z e r _ H i s t o g r a m . I F i l t e r 
 
 / / { 
 
 / / 	 p u b l i c   b o o l e a n   i s S u p p o r t ( I N y A R R a s t e r   i _ r a s t e r ) 
 
 / / 	 { 
 
 / / 	 	 r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ B 8 G 8 R 8 X 8 _ 3 2 ) ; 
 
 / / 	 } 
 
 / / 	 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( I N y A R R a s t e r   i _ r a s t e r , i n t   i _ l , i n t   i _ t , i n t   i _ w , i n t   i _ h ,   i n t [ ]   o _ h i s t o g r a m , i n t   i _ s k i p ) 
 
 / / 	 { 
 
 / /                 D e b u g . A s s e r t ( i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ B 8 G 8 R 8 X 8 _ 3 2 ) ) ; 
 
 / / 	 	 f i n a l   b y t e [ ]   i n p u t = ( b y t e [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 / / 	 	 N y A R I n t S i z e   s = i _ r a s t e r . g e t S i z e ( ) ; 
 
 / / 	 	 i n t   s k i p = ( i _ s k i p * s . w - i _ w ) * 4 ; 
 
 / / 	 	 f i n a l   i n t   p i x _ c o u n t = i _ w ; 
 
 / / 	 	 f i n a l   i n t   p i x _ m o d _ p a r t = p i x _ c o u n t - ( p i x _ c o u n t % 8 ) ; 	 	 	 
 
 / / 	 	 / / ]
NK001 Le0d0pgW0f0D0O0
 
 / / 	 	 i n t   p t = ( i _ t * s . w + i _ l ) * 4 ; 
 
 / / 	 	 f o r   ( i n t   y   =   i _ h - 1 ;   y   > = 0   ;   y - = i _ s k i p ) { 
 
 / / 	 	 	 i n t   x ; 
 
 / / 	 	 	 f o r   ( x   =   p i x _ c o u n t - 1 ;   x   > = p i x _ m o d _ p a r t ;   x - - ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 f o r   ( ; x > = 0 ; x - = 8 ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 0 ] &   0 x f f ) + ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 / / 0000
 
 / / 	 	 	 p t + = s k i p ; 
 
 / / 	 	 } 
 
 / / 	 	 r e t u r n ; 	 
 
 / /         } 
 
 / / } 
 
 / / 
 
 / / c l a s s   N y A R R a s t e r T h r e s h o l d A n a l y z e r _ H i s t o g r a m _ B Y T E 1 D _ X 8 R 8 G 8 B 8 _ 3 2   i m p l e m e n t s   N y A R R a s t e r A n a l y z e r _ H i s t o g r a m . I F i l t e r 
 
 / / { 
 
 / / 	 p u b l i c   b o o l e a n   i s S u p p o r t ( I N y A R R a s t e r   i _ r a s t e r ) 
 
 / / 	 { 
 
 / / 	 	 r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ X 8 R 8 G 8 B 8 _ 3 2 ) ; 
 
 / / 	 } 	 
 
 / / 	 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( I N y A R R a s t e r   i _ r a s t e r , i n t   i _ l , i n t   i _ t , i n t   i _ w , i n t   i _ h ,   i n t [ ]   o _ h i s t o g r a m , i n t   i _ s k i p ) 
 
 / / 	 { 
 
 / /                 D e b u g . A s s e r t ( i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . B Y T E 1 D _ X 8 R 8 G 8 B 8 _ 3 2 ) ) ; 
 
 / / 	 	 f i n a l   b y t e [ ]   i n p u t = ( b y t e [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 / / 	 	 N y A R I n t S i z e   s = i _ r a s t e r . g e t S i z e ( ) ; 
 
 / / 	 	 i n t   s k i p = ( i _ s k i p * s . w - i _ w ) * 4 ; 
 
 / / 	 	 f i n a l   i n t   p i x _ c o u n t = i _ w ; 
 
 / / 	 	 f i n a l   i n t   p i x _ m o d _ p a r t = p i x _ c o u n t - ( p i x _ c o u n t % 8 ) ; 	 	 	 
 
 / / 	 	 / / ]
NK001 Le0d0pgW0f0D0O0
 
 / / 	 	 i n t   p t = ( i _ t * s . w + i _ l ) * 4 ; 
 
 / / 	 	 f o r   ( i n t   y   =   i _ h - 1 ;   y   > = 0   ;   y - = i _ s k i p ) { 
 
 / / 	 	 	 i n t   x ; 
 
 / / 	 	 	 f o r   ( x   =   p i x _ c o u n t - 1 ;   x   > = p i x _ m o d _ p a r t ;   x - - ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t +   3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 f o r   ( ; x > = 0 ; x - = 8 ) { 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 	 o _ h i s t o g r a m [ ( ( i n p u t [ p t + 1 ] &   0 x f f ) + ( i n p u t [ p t + 2 ] &   0 x f f ) + ( i n p u t [ p t + 3 ] &   0 x f f ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 p t + = 4 ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 / / 0000
 
 / / 	 	 	 p t + = s k i p ; 
 
 / / 	 	 } 
 
 / / 	 	 r e t u r n ; 	 
 
 / /         } 
 
 / / } 
 
 / / 
 
 / / c l a s s   N y A R R a s t e r T h r e s h o l d A n a l y z e r _ H i s t o g r a m _ W O R D 1 D _ R 5 G 6 B 5 _ 1 6 L E   i m p l e m e n t s   N y A R R a s t e r A n a l y z e r _ H i s t o g r a m . I F i l t e r 
 
 / / { 
 
 / / 	 p u b l i c   b o o l e a n   i s S u p p o r t ( I N y A R R a s t e r   i _ r a s t e r ) 
 
 / / 	 { 
 
 / / 	 	 r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . W O R D 1 D _ R 5 G 6 B 5 _ 1 6 L E ) ; 
 
 / / 	 } 	 	 
 
 / / 	 p u b l i c   v o i d   c r e a t e H i s t o g r a m ( I N y A R R a s t e r   i _ r a s t e r , i n t   i _ l , i n t   i _ t , i n t   i _ w , i n t   i _ h ,   i n t [ ]   o _ h i s t o g r a m , i n t   i _ s k i p ) 
 
 / / 	 { 
 
 / /                 D e b u g . A s s e r t ( i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . W O R D 1 D _ R 5 G 6 B 5 _ 1 6 L E ) ) ; 
 
 / / 	 	 f i n a l   s h o r t [ ]   i n p u t = ( s h o r t [ ] ) i _ r a s t e r . g e t B u f f e r ( ) ; 
 
 / / 	 	 N y A R I n t S i z e   s = i _ r a s t e r . g e t S i z e ( ) ; 
 
 / / 	 	 i n t   s k i p = ( i _ s k i p * s . w - i _ w ) ; 
 
 / / 	 	 f i n a l   i n t   p i x _ c o u n t = i _ w ; 
 
 / / 	 	 f i n a l   i n t   p i x _ m o d _ p a r t = p i x _ c o u n t - ( p i x _ c o u n t % 8 ) ; 	 	 	 
 
 / / 	 	 / / ]
NK001 Le0d0pgW0f0D0O0
 
 / / 	 	 i n t   p t = ( i _ t * s . w + i _ l ) ; 
 
 / / 	 	 f o r   ( i n t   y   =   i _ h - 1 ;   y   > = 0   ;   y - = i _ s k i p ) { 
 
 / / 	 	 	 i n t   x , v ; 
 
 / / 	 	 	 f o r   ( x   =   p i x _ c o u n t - 1 ;   x   > = p i x _ m o d _ p a r t ;   x - - ) { 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 f o r   ( ; x > = 0 ; x - = 8 ) { 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 	 v   = ( i n t ) i n p u t [ p t + + ] ;   o _ h i s t o g r a m [ ( ( ( v   &   0 x f 8 0 0 )   > >   8 )   +   ( ( v   &   0 x 0 7 e 0 )   > >   3 )   +   ( ( v   &   0 x 0 0 1 f )   < <   3 ) ) / 3 ] + + ; 
 
 / / 	 	 	 } 
 
 / / 	 	 	 / / 0000
 
 / / 	 	 	 p t + = s k i p ; 
 
 / / 	 	 } 
 
 / / 	 	 r e t u r n ; 	 
 
 / /         } 
 
 / / } 