Skip to content
Snippets Groups Projects
Commit e5b77e3c authored by Julien Malik's avatar Julien Malik
Browse files

BUG: InPlaceLabelMapFilter is incompatible with multiple types output

parent 229b14ef
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ PURPOSE. See the above copyright notices for more information.
#ifndef __otbMinMaxAttributesLabelMapFilter_h
#define __otbMinMaxAttributesLabelMapFilter_h
#include "itkInPlaceLabelMapFilter.h"
#include "itkLabelMapFilter.h"
#include "itkSimpleDataObjectDecorator.h"
namespace otb {
......@@ -28,27 +28,30 @@ namespace otb {
*/
template<class TInputImage>
class ITK_EXPORT MinMaxAttributesLabelMapFilter :
public itk::InPlaceLabelMapFilter<TInputImage>
public itk::LabelMapFilter<TInputImage,TInputImage>
{
public:
/** Standard class typedefs. */
typedef MinMaxAttributesLabelMapFilter Self;
typedef itk::InPlaceLabelMapFilter<TInputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef MinMaxAttributesLabelMapFilter Self;
typedef itk::LabelMapFilter<TInputImage,TInputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef TInputImage InputImageType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::LabelObjectType LabelObjectType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::LabelObjectType LabelObjectType;
typedef typename LabelObjectType::AttributesValueType AttributesValueType;
typedef typename LabelObjectType::AttributesMapType AttributesMapType;
typedef itk::SimpleDataObjectDecorator<AttributesMapType> AttributesMapObjectType;
typedef itk::DataObject DataObjectType;
typedef DataObjectType::Pointer DataObjectPointerType;
/** ImageDimension constants */
itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension);
......@@ -77,6 +80,7 @@ public:
AttributesMapObjectType* GetMaximumOutput();
const AttributesMapObjectType* GetMaximumOutput() const;
virtual DataObjectPointerType MakeOutput(unsigned int idx);
protected:
MinMaxAttributesLabelMapFilter();
......
......@@ -27,13 +27,31 @@ template <class TInputImage>
MinMaxAttributesLabelMapFilter<TInputImage>
::MinMaxAttributesLabelMapFilter()
{
typename AttributesMapObjectType::Pointer min = AttributesMapObjectType::New();
typename AttributesMapObjectType::Pointer max = AttributesMapObjectType::New();
this->Superclass::SetNumberOfRequiredOutputs(3);
this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer());
this->itk::ProcessObject::SetNthOutput(2, this->MakeOutput(2).GetPointer());
}
this->itk::ProcessObject::SetNthOutput(1, min.GetPointer());
this->itk::ProcessObject::SetNthOutput(2, max.GetPointer());
template<class TInputImage>
typename MinMaxAttributesLabelMapFilter<TInputImage>::DataObjectPointerType
MinMaxAttributesLabelMapFilter<TInputImage>
::MakeOutput(unsigned int i)
{
DataObjectPointerType ret;
switch (i)
{
case 0:
ret = InputImageType::New();
break;
case 1:
case 2:
ret = AttributesMapObjectType::New();
break;
}
return ret;
}
template<class TInputImage>
typename MinMaxAttributesLabelMapFilter<TInputImage>::AttributesMapObjectType*
MinMaxAttributesLabelMapFilter<TInputImage>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment