Skip to content
Snippets Groups Projects
Commit 54e12240 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Fixing mean-shift segmentation composite filter

parent d0306028
Branches
Tags
No related merge requests found
...@@ -70,14 +70,6 @@ public: ...@@ -70,14 +70,6 @@ public:
OutputLabelImageType, OutputClusteredImageType> RegionMergingFilterType; OutputLabelImageType, OutputClusteredImageType> RegionMergingFilterType;
typedef typename RegionMergingFilterType::Pointer RegionMergingFilterPointerType; typedef typename RegionMergingFilterType::Pointer RegionMergingFilterPointerType;
/** Set/Get mean shift filter */
itkSetObjectMacro(MeanShiftFilter, MeanShiftFilterType);
itkGetObjectMacro(MeanShiftFilter, MeanShiftFilterType);
/** Set/Get region merging filter */
itkSetObjectMacro(RegionMergingFilter, RegionMergingFilterType);
itkGetObjectMacro(RegionMergingFilter, RegionMergingFilterType);
/** Sets the spatial bandwidth (or radius in the case of a uniform kernel) /** Sets the spatial bandwidth (or radius in the case of a uniform kernel)
* of the neighborhood for each pixel * of the neighborhood for each pixel
*/ */
...@@ -118,8 +110,6 @@ protected: ...@@ -118,8 +110,6 @@ protected:
virtual ~MeanShiftSegmentationFilter(); virtual ~MeanShiftSegmentationFilter();
void GenerateInputRequestedRegion();
// virtual void GenerateOutputInformation(void); // virtual void GenerateOutputInformation(void);
virtual void GenerateData(); virtual void GenerateData();
......
...@@ -30,32 +30,21 @@ MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImag ...@@ -30,32 +30,21 @@ MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImag
m_RegionMergingFilter = RegionMergingFilterType::New(); m_RegionMergingFilter = RegionMergingFilterType::New();
this->SetNumberOfOutputs(2); this->SetNumberOfOutputs(2);
this->SetNthOutput(0,TOutputLabelImage::New());
this->SetNthOutput(0, m_RegionMergingFilter->GetLabelOutput()); this->SetNthOutput(1,TOutputClusteredImage::New());
this->SetNthOutput(1, m_RegionMergingFilter->GetClusteredOutput());
} }
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::~MeanShiftSegmentationFilter() ::~MeanShiftSegmentationFilter()
{ {}
}
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
void
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GenerateInputRequestedRegion()
{
Superclass::GenerateInputRequestedRegion();
}
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
TOutputLabelImage * TOutputLabelImage *
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GetLabelOutput() ::GetLabelOutput()
{ {
return static_cast<OutputLabelImageType *>(this->m_RegionMergingFilter->GetLabelOutput()); return static_cast<OutputLabelImageType *>(this->itk::ProcessObject::GetOutput(0));
} }
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
...@@ -63,7 +52,7 @@ const TOutputLabelImage * ...@@ -63,7 +52,7 @@ const TOutputLabelImage *
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GetLabelOutput() const ::GetLabelOutput() const
{ {
return static_cast<OutputLabelImageType *>(this->m_RegionMergingFilter->GetLabelOutput()); return static_cast<OutputLabelImageType *>(this->itk::ProcessObject::GetOutput(0));
} }
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
...@@ -71,7 +60,7 @@ typename MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClus ...@@ -71,7 +60,7 @@ typename MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClus
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GetClusteredOutput() ::GetClusteredOutput()
{ {
return static_cast<OutputClusteredImageType *>(this->m_RegionMergingFilter->GetClusteredOutput()); return static_cast<OutputClusteredImageType *>(this->itk::ProcessObject::GetOutput(1));
} }
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
...@@ -79,41 +68,22 @@ const typename MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutp ...@@ -79,41 +68,22 @@ const typename MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutp
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GetClusteredOutput() const ::GetClusteredOutput() const
{ {
return static_cast<OutputClusteredImageType *>(this->m_RegionMergingFilter->GetClusteredOutput()); return static_cast<OutputClusteredImageType *>(this->itk::ProcessObject::GetOutput(1));
} }
// template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
// void
// MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
// ::GenerateOutputInformation()
// {
// Superclass::GenerateOutputInformation();
// unsigned int numberOfComponentsPerPixel = this->GetInput()->GetNumberOfComponentsPerPixel();
// if(this->GetClusteredOutput())
// {
// this->GetClusteredOutput()->SetNumberOfComponentsPerPixel(numberOfComponentsPerPixel);
// }
// }
template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel> template <class TInputImage, class TOutputLabelImage, class TOutputClusteredImage, class TKernel>
void void
MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel> MeanShiftSegmentationFilter<TInputImage, TOutputLabelImage, TOutputClusteredImage, TKernel>
::GenerateData() ::GenerateData()
{ {
this->m_MeanShiftFilter->SetInput(this->GetInput()); this->m_MeanShiftFilter->SetInput(this->GetInput());
this->m_MeanShiftFilter->Update();
this->m_RegionMergingFilter->SetInputLabelImage(this->m_MeanShiftFilter->GetLabelOutput()); this->m_RegionMergingFilter->SetInputLabelImage(this->m_MeanShiftFilter->GetLabelOutput());
this->m_RegionMergingFilter->SetInputSpectralImage(this->m_MeanShiftFilter->GetRangeOutput()); this->m_RegionMergingFilter->SetInputSpectralImage(this->m_MeanShiftFilter->GetRangeOutput());
this->m_RegionMergingFilter->SetRangeBandwidth(this->GetRangeBandwidth()); this->m_RegionMergingFilter->SetRangeBandwidth(this->GetRangeBandwidth());
m_RegionMergingFilter->GraftNthOutput(0,this->GetLabelOutput());
m_RegionMergingFilter->GraftNthOutput(1,this->GetClusteredOutput());
this->m_RegionMergingFilter->Update(); this->m_RegionMergingFilter->Update();
this->GraftNthOutput(0, m_RegionMergingFilter->GetLabelOutput()); this->GraftNthOutput(0, m_RegionMergingFilter->GetLabelOutput());
this->GraftNthOutput(1, m_RegionMergingFilter->GetClusteredOutput()); this->GraftNthOutput(1, m_RegionMergingFilter->GetClusteredOutput());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment