MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / TEST

Function TEST

Testing/Unit/sitkLabelStatisticsTest.cxx:25–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include <memory>
24
25TEST(LabelStatistics, Simple)
26{
27 // By using the same image, the label min/max values should equal the label itself.
28 itk::simple::Image intensityImage = itk::simple::ReadImage(dataFinder.GetFile("Input/2th_cthead1.png"));
29 itk::simple::Image labelImage = itk::simple::ReadImage(dataFinder.GetFile("Input/2th_cthead1.png"));
30
31 itk::simple::LabelStatisticsImageFilter lsFilter;
32
33 EXPECT_TRUE(lsFilter.GetUseHistograms());
34 lsFilter.UseHistogramsOff();
35 EXPECT_FALSE(lsFilter.GetUseHistograms());
36 lsFilter.UseHistogramsOn();
37 EXPECT_TRUE(lsFilter.GetUseHistograms());
38 lsFilter.SetUseHistograms(false);
39 EXPECT_FALSE(lsFilter.GetUseHistograms());
40 lsFilter.SetUseHistograms(true);
41 EXPECT_TRUE(lsFilter.GetUseHistograms());
42
43 try
44 {
45 lsFilter.Execute(intensityImage, labelImage);
46 }
47 catch (itk::ExceptionObject & e)
48 {
49 std::cout << "LabelStatistics failed: " << e.what() << std::endl;
50 }
51
52 std::vector<int64_t> labels = lsFilter.GetLabels();
53 for (std::vector<int64_t>::const_iterator i = labels.begin(); i != labels.end(); ++i)
54 {
55 // By using the same image, the label min/max/mean values should equal the label itself.
56 ASSERT_EQ(lsFilter.GetMinimum(*i), *i);
57 ASSERT_EQ(lsFilter.GetMaximum(*i), *i);
58 ASSERT_EQ(lsFilter.GetMean(*i), *i);
59 ASSERT_EQ(lsFilter.GetMedian(*i), *i);
60 // By using the same image, the label variance values should equal to Zero.
61 ASSERT_EQ(lsFilter.GetSigma(*i), 0.0);
62 ASSERT_EQ(lsFilter.GetVariance(*i), 0.0);
63 }
64
65 ASSERT_EQ(lsFilter.GetSum(0), 0);
66 ASSERT_EQ(lsFilter.GetCount(0), 33390u);
67}
68
69
70TEST(LabelStatistics, Commands)

Callers

nothing calls this directly

Calls 15

HashFunction · 0.85
v2Function · 0.85
v4Function · 0.85
v9Function · 0.85
whatMethod · 0.80
AddCommandMethod · 0.80
DebugOnMethod · 0.80
GetProgressMethod · 0.80
GetNumberOfPixelsMethod · 0.80
GetPixelAsUInt8Method · 0.80
ReadImageFunction · 0.50
GetFileMethod · 0.45

Tested by

no test coverage detected