Пример #1
0
 def test_cooccurrence(self):
     P, levels = haralick.cooccurrence(gray4, labels, 0, 1)
     correct = np.array(
         [[[2, 2, 1, 0], [0, 2, 0, 0], [0, 0, 3, 1], [0, 0, 0, 1]]], float)
     correct = correct / np.sum(correct)
     self.assertEqual(levels, 4)
     self.assertTrue((P == correct).all())
Пример #2
0
    def test_01_01_regression_edge(self):
        '''Test coocurrence with an object smaller than the scal near the edge.

        There's a corner case here where the co-occurrence is being done
        on pixels "scale" to the right of objects and all objects are
        within "scale" of the right edge. That means that all objects get
        compared to nothing and the histogram code blows up.
        '''
        labels = np.zeros((100,100),int)
        labels[90:99,90:99] = 1
        np.random.seed(0)
        image = (np.random.uniform(size=(100,100))*8).astype(int)
        c, nlevels = haralick.cooccurrence(image, labels, 0, 30)
        self.assertTrue(np.all(c==0))
Пример #3
0
    def test_01_01_regression_edge(self):
        '''Test coocurrence with an object smaller than the scal near the edge.

        There's a corner case here where the co-occurrence is being done
        on pixels "scale" to the right of objects and all objects are
        within "scale" of the right edge. That means that all objects get
        compared to nothing and the histogram code blows up.
        '''
        labels = np.zeros((100, 100), int)
        labels[90:99, 90:99] = 1
        np.random.seed(0)
        image = (np.random.uniform(size=(100, 100)) * 8).astype(int)
        c, nlevels = haralick.cooccurrence(image, labels, 0, 30)
        self.assertTrue(np.all(c == 0))
Пример #4
0
 def test_cooccurrence(self):
     P,levels = haralick.cooccurrence(gray4, labels, 0, 1)
     correct = np.array([[[2,2,1,0], [0,2,0,0], [0,0,3,1], [0,0,0,1]]],float)
     correct = correct / np.sum(correct)
     self.assertEqual(levels,4)
     self.assertTrue((P == correct).all())