[ITK] BinaryMorphologicalOpening Filter compile error
Kurt Sansom
kayarre at gmail.com
Fri Feb 19 14:06:00 EST 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160219/6f3534c8/attachment-0001.html>
More information about the Community
mailing list