BinaryMorphologycalOpeningImageFilter, does not name a template type?

Hi everyone,

I run my code about the Morphology algorithm. And I get an error:
/home/ITK_Codes/itkMaskToMesh.hxx:238:18: error:

‘BinaryMorphologycalOpeningImageFilter’ in namespace ‘itk’ does not name a template type
     typedef itk::BinaryMorphologycalOpeningImageFilter< ImageType, ImageType,
/home/ITK_Codes/MaskToMesh_new/itkMaskToMesh.hxx:246:14: error: ‘BinaryMorphologicalOpeningImageFilterType’ has not been declared
     typename BinaryMorphologicalOpeningImageFilterType::Pointer binaryOpen = BinaryMorphologicalOpeningImageFilterType::New();
/home/ITK_Codes/MaskToMesh_new/itkMaskToMesh.hxx:246:65: error: expected ‘(’ before ‘binaryOpen’
 typename BinaryMorphologicalOpeningImageFilterType::Pointer binaryOpen = BinaryMorphologicalOpeningImageFilterType::New();
 /home/ITK_Codes/MaskToMesh_new/itkMaskToMesh.hxx:247:5: error: ‘binaryOpen’ was not declared in this scope
     binaryOpen->SetKernel( structuringElement );

This is my code:

 if(m_isOpen)
  {
//  float m_closeSize=1;
    std::cerr <<"Opening the Mask Image with structure size: "
              <<m_openSize<<std::endl;
//
//  typedef itk::BinaryBallStructuringElement< PixelType, Dimension >
//                 StructuringElementType;
    typedef itk::FlatStructuringElement< Dimension > StructuringElementType;
    typedef itk::BinaryMorphologycalOpeningImageFilter< ImageType, ImageType,
                   StructuringElementType> BinaryMorphologicalOpeningImageFilterType;

    StructuringElementType structuringElement;
    typename StructuringElementType::RadiusType elementRadius;
    elementRadius.Fill( m_openSize );
    structuringElement = StructuringElementType::Ball(elementRadius,true);

    typename BinaryMorphologicalOpeningImageFilterType::Pointer binaryOpen = BinaryMorphologicalOpeningImageFilterType::New();
    binaryOpen->SetKernel( structuringElement );
    binaryOpen->SetInput( inputImage );
    binaryOpen->SetForegroundValue( m_objectValue );

// study try and catch concepts
    try
    {
      binaryOpen->Update();
    }
    catch( itk::ExceptionObject & excp )
    {
      std::cerr <<"\tWARNING: Exception thrown in opening the mask image"
                << excp << std::endl;
    }

      inputImage=binaryOpen->GetOutput();
  }

How i can fix that error?
Thank you so much!

Maybe you forgot to #include "itkBinaryMorphologycalOpeningImageFilter.h"?

2 Likes