/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t C S   i s   C #   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 ; 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ; 
 
 u s i n g   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 ; 
 
 
 
 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 . r p f 
 
 { 
 
 
 
         / * * 
 
           *   N y A R R e a l i t y (un0000iQ00000
 
           *   R o b e r t s RMn02 WN$P1 6 
Pk0 g'Y$P6RP0K0Q00SW0_0$Pg0Y00
 
           *   Szh0]zn01 0000o008^k00 L0eQ0~0Y00
 
           *   X = | - 1 ,   0 |     Y = | 0 , - 1 | 
 
           *       |   0 ,   1 |         | 1 ,   0 | 
 
           *   V = s q r t ( X ^ 2 + Y + 2 ) / 2 
 
           * / 
 
         p u b l i c   c l a s s   N e g a t i v e S q R o b e r t s 
 
         { 
 
 	         p r i v a t e   I d o F i l t e r I m p l   _ d o _ f i l t e r _ i m p l ;   
 
 	         p u b l i c   N e g a t i v e S q R o b e r t s ( i n t   i _ r a s t e r _ t y p e ) 
 
 	         { 
 
 	 	         t h i s . i n i t I n s t a n c e ( i _ r a s t e r _ t y p e ) ; 
 
 	         } 
 
 	         p u b l i c   v o i d   i n i t I n s t a n c e ( i n t   i _ r a s t e r _ t y p e ) 
 
 	         { 
 
 	 	         s w i t c h   ( i _ r a s t 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 : 
 
 	 	 	         t h i s . _ d o _ f i l t e r _ i m p l = n e w   I d o F i l t e r I m p l _ G R A Y _ 8 ( ) ; 
 
 	 	 	         b r e a k ; 
 
 	 	         d e f a u l t : 
 
 	 	 	         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   v o i d   d o F i l t e r ( I N y A R R a s t e r   i _ i n p u t ,   I N y A R R a s t e r   i _ o u t p u t ) 
 
 	         { 
 
 	 	         t h i s . _ d o _ f i l t e r _ i m p l . d o F i l t e r ( i _ i n p u t , i _ o u t p u t , i _ i n p u t . g e t S i z e ( ) ) ; 
 
 	         } 
 
         	 
 
 	         i n t e r f a c e   I d o F i l t e r I m p l 
 
 	         { 
 
 	 	         v o i d   d o F i l t e r ( I N y A R R a s t e r   i _ i n p u t ,   I N y A R R a s t e r   i _ o u t p u t , N y A R I n t S i z e   i _ s i z e ) ; 
 
 	         } 
 
 	         p r i v a t e   c o n s t   i n t   S H = 4 ; 
 
 	         c l a s s   I d o F i l t e r I m p l _ G R A Y _ 8   :   I d o F i l t e r I m p l 
 
 	         { 
 
 	 	         p u b l i c   v o i d   d o F i l t e r ( I N y A R R a s t e r   i _ i n p u t ,   I N y A R R a s t e r   i _ o u t p u t , N y A R I n t S i z e   i _ s i z e ) 
 
 	 	         { 
 
                                 D e b u g . A s s e r t ( i _ i n p u t . 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 _ G R A Y _ 8 ) ) ; 
 
                                 D e b u g . A s s e r t ( i _ o u t p u t . 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 _ G R A Y _ 8 ) ) ; 
 
 	 	 	         i n t [ ]   i n _ p t r   = ( i n t [ ] ) i _ i n p u t . g e t B u f f e r ( ) ; 
 
 	 	 	         i n t [ ]   o u t _ p t r = ( i n t [ ] ) i _ o u t p u t . g e t B u f f e r ( ) ; 
 
 	 	 	         i n t   w i d t h = i _ s i z e . w ; 
 
 	 	 	         i n t   i d x = 0 ; 
 
 	 	 	         i n t   i d x 2 = w i d t h ; 
 
 	 	 	         i n t   f x , f y ; 
 
 	 	 	         i n t   m o d _ p = ( w i d t h - 2 ) - ( w i d t h - 2 ) % 4 ; 
 
 	 	 	         f o r ( i n t   y = i _ s i z e . h - 2 ; y > = 0 ; y - - ) { 
 
 	 	 	 	         i n t   p 0 0 = i n _ p t r [ i d x + + ] ; 
 
 	 	 	 	         i n t   p 1 0 = i n _ p t r [ i d x 2 + + ] ; 
 
 	 	 	 	         i n t   p 0 1 , p 1 1 ; 
 
 	 	 	 	         i n t   x = w i d t h - 2 ; 
 
 	 	 	 	         f o r ( ; x > = m o d _ p ; x - - ) { 
 
 	 	 	 	 	         p 0 1 = i n _ p t r [ i d x + + ] ; p 1 1 = i n _ p t r [ i d x 2 + + ] ; 
 
 	 	 	 	 	         f x = p 1 1 - p 0 0 ; f y = p 1 0 - p 0 1 ; 
 
         / / 	 	 	 	 	 o u t _ p t r [ i d x - 2 ] = 2 5 5 - ( ( ( f x < 0 ? - f x : f x ) + ( f y < 0 ? - f y : f y ) ) > > 1 ) ; 
 
 	 	 	 	 	         f x = ( f x * f x + f y * f y ) > > S H ; o u t _ p t r [ i d x - 2 ] = ( f x > 2 5 5 ? 0 : 2 5 5 - f x ) ; 
 
 	 	 	 	 	         p 0 0 = p 0 1 ; 
 
 	 	 	 	 	         p 1 0 = p 1 1 ; 
 
 	 	 	 	         } 
 
 	 	 	 	         f o r ( ; x > = 0 ; x - = 4 ) { 
 
 	 	 	 	 	         p 0 1 = i n _ p t r [ i d x + + ] ; p 1 1 = i n _ p t r [ i d x 2 + + ] ; 
 
 	 	 	 	 	         f x = p 1 1 - p 0 0 ; 
 
 	 	 	 	 	         f y = p 1 0 - p 0 1 ; 
 
         / / 	 	 	 	 	 o u t _ p t r [ i d x - 2 ] = 2 5 5 - ( ( ( f x < 0 ? - f x : f x ) + ( f y < 0 ? - f y : f y ) ) > > 1 ) ; 
 
 	 	 	 	 	         f x = ( f x * f x + f y * f y ) > > S H ; o u t _ p t r [ i d x - 2 ] = ( f x > 2 5 5 ? 0 : 2 5 5 - f x ) ; 
 
 	 	 	 	 	         p 0 0 = p 0 1 ; p 1 0 = p 1 1 ; 
 
 	 	 	 	 	         p 0 1 = i n _ p t r [ i d x + + ] ; p 1 1 = i n _ p t r [ i d x 2 + + ] ; 
 
 	 	 	 	 	         f x = p 1 1 - p 0 0 ; 
 
 	 	 	 	 	         f y = p 1 0 - p 0 1 ; 
 
         / / 	 	 	 	 	 o u t _ p t r [ i d x - 2 ] = 2 5 5 - ( ( ( f x < 0 ? - f x : f x ) + ( f y < 0 ? - f y : f y ) ) > > 1 ) ; 
 
 	 	 	 	 	         f x = ( f x * f x + f y * f y ) > > S H ; o u t _ p t r [ i d x - 2 ] = ( f x > 2 5 5 ? 0 : 2 5 5 - f x ) ; 
 
 	 	 	 	 	         p 0 0 = p 0 1 ; p 1 0 = p 1 1 ; 
 
 	 	 	 	 	         p 0 1 = i n _ p t r [ i d x + + ] ; p 1 1 = i n _ p t r [ i d x 2 + + ] ; 
 
         	 	 	 	 	 
 
 	 	 	 	 	         f x = p 1 1 - p 0 0 ; 
 
 	 	 	 	 	         f y = p 1 0 - p 0 1 ; 
 
         / / 	 	 	 	 	 o u t _ p t r [ i d x - 2 ] = 2 5 5 - ( ( ( f x < 0 ? - f x : f x ) + ( f y < 0 ? - f y : f y ) ) > > 1 ) ; 
 
 	 	 	 	 	         f x = ( f x * f x + f y * f y ) > > S H ; o u t _ p t r [ i d x - 2 ] = ( f x > 2 5 5 ? 0 : 2 5 5 - f x ) ; 
 
 	 	 	 	 	         p 0 0 = p 0 1 ; p 1 0 = p 1 1 ; 
 
 
 
 	 	 	 	 	         p 0 1 = i n _ p t r [ i d x + + ] ; p 1 1 = i n _ p t r [ i d x 2 + + ] ; 
 
 	 	 	 	 	         f x = p 1 1 - p 0 0 ; 
 
 	 	 	 	 	         f y = p 1 0 - p 0 1 ; 
 
         / / 	 	 	 	 	 o u t _ p t r [ i d x - 2 ] = 2 5 5 - ( ( ( f x < 0 ? - f x : f x ) + ( f y < 0 ? - f y : f y ) ) > > 1 ) ; 
 
 	 	 	 	 	         f x = ( f x * f x + f y * f y ) > > S H ; o u t _ p t r [ i d x - 2 ] = ( f x > 2 5 5 ? 0 : 2 5 5 - f x ) ; 
 
 	 	 	 	 	         p 0 0 = p 0 1 ; p 1 0 = p 1 1 ; 
 
 
 
 	 	 	 	         } 
 
 	 	 	 	         o u t _ p t r [ i d x - 1 ] = 2 5 5 ; 
 
 	 	 	         } 
 
 	 	 	         f o r ( i n t   x = w i d t h - 1 ; x > = 0 ; x - - ) { 
 
 	 	 	 	         o u t _ p t r [ i d x + + ] = 2 5 5 ; 
 
 	 	 	         } 
 
 	 	 	         r e t u r n ; 
 
 	 	         } 
 
 	         } 
 
         } 
 
 } 