Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ class ITK_TEMPLATE_EXPORT ConfidenceConnectedImageFilter : public ImageToImageFi
* executed using the Update() method. */
itkGetConstReferenceMacro(Variance, InputRealType);

/** Method to access seed container. */
virtual const SeedsContainerType &
GetSeeds() const;
/** Set/Get the seed container. */
/** @ITKStartGrouping */
itkSetMacro(Seeds, SeedsContainerType);
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
/** @ITKEndGrouping */

itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputImagePixelType>));
itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputImagePixelType>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::AddSeed(const IndexTy
this->Modified();
}

template <typename TInputImage, typename TOutputImage>
auto
ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedsContainerType &
{
itkDebugMacro("returning Seeds");
return this->m_Seeds;
}

template <typename TInputImage, typename TOutputImage>
void
ConfidenceConnectedImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ITK_TEMPLATE_EXPORT ConnectedThresholdImageFilter : public ImageToImageFil
using InputImagePixelType = typename InputImageType::PixelType;
using IndexType = typename InputImageType::IndexType;
using SeedContainerType = std::vector<IndexType>;
using SeedsContainerType = SeedContainerType;
using SizeType = typename InputImageType::SizeType;

using OutputImageType = TOutputImage;
Expand All @@ -110,9 +111,11 @@ class ITK_TEMPLATE_EXPORT ConnectedThresholdImageFilter : public ImageToImageFil
void
ClearSeeds();

/** Method to access seed container. */
virtual const SeedContainerType &
GetSeeds() const;
/** Set/Get the seed container. */
/** @ITKStartGrouping */
itkSetMacro(Seeds, SeedsContainerType);
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
/** @ITKEndGrouping */

/** Set/Get value to replace thresholded pixels. Pixels that lie *
* within Lower and Upper (inclusive) will be replaced with this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ ConnectedThresholdImageFilter<TInputImage, TOutputImage>::ClearSeeds()
}
}

template <typename TInputImage, typename TOutputImage>
auto
ConnectedThresholdImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedContainerType &
{
return this->m_Seeds;
}

template <typename TInputImage, typename TOutputImage>
void
ConnectedThresholdImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ class ITK_TEMPLATE_EXPORT IsolatedConnectedImageFilter : public ImageToImageFilt

/** Method to access seed container */
/** @ITKStartGrouping */
virtual const SeedsContainerType &
GetSeeds1() const;
virtual const SeedsContainerType &
GetSeeds2() const;
itkSetMacro(Seeds1, SeedsContainerType);
Comment thread
hjmjohnson marked this conversation as resolved.
itkGetConstReferenceMacro(Seeds1, SeedsContainerType);
itkSetMacro(Seeds2, SeedsContainerType);
itkGetConstReferenceMacro(Seeds2, SeedsContainerType);
/** @ITKEndGrouping */
/** Set/Get the limit on the lower threshold value. The default is
* the NonpositiveMin() for the InputPixelType. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,6 @@ IsolatedConnectedImageFilter<TInputImage, TOutputImage>::ClearSeeds2()
}
}

template <typename TInputImage, typename TOutputImage>
auto
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds1() const -> const SeedsContainerType &
{
itkDebugMacro("returning Seeds1");
return this->m_Seeds1;
}

template <typename TInputImage, typename TOutputImage>
auto
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds2() const -> const SeedsContainerType &
{
itkDebugMacro("returning Seeds2");
return this->m_Seeds2;
}

template <typename TInputImage, typename TOutputImage>
void
IsolatedConnectedImageFilter<TInputImage, TOutputImage>::GenerateData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
using IndexType = typename InputImageType::IndexType;
using InputImageSizeType = typename InputImageType::SizeType;

using SeedsContainerType = std::vector<IndexType>;

using OutputImageType = TOutputImage;
using OutputImagePointer = typename OutputImageType::Pointer;
using OutputImageRegionType = typename OutputImageType::RegionType;
Expand All @@ -78,6 +80,12 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
void
AddSeed(const IndexType & seed);

/** Set/Get the seed container. */
/** @ITKStartGrouping */
itkSetMacro(Seeds, SeedsContainerType);
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
/** @ITKEndGrouping */

/** Set/Get the lower threshold. The default is 0. */
/** @ITKStartGrouping */
itkSetMacro(Lower, InputImagePixelType);
Expand Down Expand Up @@ -115,7 +123,7 @@ class ITK_TEMPLATE_EXPORT NeighborhoodConnectedImageFilter : public ImageToImage
protected:
NeighborhoodConnectedImageFilter();
~NeighborhoodConnectedImageFilter() override = default;
std::vector<IndexType> m_Seeds{};
SeedsContainerType m_Seeds{};

InputImagePixelType m_Lower{};
InputImagePixelType m_Upper{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ class ITK_TEMPLATE_EXPORT VectorConfidenceConnectedImageFilter : public ImageToI
const CovarianceMatrixType &
GetCovariance() const;

/** Method to access seed container */
virtual const SeedsContainerType &
GetSeeds() const;
/** Set/Get the seed container. */
/** @ITKStartGrouping */
itkSetMacro(Seeds, SeedsContainerType);
itkGetConstReferenceMacro(Seeds, SeedsContainerType);
/** @ITKEndGrouping */

itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputImagePixelType>));
itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<typename InputImagePixelType::ValueType>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,6 @@ VectorConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetMean() const
return m_ThresholdFunction->GetMean();
}

template <typename TInputImage, typename TOutputImage>
auto
VectorConfidenceConnectedImageFilter<TInputImage, TOutputImage>::GetSeeds() const -> const SeedsContainerType &
{
itkDebugMacro("returning Seeds");
return this->m_Seeds;
}

} // end namespace itk

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ itkConfidenceConnectedImageFilterTest(int argc, char * argv[])
// Exercise AddSeed() method
filter->AddSeed(seed);

// Exercise SetSeeds/GetSeeds container interface
const FilterType::SeedsContainerType seeds = filter->GetSeeds();
filter->ClearSeeds();
if (!filter->GetSeeds().empty())
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container not empty after ClearSeeds." << std::endl;
return EXIT_FAILURE;
}
filter->SetSeeds(seeds);
if (filter->GetSeeds() != seeds)
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container from GetSeeds does not match SetSeeds input." << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ itkConnectedThresholdImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

// Exercise SetSeeds/GetSeeds container interface using SeedsContainerType alias
connectedThresholdFilter->AddSeed(seed);
const ConnectedThresholdImageFilterType::SeedsContainerType seeds = connectedThresholdFilter->GetSeeds();
connectedThresholdFilter->ClearSeeds();
connectedThresholdFilter->SetSeeds(seeds);
if (connectedThresholdFilter->GetSeeds() != seeds)
{
std::cerr << "Test FAILED !" << std::endl;
std::cerr << "Seed container from GetSeeds does not match SetSeeds input." << std::endl;
return EXIT_FAILURE;
}

connectedThresholdFilter->SetSeed(seed);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ itkIsolatedConnectedImageFilterTest(int argc, char * argv[])
filter->AddSeed2(seed1);
}

// Exercise the seed-container accessors. Round-trip the populated
// containers through SetSeeds/GetSeeds, leaving the filter unchanged.
const FilterType::SeedsContainerType seeds1 = filter->GetSeeds1();
const FilterType::SeedsContainerType seeds2 = filter->GetSeeds2();

filter->ClearSeeds1();
filter->ClearSeeds2();
if (!filter->GetSeeds1().empty() || !filter->GetSeeds2().empty())
{
std::cerr << "Test failed!" << std::endl;
std::cerr << "Seed containers were not cleared by ClearSeeds." << std::endl;
return EXIT_FAILURE;
}

filter->SetSeeds1(seeds1);
filter->SetSeeds2(seeds2);
if (filter->GetSeeds1() != seeds1 || filter->GetSeeds2() != seeds2)
{
std::cerr << "Test failed!" << std::endl;
std::cerr << "Seed containers retrieved by GetSeeds do not match those set by SetSeeds." << std::endl;
return EXIT_FAILURE;
}

// The min and max values for a .png image
constexpr FilterType::InputImagePixelType lower{ 0 };
filter->SetLower(lower);
Comment thread
hjmjohnson marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,22 @@ itkNeighborhoodConnectedImageFilterTest(int argc, char * argv[])
writer->SetFileName(argv[2]);
writer->Update();

// Exercise SetSeeds/GetSeeds container interface
const FilterType::SeedsContainerType seeds = filter->GetSeeds();
filter->ClearSeeds();
if (!filter->GetSeeds().empty())
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container not empty after ClearSeeds." << std::endl;
return EXIT_FAILURE;
}
filter->SetSeeds(seeds);
if (filter->GetSeeds() != seeds)
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container from GetSeeds does not match SetSeeds input." << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ itkVectorConfidenceConnectedImageFilterTest(int argc, char * argv[])
writer->SetFileName(argv[2]);
writer->Update();

// Exercise SetSeeds/GetSeeds container interface
const FilterType::SeedsContainerType seeds = filter->GetSeeds();
filter->ClearSeeds();
if (!filter->GetSeeds().empty())
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container not empty after ClearSeeds." << std::endl;
return EXIT_FAILURE;
}
filter->SetSeeds(seeds);
if (filter->GetSeeds() != seeds)
{
std::cerr << "Test FAILED!" << std::endl;
std::cerr << "Seed container from GetSeeds does not match SetSeeds input." << std::endl;
return EXIT_FAILURE;
}

// Exercise SetSeed() method
filter->SetSeed(seed1);

Expand Down
Loading