/ *   
 
   *   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 
 
 
 
 { 
 
 
 
 
 
 
 
 / * * 
 
   *   ;uP000n00000g0Y00;uP000K000*}bQn00000{W0f00QR0000k0<h
}W0~0Y00
 
   *   eQR- L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n 
 
   *   QR- L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t 
 
   * / 
 
 p u b l i c   c l a s s   L o w R e s o l u t i o n L a b e l i n g S a m p l e r 
 
 { 
 
 	 / * * 
 
 	   *   1 / n ;uPn00y00000Y000000
 
 	   *   @ a u t h o r   n y a t l a 
 
 	   * 
 
 	   * / 
 
 	 c l a s s   M a i n _ L a b e l i n g   :   N y A R L a b e l i n g _ R l e 
 
 	 { 
 
 	 	 p r i v a t e   i n t   _ p i x ; 
 
 	 	 p u b l i c   i n t   c u r r e n t _ t h ; 
 
 	 	 p u b l i c   L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t   c u r r e n t _ o u t p u t ; 
 
                 p u b l i c   M a i n _ L a b e l i n g ( i n t   i _ w i d t h ,   i n t   i _ h e i g h t ,   i n t   i _ p i x _ b a s e ) 
 
                         :   b a s e ( i _ w i d t h ,   i _ h e i g h t ) 
 
 	 	 { 
 
 	 	 	 t h i s . _ p i x = i _ p i x _ b a s e ; 
 
 	 	 } 
 
 	 	 / * * 
 
 	 	   *   @ O v e r r i d e 
 
 	 	   * / 
 
 	 	 p r o t e c t e d   o v e r r i d e   v o i d   o n L a b e l F o u n d ( N y A R R l e L a b e l F r a g m e n t I n f o   i R e f L a b e l ) 
 
 	 	 { 
 
 	 	 	 / / w i d t h h0h e i g h t n0{
 
 	 	 	 i n t   w = i R e f L a b e l . c l i p _ r - i R e f L a b e l . c l i p _ l ; 
 
 	 	 	 i n t   h = i R e f L a b e l . c l i p _ b - i R e f L a b e l . c l i p _ t ; 
 
 	 	 	 / / 1 * 1 ( 1 b i t P i x e l n05 * 5 ) NNn04XTo00iQ
N
 
 	 	 	 / / *g[ňR: 2 * 2 ( 1 b i t P i x e l n08 * 8 ) NNn04XTo00P^1 g0QiQ
 
 	 	 	 / / *g[ňR: 3 * 3 , 4 * 4 ( 1 b i t P i x e l n01 2 * 1 2 , 1 6 * 1 6 ) NNn04XTo00P^2 g0QiQ
 
 	 	 	 i f ( w < 1 0   | |   h < 1 0 ) { 
 
 	 	 	 	 / / Nn0h0S00o0QiQ_jij0W00
 
 	 	 	 	 r e t u r n ; 
 
 	 	 	 } 
 
 	 	 	 L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t . I t e m   i t e m = c u r r e n t _ o u t p u t . p r e P u s h ( ) ; 
 
 	 	 	 i f ( i t e m = = n u l l ) { 
 
 	 	 	 	 r e t u r n ; 
 
 	 	 	 } 
 
 	 	 	 i n t   p i x = t h i s . _ p i x ; 
 
 	 	 	 i t e m . e n t r y _ p o s . x = i R e f L a b e l . e n t r y _ x ; 
 
 	 	 	 i t e m . e n t r y _ p o s . y = i R e f L a b e l . c l i p _ t ; 
 
 	 	 	 i t e m . b a s e _ a r e a . x = i R e f L a b e l . c l i p _ l * p i x ; 
 
 	 	 	 i t e m . b a s e _ a r e a . y = i R e f L a b e l . c l i p _ t * p i x ; 
 
 	 	 	 i t e m . b a s e _ a r e a . w = w * p i x ; 
 
 	 	 	 i t e m . b a s e _ a r e a . h = h * p i x ; 
 
 	 	 	 i t e m . b a s e _ a r e a _ c e n t e r . x = i t e m . b a s e _ a r e a . x + i t e m . b a s e _ a r e a . w / 2 ; 
 
 	 	 	 i t e m . b a s e _ a r e a _ c e n t e r . y = i t e m . b a s e _ a r e a . y + i t e m . b a s e _ a r e a . h / 2 ; 
 
 	 	 	 i t e m . b a s e _ a r e a _ s q _ d i a g o n a l = ( w * w + h * h ) * ( p i x * p i x ) ; 
 
 	 	 	 i t e m . l e b e l i n g _ t h = t h i s . c u r r e n t _ t h ; 
 
 	 	 } 
 
 	 	 
 
 	 } 
 
 	 p r i v a t e   M a i n _ L a b e l i n g   _ m a i n _ l a b e l i n g ; 
 
 	 / * * 
 
 	   *   0000000g0Y00s a m p l i n g Y000000n000000c[W0f000000000RgSW0~0Y00
 
 	   *   @ p a r a m   i _ w i d t h 
 
 	   *   000000Y00L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n n0W,gP^E^
 
 	   *   S0n0$Po00s a m p l i n g k0!nY0L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n k0-[W0_0$Ph0TX0g0B00_L0B00~0Y00
 
 	   *   @ p a r a m   i _ h e i g h t 
 
 	   *   000000Y00L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n n0W,gP^ؚU0
 
 	   *   S0n0$Po00s a m p l i n g k0!nY0L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n k0-[W0_0$Ph0TX0g0B00_L0B00~0Y00
 
 	   *   @ p a r a m   i _ p i x _ s i z e 
 
 	   *   ^j|n0
PsOpe0c[Y000OH0p01 / 2 ;uP( bMz1 / 4 ) n0000000P}g0CQ;uP000k0;bY0h0M0o004 0c[Y000
 
 	   *    gNOP^h0Y00R a s t e r n0d e p t h 0
 
 	   *   S0n0$Po00s a m p l i n g k0!nY0L o w R e s o l u t i o n L a b e l i n g S a m p l e r I n k0-[W0_0$Ph0TX0g0B00_L0B00~0Y00
 
 	   *   < p > 00: 000b__n0Y$PS0H00j0000`00I m p l \Ob0< / p > 
 
 	   *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	   * / 
 
 	 p u b l i c   L o w R e s o l u t i o n L a b e l i n g S a m p l e r ( i n t   i _ w i d t h , i n t   i _ h e i g h t , i n t   i _ p i x _ s i z e ) 
 
 	 { 
 
 	 	 t h i s . _ m a i n _ l a b e l i n g = n e w   M a i n _ L a b e l i n g ( i _ w i d t h / i _ p i x _ s i z e , i _ h e i g h t / i _ p i x _ s i z e , i _ p i x _ s i z e ) ; 
 
 	 } 
 
 	 / * * 
 
 	   *   i _ i n n00000000000W0f00o _ o u t k00000$P0\ObW0~0Y00
 
 	   *   S0n0peo00o _ o u t k0i _ i n n0000000P}g0QRW0~0Y00ek0o _ o u t k0B00000o0RgSU00~0Y00
 
 	   *   @ p a r a m   i _ i n 
 
 	   *   eQRCQn0000g0Y00
 
 	   *   @ p a r a m   i _ t h 
 
 	   *   0y0000n0weE\$Pg0Y00
 
 	   *   @ p a r a m   o _ o u t 
 
 	   *   QRHQn0000g0Y00
 
 	   *   @ t h r o w s   N y A R E x c e p t i o n 
 
 	   * / 
 
 	 p u b l i c   v o i d   s a m p l i n g ( N y A R G r a y s c a l e R a s t e r   i _ i n , i n t   i _ t h , L o w R e s o l u t i o n L a b e l i n g S a m p l e r O u t   o _ o u t ) 
 
 	 { 
 
 	 	 / / 000n000000RgS
 
 	 	 M a i n _ L a b e l i n g   l b = t h i s . _ m a i n _ l a b e l i n g ; 
 
 	 	 l b . c u r r e n t _ o u t p u t = o _ o u t ; 
 
 	 	 l b . c u r r e n t _ t h = i _ t h ; 
 
 
 
 
 
 	 	 / / 00000n0-[
 
 	 	 o _ o u t . i n i t i a l i z e P a r a m s ( ) ; 
 
 	 	 / / 0y0000
 
 	 	 l b . s e t A r e a R a n g e ( 1 0 0 0 0 , 3 ) ; 
 
 	 	 l b . l a b e l i n g ( i _ i n , i _ t h ) ; 
 
 	 } 
 
 } 
 
 } 