示例#1
0
    def test_one_components(self):
        dut = fltr.LargestNConnectedComponents(1, False)
        result = dut.execute(self.image)

        self.assertEqual(result.GetPixel((4, 0)), 1)
        self.assertEqual(result.GetPixel((4, 1)), 1)
        self.assertEqual(result.GetPixel((4, 2)), 1)

        result_array = sitk.GetArrayFromImage(result)
        self.assertEqual(result_array.sum(), 3)
示例#2
0
    def test_consecutive_labels(self):
        dut = fltr.LargestNConnectedComponents(3, True)
        result = dut.execute(self.image)

        self.assertEqual(result.GetPixel((0, 0)), 3)
        self.assertEqual(result.GetPixel((2, 0)), 2)
        self.assertEqual(result.GetPixel((2, 1)), 2)
        self.assertEqual(result.GetPixel((4, 0)), 1)
        self.assertEqual(result.GetPixel((4, 1)), 1)
        self.assertEqual(result.GetPixel((4, 2)), 1)

        result_array = sitk.GetArrayFromImage(result)
        self.assertEqual(result_array.sum(), 10)
示例#3
0
 def test_zero_components(self):
     with self.assertRaises(ValueError):
         fltr.LargestNConnectedComponents(0, False)