コード例 #1
0
    def test_02_01_angles(self):
        '''Test that measurements are stable on i,j swap'''

        labels = np.ones((10, 20), int)
        np.random.seed(12)
        image = np.random.uniform(size=(10, 20)).astype(np.float32)
        hi = haralick.Haralick(image, labels, 1, 0)
        hj = haralick.Haralick(image.transpose(), labels.transpose(), 0, 1)
        for him, hjm in zip(hi.all(), hj.all()):
            self.assertEqual(him, hjm)
コード例 #2
0
 def test_01_02_mask(self):
     '''Test with a masked image'''
     labels = np.ones((10, 20), int)
     np.random.seed(12)
     image = np.random.uniform(size=(10, 20)).astype(np.float32)
     image[:, :10] *= .5
     mask = np.ones((10, 20), bool)
     mask[:, 10:] = False
     # Masked haralick
     hm = haralick.Haralick(image, labels, 0, 1, mask=mask)
     # Expected haralick
     he = haralick.Haralick(image[:, :10], labels[:, :10], 0, 1)
     for measured, expected in zip(hm.all(), he.all()):
         self.assertEqual(measured, expected)
コード例 #3
0
 def test_H3(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.mux, 2.0833, 4)
     self.assertAlmostEqual(h.muy, 2.5000, 4)
     self.assertAlmostEqual(h.sigmax, 1.0375, 4)
     self.assertAlmostEqual(h.sigmay, 0.9574, 4)
     self.assertAlmostEqual(h.H3()[0], 0.7970, 4)
コード例 #4
0
 def test_H12(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H12()[0], -0.5285, 4)
コード例 #5
0
 def test_H11(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H11()[0], 0.8240, 4)
コード例 #6
0
 def test_H9(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H9()[0], 1.8637, 4)
コード例 #7
0
 def test_H8(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H8()[0], 1.7046, 4)
コード例 #8
0
 def test_H7(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H7()[0], 3.5764, 4)
コード例 #9
0
 def test_H6(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H6()[0], 4.5833, 4)
コード例 #10
0
 def test_all_01(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     fv = h.all()
     self.assertTrue((np.array(map(len, fv)) == 1).all())