Skip to content

Commit 59f6b28

Browse files
authored
Merge pull request #4793 from blowekamp/IsolatedConnected_set_seed_container
ENH: Set Seeds as conntainer objects
2 parents 7c368a6 + fdb2c6b commit 59f6b28

14 files changed

Lines changed: 114 additions & 53 deletions

Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ class ITK_TEMPLATE_EXPORT ConfidenceConnectedImageFilter : public ImageToImageFi
141141
* executed using the Update() method. */
142142
itkGetConstReferenceMacro(Variance, InputRealType);
143143

144-
/** Method to access seed container. */
145-
virtual const SeedsContainerType &
146-
GetSeeds() const;
144+
/** Set/Get the seed container. */
145+
/** @ITKStartGrouping */
146+
itkSetMacro(Seeds, SeedsContainerType);
147+
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
148+
/** @ITKEndGrouping */
147149

148150
itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputImagePixelType>));
149151
itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputImagePixelType>));

Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.hxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::AddSeed(const IndexTy
6969
this->Modified();
7070
}
7171

72-
template <typename TInputImage, typename TOutputImage>
73-
auto
74-
ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedsContainerType &
75-
{
76-
itkDebugMacro("returning Seeds");
77-
return this->m_Seeds;
78-
}
79-
8072
template <typename TInputImage, typename TOutputImage>
8173
void
8274
ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const

Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class ITK_TEMPLATE_EXPORT ConnectedThresholdImageFilter : public ImageToImageFil
8989
using InputImagePixelType = typename InputImageType::PixelType;
9090
using IndexType = typename InputImageType::IndexType;
9191
using SeedContainerType = std::vector<IndexType>;
92+
using SeedsContainerType = SeedContainerType;
9293
using SizeType = typename InputImageType::SizeType;
9394

9495
using OutputImageType = TOutputImage;
@@ -110,9 +111,11 @@ class ITK_TEMPLATE_EXPORT ConnectedThresholdImageFilter : public ImageToImageFil
110111
void
111112
ClearSeeds();
112113

113-
/** Method to access seed container. */
114-
virtual const SeedContainerType &
115-
GetSeeds() const;
114+
/** Set/Get the seed container. */
115+
/** @ITKStartGrouping */
116+
itkSetMacro(Seeds, SeedsContainerType);
117+
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
118+
/** @ITKEndGrouping */
116119

117120
/** Set/Get value to replace thresholded pixels. Pixels that lie *
118121
* within Lower and Upper (inclusive) will be replaced with this

Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ ConnectedThresholdImageFilter<TInputImage, TOutputImage>::ClearSeeds()
6969
}
7070
}
7171

72-
template <typename TInputImage, typename TOutputImage>
73-
auto
74-
ConnectedThresholdImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedContainerType &
75-
{
76-
return this->m_Seeds;
77-
}
78-
7972
template <typename TInputImage, typename TOutputImage>
8073
void
8174
ConnectedThresholdImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()

Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ class ITK_TEMPLATE_EXPORT IsolatedConnectedImageFilter : public ImageToImageFilt
144144

145145
/** Method to access seed container */
146146
/** @ITKStartGrouping */
147-
virtual const SeedsContainerType &
148-
GetSeeds1() const;
149-
virtual const SeedsContainerType &
150-
GetSeeds2() const;
147+
itkSetMacro(Seeds1, SeedsContainerType);
148+
itkGetConstReferenceMacro(Seeds1, SeedsContainerType);
149+
itkSetMacro(Seeds2, SeedsContainerType);
150+
itkGetConstReferenceMacro(Seeds2, SeedsContainerType);
151151
/** @ITKEndGrouping */
152152
/** Set/Get the limit on the lower threshold value. The default is
153153
* the NonpositiveMin() for the InputPixelType. */

Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.hxx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,6 @@ IsolatedConnectedImageFilter<TInputImage, TOutputImage>::ClearSeeds2()
137137
}
138138
}
139139

140-
template <typename TInputImage, typename TOutputImage>
141-
auto
142-
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds1() const -> const SeedsContainerType &
143-
{
144-
itkDebugMacro("returning Seeds1");
145-
return this->m_Seeds1;
146-
}
147-
148-
template <typename TInputImage, typename TOutputImage>
149-
auto
150-
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds2() const -> const SeedsContainerType &
151-
{
152-
itkDebugMacro("returning Seeds2");
153-
return this->m_Seeds2;
154-
}
155-
156140
template <typename TInputImage, typename TOutputImage>
157141
void
158142
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GenerateData()

Modules/Segmentation/RegionGrowing/include/itkNeighborhoodConnectedImageFilter.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
5858
using IndexType = typename InputImageType::IndexType;
5959
using InputImageSizeType = typename InputImageType::SizeType;
6060

61+
using SeedsContainerType = std::vector<IndexType>;
62+
6163
using OutputImageType = TOutputImage;
6264
using OutputImagePointer = typename OutputImageType::Pointer;
6365
using OutputImageRegionType = typename OutputImageType::RegionType;
@@ -78,6 +80,12 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
7880
void
7981
AddSeed(const IndexType & seed);
8082

83+
/** Set/Get the seed container. */
84+
/** @ITKStartGrouping */
85+
itkSetMacro(Seeds, SeedsContainerType);
86+
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
87+
/** @ITKEndGrouping */
88+
8189
/** Set/Get the lower threshold. The default is 0. */
8290
/** @ITKStartGrouping */
8391
itkSetMacro(Lower, InputImagePixelType);
@@ -115,7 +123,7 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
115123
protected:
116124
NeighborhoodConnectedImageFilter();
117125
~NeighborhoodConnectedImageFilter() override = default;
118-
std::vector<IndexType> m_Seeds{};
126+
SeedsContainerType m_Seeds{};
119127

120128
InputImagePixelType m_Lower{};
121129
InputImagePixelType m_Upper{};

Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ class ITK_TEMPLATE_EXPORT VectorConfidenceConnectedImageFilter : public ImageToI
140140
const CovarianceMatrixType &
141141
GetCovariance() const;
142142

143-
/** Method to access seed container */
144-
virtual const SeedsContainerType &
145-
GetSeeds() const;
143+
/** Set/Get the seed container. */
144+
/** @ITKStartGrouping */
145+
itkSetMacro(Seeds, SeedsContainerType);
146+
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
147+
/** @ITKEndGrouping */
146148

147149
itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputImagePixelType>));
148150
itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<typename InputImagePixelType::ValueType>));

Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.hxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,6 @@ VectorConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetMean() const
352352
return m_ThresholdFunction->GetMean();
353353
}
354354

355-
template <typename TInputImage, typename TOutputImage>
356-
auto
357-
VectorConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedsContainerType &
358-
{
359-
itkDebugMacro("returning Seeds");
360-
return this->m_Seeds;
361-
}
362-
363355
} // end namespace itk
364356

365357
#endif

Modules/Segmentation/RegionGrowing/test/itkConfidenceConnectedImageFilterTest.cxx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ itkConfidenceConnectedImageFilterTest(int argc, char * argv[])
102102
// Exercise AddSeed() method
103103
filter->AddSeed(seed);
104104

105+
// Exercise SetSeeds/GetSeeds container interface
106+
const FilterType::SeedsContainerType seeds = filter->GetSeeds();
107+
filter->ClearSeeds();
108+
if (!filter->GetSeeds().empty())
109+
{
110+
std::cerr << "Test FAILED!" << std::endl;
111+
std::cerr << "Seed container not empty after ClearSeeds." << std::endl;
112+
return EXIT_FAILURE;
113+
}
114+
filter->SetSeeds(seeds);
115+
if (filter->GetSeeds() != seeds)
116+
{
117+
std::cerr << "Test FAILED!" << std::endl;
118+
std::cerr << "Seed container from GetSeeds does not match SetSeeds input." << std::endl;
119+
return EXIT_FAILURE;
120+
}
105121

106122
return EXIT_SUCCESS;
107123
}

0 commit comments

Comments
 (0)