[ITK] BinaryMorphologicalOpening Filter compile error

Dženan Zukić dzenanz at gmail.com
Sun Feb 21 13:41:16 EST 2016


There were 3 fairly obvious mistakes. Attached are a diff file and a
compilable source code.

HTH,
Dženan

On Fri, Feb 19, 2016 at 2:06 PM, Kurt Sansom <kayarre at gmail.com> wrote:

> This is one of my first attempts at using the ITK library, using some code
> from someone elses masters thesis.
>
> I am getting the following type errors and and the subsequent code that I
> am compiling on a mac:
>
> Thanks so much.
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:126:20:
> **error: **type 'InputImageType' (aka 'unsigned char') cannot be*
>
> *      used prior to '::' because it has no members*
>
>   typedef typename InputImageType::Pointer      InputImagePointer;
>
> *                   ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.h:41:10:
> note: *in instantiation of template class
>
>       'itk::ImageToImageFilter<unsigned char, itk::Image<unsigned char, 3>
> >' requested here
>
>   public ImageToImageFilter< TInputImage, TOutputImage >
>
> *         ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:41:10:
> note: *in instantiation of template class
>
>       'itk::BoxImageFilter<unsigned char, itk::Image<unsigned char, 3> >'
> requested here
>
>   public BoxImageFilter< TInputImage, TOutputImage >
>
> *         ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologicalOpeningImageFilter.h:56:10:
> note: *in
>
>       instantiation of template class 'itk::KernelImageFilter<unsigned
> char, itk::Image<unsigned char, 3>,
> itk::BinaryBallStructuringElement<unsigned char, 3,
>
>       itk::NeighborhoodAllocator<unsigned char> > >' requested here
>
>   public KernelImageFilter< TInputImage, TOutputImage, TKernel >
>
> *         ^*
>
> */Users/sansomk/code/cpp/us_seg/morph.cxx:63:3: note: *in instantiation
> of template class 'itk::BinaryMorphologicalOpeningImageFilter<unsigned char,
>
>       itk::Image<unsigned char, 3>,
> itk::BinaryBallStructuringElement<unsigned char, 3,
> itk::NeighborhoodAllocator<unsigned char> > >' requested here
>
>   FilterType::Pointer filter = FilterType::New();
>
> *  ^*
>
> In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:12:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h:21:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkUnaryFunctorImageFilter.h:22:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkInPlaceImageFilter.h:31:
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:127:20:
> **error: **type 'InputImageType' (aka 'unsigned char') cannot be*
>
> *      used prior to '::' because it has no members*
>
>   typedef typename InputImageType::ConstPointer InputImageConstPointer;
>
> *                   ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:128:20:
> **error: **type 'InputImageType' (aka 'unsigned char') cannot be*
>
> *      used prior to '::' because it has no members*
>
>   typedef typename InputImageType::RegionType   InputImageRegionType;
>
> *                   ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:129:20:
> **error: **type 'InputImageType' (aka 'unsigned char') cannot be*
>
> *      used prior to '::' because it has no members*
>
>   typedef typename InputImageType::PixelType    InputImagePixelType;
>
> *                   ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:133:23:
> **error: **type 'unsigned char' cannot be used prior to '::'*
>
> *      because it has no members*
>
>                       TInputImage::ImageDimension);
>
> *                      ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkMacro.h:763:73:
> note: *expanded from macro 'itkStaticConstMacro'
>
> #  define itkStaticConstMacro(name,type,value) static const type name =
> value
>
> *                                                                        ^*
>
> In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:13:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkBinaryBallStructuringElement.h:124:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkBinaryBallStructuringElement.hxx:22:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.h:246:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx:40:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanDilateImageFilter.h:21:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanErodeDilateImageFilter.h:21:
>
> In file included from
> /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:21:
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.h:59:20:
> **error: **type 'unsigned char' cannot be used prior to*
>
> *      '::' because it has no members*
>
>   typedef typename TInputImage::RegionType RegionType;
>
> *                   ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:41:10:
> note: *in instantiation of template class
>
>       'itk::BoxImageFilter<unsigned char, itk::Image<unsigned char, 3> >'
> requested here
>
>   public BoxImageFilter< TInputImage, TOutputImage >
>
> *         ^*
>
> */Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologicalOpeningImageFilter.h:56:10:
> note: *in
>
>       instantiation of template class 'itk::KernelImageFilter<unsigned
> char, itk::Image<unsigned char, 3>,
> itk::BinaryBallStructuringElement<unsigned char, 3,
>
>       itk::NeighborhoodAllocator<unsigned char> > >' requested here
>
>   public KernelImageFilter< TInputImage, TOutputImage, TKernel >
>
> *         ^*
>
> */Users/sansomk/code/cpp/us_seg/morph.cxx:63:3: note: *in instantiation
> of template class 'itk::BinaryMorphologicalOpeningImageFilter<unsigned char,
>
>       itk::Image<unsigned char, 3>,
> itk::BinaryBallStructuringElement<unsigned char, 3,
> itk::NeighborhoodAllocator<unsigned char> > >' requested here
>
>   FilterType::Pointer filter = FilterType::New();
>
> *  ^*
>
> In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:13:
>
> here is the code:
>
> #if defined(MSCVER)
>
>   #pragma warning ( disable : 4786 )
>
> #endif
>
>
> #ifdef _BORLANDC_
>
>   #define ITK_LEAN_AND_MEAN
>
> #endif
>
>
> #include "itkImage.h"
>
> #include "itkImageFileReader.h"
>
> #include "itkImageFileWriter.h"
>
> #include "itkRescaleIntensityImageFilter.h"
>
> #include "itkBinaryBallStructuringElement.h"
>
> #include "itkBinaryMorphologicalClosingImageFilter.h"
>
> #include "itkBinaryMorphologicalOpeningImageFilter.h"
>
>
> int main(int argc, char * argv[] ) {
>
>
>   if( argc < 5 ) {
>
>     std::cerr << "Usage: " <<  std::endl;
>
>     std::cerr << argv [0] << " inputImageFile outputImageFile radiusX(int)"
>
>       << " radiusY(int) radiusZ(int) " << std::endl;
>
>     return EXIT_FAILURE;
>
>   }
>
>
>
>
>
>   const unsigned int Dimension = 3;
>
>
>
>   typedef unsigned char InputPixelType;
>
>   typedef unsigned char OutputPixelType;
>
>
>
>   typedef itk::Image< InputPixelType, Dimension > InputImageType;
>
>   typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>
>
>
>   typedef itk::ImageFileReader< InputImageType> ReaderType;
>
>   typedef itk::ImageFileWriter< OutputImageType> WriterType;
>
>
>
>   typedef itk::BinaryBallStructuringElement< InputPixelType, Dimension >
> KernelType;
>
>
>
>   typedef itk::BinaryMorphologicalOpeningImageFilter< InputPixelType,
>
>                                                       OutputImageType,
>
>                                                       KernelType >
> FilterType;
>
>   typedef itk::RescaleIntensityImageFilter<OutputImageType,
> OutputImageType> RescaleFilterType;
>
>
>
>
>
>   // Read Image
>
>   ReaderType::Pointer reader = ReaderType::New();
>
>   reader->SetFileName( argv[1] );
>
>   reader->Update();
>
>
>
>   //Create Kernel (structuring element)
>
>   KernelType::RadiusType radius;
>
>   radius[0] = atoi( argv[3] );
>
>   radius[1] = atoi( argv[4] );
>
>   radius[2] = atoi( argv[5] );
>
>
>
>
>
>   KernelType kernel;
>
>   kernel.SetRadius( Dimension );
>
>   kernel.CreateStructuringElement();
>
>
>
>   // Create morphological filter
>
>   FilterType::Pointer filter = FilterType::New();
>
>   filter->SetInput( reader );
>
>   filter->SetKernel( kernel );
>
>   filter->Update();
>
>
>
>   // Rescale for output
>
>   RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>
>   rescaler->SetOutputMinimum( 0 );
>
>   rescaler->SetOutputMaximum( 255 );
>
>   rescaler->SetInput( filter->GetOutput() );
>
>   //rescaler->Update();
>
>
>
>   // Write output
>
>   WriterType::Pointer writer = WriterType::New();
>
>   writer->SetFileName( argv[2] );
>
>   writer->SetInput( rescaler->GetOutput() );
>
>   writer->Update();
>
>
>
>   return EXIT_SUCCESS;
>
> }
>
>
>
>
> --
> Kurt Sansom
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160221/e3737be7/attachment-0001.html>
-------------- next part --------------
diff --git "a/C:\\Misc\\Tester\\Source1.cpp" "b/C:\\Misc\\Tester\\tester.cpp"
index b137d33..d690374 100644
--- "a/C:\\Misc\\Tester\\Source1.cpp"
+++ "b/C:\\Misc\\Tester\\tester.cpp"
@@ -37,7 +37,7 @@ int main(int argc, char * argv[]) {
 
     typedef itk::BinaryBallStructuringElement< InputPixelType, Dimension > KernelType;
 
-    typedef itk::BinaryMorphologicalOpeningImageFilter< InputPixelType,
+    typedef itk::BinaryMorphologicalOpeningImageFilter< InputImageType,
         OutputImageType,
         KernelType > FilterType;
     typedef itk::RescaleIntensityImageFilter<OutputImageType, OutputImageType> RescaleFilterType;
@@ -56,12 +56,12 @@ int main(int argc, char * argv[]) {
 
 
     KernelType kernel;
-    kernel.SetRadius(Dimension);
+    kernel.SetRadius(radius);
     kernel.CreateStructuringElement();
 
     // Create morphological filter
     FilterType::Pointer filter = FilterType::New();
-    filter->SetInput(reader);
+    filter->SetInput(reader->GetOutput());
     filter->SetKernel(kernel);
     filter->Update();
 
@@ -80,4 +80,4 @@ int main(int argc, char * argv[]) {
 
     return EXIT_SUCCESS;
 
-}
+}
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tester.cpp
Type: text/x-c++src
Size: 2481 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20160221/e3737be7/attachment-0001.cpp>


More information about the Community mailing list