Exemplo n.º 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)
Exemplo n.º 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] *= 0.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)
Exemplo n.º 3
0
 def test_H3(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.mux[0], 2.0833, 4)
     self.assertAlmostEqual(h.muy[0], 2.5000, 4)
     self.assertAlmostEqual(h.sigmax[0], 1.0375, 4)
     self.assertAlmostEqual(h.sigmay[0], 0.9574, 4)
     self.assertAlmostEqual(h.H3()[0], 0.7970, 4)
Exemplo n.º 4
0
 def test_all_01(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     fv = h.all()
     self.assertTrue((np.array(list(map(len, fv))) == 1).all())
Exemplo n.º 5
0
 def test_H13(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H13()[0], 0.8687, 4)
Exemplo n.º 6
0
 def test_H12(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H12()[0], -0.5285, 4)
Exemplo n.º 7
0
 def test_H9(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H9()[0], 1.8637, 4)
Exemplo n.º 8
0
 def test_H8(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H8()[0], 1.7046, 4)
Exemplo n.º 9
0
 def test_H7(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H7()[0], 3.5764, 4)
Exemplo n.º 10
0
 def test_H6(self):
     h = haralick.Haralick(gray, labels, 0, 1, nlevels=4)
     self.assertAlmostEqual(h.H6()[0], 4.5833, 4)