@@ -12,6 +12,7 @@ def setUp(self):
1212 self .img1 = Image (img = np .zeros ((3 , 3 , 3 ), dtype = np .float ))
1313 self .img2 = Image (img = np .zeros ((3 , 3 , 3 ), dtype = np .float )+ 1 )
1414 self .img3 = Image (img = np .zeros ((3 , 3 , 3 ), dtype = np .float )+ 2 )
15+ self .img4 = Image (img = np .zeros ((3 , 3 , 3 ), dtype = np .float )+ 7 )
1516
1617 def test_min_stack (self ):
1718 stack = Stack ('min' , 2 )
@@ -77,6 +78,20 @@ def test_median_stack(self):
7778 result = stack .calculate ().img
7879 self .assertItemsEqual (result , np .ones ((3 , 3 , 3 ), dtype = np .uint16 ))
7980
81+ def test_sigma_stack (self ):
82+ stack = Stack ('sigma' , 9 , kwargs = {'kappa' : 2 , 'max_iters' : 1 })
83+ self .assertEqual (stack .mode , 'sigma' )
84+ self .assertEqual (stack .num , 9 )
85+ self .assertEqual (stack ._num , 0 )
86+ for i in range (3 ):
87+ stack ._update_stack (self .img2 )
88+ stack ._update_stack (self .img3 )
89+ stack ._update_stack (self .img4 )
90+
91+ result = stack .calculate ().img
92+ self .assertItemsEqual (result , 1. / 3. + 3 * np .ones ((3 , 3 , 3 ),
93+ dtype = np .uint16 ))
94+
8095 def assertItemsEqual (self , a , b ):
8196 if isinstance (a , np .ndarray ):
8297 self .assertTrue (np .all (a == b ))
0 commit comments