/ *   
 
   *   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 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0r00000000g0Y00
 
           *   0000000n0Q[k0_c0f00;u }0ncW0~0Y00
 
           *   < / p > 
 
           * / 
 
         p u b l i c   i n t e r f a c e   I N y A R G s T o n e T a b l e F i l t e r 
 
         { 
 
                 / * * 
 
                   *   0000000k00p0 , 0 0NY000PM0i _ a n0v}0[W0f0000000i_W0~0Y00
 
                   *   < p > -[O- 
 
                   *   i _ a n0$P0v h0W0_0h0M00NNn00F0k0j00~0Y00
 
                   *   < u l > 
 
                   *   < l i > v < = 0 	 	 Ҟr
 
                   *   < l i > 0 < v < 1 	 fO0Y000
 
                   *   < l i > v = 0 	 	 	YSW0j0D0
 
                   *   < l i > 1 < v < 2 5 5 	 f0O0Y000
 
                   *   < l i > 2 5 5 < = v 	 }vr
 
                   *   < / u l > 
 
                   *   < / p > 
 
                   *   @ p a r a m   i _ a 
 
                   *   v}n0PM0g0Y00
 
                   * / 
 
                 v o i d   l i n e ( d o u b l e   i _ a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) ; 
 
                 / * * 
 
                   *   0000000k00px , y 0NY000PM0i _ a n0v}0[W0f0000000i_W0~0Y00
 
                   *   @ p a r a m   i _ x 
 
                   *   v}n0Np
 
                   *   @ p a r a m   i _ y 
 
                   *   v}n0Np
 
                   *   @ p a r a m   i _ a 
 
                   *   v}n0PM0g0Y00
 
                   * / 
 
                 v o i d   l i n e ( i n t   i _ x ,   i n t   i _ y ,   d o u b l e   i _ a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) ; 
 
                 / * * 
 
                   *   p  i _ x , i _ y 0-N_h0Y000000i _ g a i n n000000pe0[W0f0000000i_W0~0Y00
 
                   *   @ p a r a m   i _ x 
 
                   *   v}n0Np
 
                   *   @ p a r a m   i _ y 
 
                   *   v}n0Np
 
                   *   @ p a r a m   i _ g a i n 
 
                   *   00000pen0000$P
 
                   * / 
 
                 v o i d   s i g m o i d ( i n t   i _ x ,   i n t   i _ y ,   d o u b l e   i _ g a i n ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) ; 
 
                 / * * 
 
                   *   000܈ck$P0[W0f0000000i_W0~0Y00
 
                   *   @ p a r a m   i _ g a m m a 
 
                   *   000$P
 
                   * / 
 
                 v o i d   g a m m a ( d o u b l e   i _ g a m m a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) ; 
 
         } 
 
 
 
 
 
         c l a s s   N y A R G s T o n e T a b l e F i l t e r   :   I N y A R G s T o n e T a b l e F i l t e r 
 
         { 
 
                 p r i v a t e   i n t [ ]   _ t a b l e   =   n e w   i n t [ 2 5 6 ] ; 
 
                 p r i v a t e   I N y A R G s C u s t o m T o n e T a b l e F i l t e r   _ t o n e _ f i l t e r ; 
 
 
 
                 p u b l i c   N y A R G s T o n e T a b l e F i l t e r ( 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 . _ t o n e _ f i l t e r   =   N y A R G s F i l t e r F a c t o r y . c r e a t e C u s t o m T o n e T a b l e F i l t e r ( i _ r a s t e r ) ; 
 
                 } 
 
 
 
                 p u b l i c   v o i d   l i n e ( i n t   i _ x ,   i n t   i _ y ,   d o u b l e   i _ a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) 
 
                 { 
 
                         i f   ( i _ a   = =   0 ) 
 
                         { 
 
                                 i n t   i ; 
 
                                 f o r   ( i   =   0 ;   i   < =   i _ x ;   i + + ) 
 
                                 { 
 
                                         t h i s . _ t a b l e [ i ]   =   0 ; 
 
                                 } 
 
                                 f o r   ( i   =   0 ;   i   <   2 5 6 ;   i + + ) 
 
                                 { 
 
                                         t h i s . _ t a b l e [ i ]   =   2 5 5 ; 
 
                                 } 
 
                         } 
 
                         e l s e 
 
                         { 
 
                                 i n t   b   =   i _ y   -   ( i n t ) ( i _ a   *   i _ x ) ; 
 
                                 f o r   ( i n t   i   =   0 ;   i   <   2 5 6 ;   i + + ) 
 
                                 { 
 
                                         i n t   v   =   ( i n t ) ( i _ a   *   i )   +   b ; 
 
                                         t h i s . _ t a b l e [ i ]   =   v   <   0   ?   0   :   v   >   2 5 5   ?   2 5 5   :   v ; 
 
                                 } 
 
                         } 
 
                         t h i s . _ t o n e _ f i l t e r . d o F i l t e r ( t h i s . _ t a b l e ,   i _ o u t p u t ) ; 
 
                 } 
 
 
 
                 p u b l i c   v o i d   l i n e ( d o u b l e   i _ a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) 
 
                 { 
 
                         t h i s . l i n e ( 0 ,   0 ,   i _ a ,   i _ o u t p u t ) ; 
 
                 } 
 
 
 
                 p u b l i c   v o i d   s i g m o i d ( i n t   i _ x ,   i n t   i _ y ,   d o u b l e   i _ g a i n ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) 
 
                 { 
 
                         f o r   ( i n t   i   =   0 ;   i   <   2 5 6 ;   i + + ) 
 
                         { 
 
                                 i n t   v   =   2 5 5   *   ( i n t ) ( 1   /   ( 1   +   M a t h . E x p ( i _ g a i n   *   ( i   -   i _ x ) ) )   -   0 . 5 )   +   i _ y ; 
 
                                 t h i s . _ t a b l e [ i ]   =   v   <   0   ?   0   :   v   >   2 5 5   ?   2 5 5   :   v ; 
 
                         } 
 
                         t h i s . _ t o n e _ f i l t e r . d o F i l t e r ( t h i s . _ t a b l e ,   i _ o u t p u t ) ; 
 
                 } 
 
 
 
                 p u b l i c   v o i d   g a m m a ( d o u b l e   i _ g a m m a ,   I N y A R G r a y s c a l e R a s t e r   i _ o u t p u t ) 
 
                 { 
 
                         f o r   ( i n t   i   =   0 ;   i   <   2 5 6 ;   i + + ) 
 
                         { 
 
                                 t h i s . _ t a b l e [ i ]   =   ( i n t ) ( M a t h . P o w ( ( d o u b l e ) i   /   2 5 5 . 0 ,   i _ g a m m a )   *   2 5 5 . 0 ) ; 
 
                         } 
 
                         t h i s . _ t o n e _ f i l t e r . d o F i l t e r ( t h i s . _ t a b l e ,   i _ o u t p u t ) ; 
 
                 } 
 
         } 
 
 } 
 
 