| 23 | #include <memory> |
| 24 | |
| 25 | TEST(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 | |
| 70 | TEST(LabelStatistics, Commands) |
nothing calls this directly
no test coverage detected