<div dir="ltr">This is one of my first attempts at using the ITK library, using some code from someone elses masters thesis.<div><br></div><div>I am getting the following type errors and and the subsequent code that I am compiling on a mac:</div><div><br></div><div>Thanks so much.</div><div>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:126:20: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'InputImageType' (aka 'unsigned char') cannot be</b></span></p>
<p class=""><span class=""><b> used prior to '::' because it has no members</b></span></p>
<p class=""><span class=""> typedef typename InputImageType::Pointer InputImagePointer;</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.h:41:10: note: </b>in instantiation of template class</span></p>
<p class=""><span class=""> 'itk::ImageToImageFilter<unsigned char, itk::Image<unsigned char, 3> >' requested here</span></p>
<p class=""><span class=""> public ImageToImageFilter< TInputImage, TOutputImage ></span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:41:10: note: </b>in instantiation of template class</span></p>
<p class=""><span class=""> 'itk::BoxImageFilter<unsigned char, itk::Image<unsigned char, 3> >' requested here</span></p>
<p class=""><span class=""> public BoxImageFilter< TInputImage, TOutputImage ></span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologicalOpeningImageFilter.h:56:10: note: </b>in</span></p>
<p class=""><span class=""> instantiation of template class 'itk::KernelImageFilter<unsigned char, itk::Image<unsigned char, 3>, itk::BinaryBallStructuringElement<unsigned char, 3,</span></p>
<p class=""><span class=""> itk::NeighborhoodAllocator<unsigned char> > >' requested here</span></p>
<p class=""><span class=""> public KernelImageFilter< TInputImage, TOutputImage, TKernel ></span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/code/cpp/us_seg/morph.cxx:63:3: note: </b>in instantiation of template class 'itk::BinaryMorphologicalOpeningImageFilter<unsigned char,</span></p>
<p class=""><span class=""> itk::Image<unsigned char, 3>, itk::BinaryBallStructuringElement<unsigned char, 3, itk::NeighborhoodAllocator<unsigned char> > >' requested here</span></p>
<p class=""><span class=""> FilterType::Pointer filter = FilterType::New();</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class="">In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:12:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h:21:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkUnaryFunctorImageFilter.h:22:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkInPlaceImageFilter.h:31:</span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:127:20: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'InputImageType' (aka 'unsigned char') cannot be</b></span></p>
<p class=""><span class=""><b> used prior to '::' because it has no members</b></span></p>
<p class=""><span class=""> typedef typename InputImageType::ConstPointer InputImageConstPointer;</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:128:20: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'InputImageType' (aka 'unsigned char') cannot be</b></span></p>
<p class=""><span class=""><b> used prior to '::' because it has no members</b></span></p>
<p class=""><span class=""> typedef typename InputImageType::RegionType InputImageRegionType;</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:129:20: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'InputImageType' (aka 'unsigned char') cannot be</b></span></p>
<p class=""><span class=""><b> used prior to '::' because it has no members</b></span></p>
<p class=""><span class=""> typedef typename InputImageType::PixelType InputImagePixelType;</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkImageToImageFilter.h:133:23: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'unsigned char' cannot be used prior to '::'</b></span></p>
<p class=""><span class=""><b> because it has no members</b></span></p>
<p class=""><span class=""> TInputImage::ImageDimension);</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Core/Common/include/itkMacro.h:763:73: note: </b>expanded from macro 'itkStaticConstMacro'</span></p>
<p class=""><span class=""># define itkStaticConstMacro(name,type,value) static const type name = value</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class="">In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:13:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkBinaryBallStructuringElement.h:124:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkBinaryBallStructuringElement.hxx:22:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.h:246:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx:40:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanDilateImageFilter.h:21:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanErodeDilateImageFilter.h:21:</span></p>
<p class=""><span class="">In file included from /Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:21:</span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.h:59:20: </b></span><span class=""><b>error: </b></span><span class=""><b>type 'unsigned char' cannot be used prior to</b></span></p>
<p class=""><span class=""><b> '::' because it has no members</b></span></p>
<p class=""><span class=""> typedef typename TInputImage::RegionType RegionType;</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/ImageFilterBase/include/itkKernelImageFilter.h:41:10: note: </b>in instantiation of template class</span></p>
<p class=""><span class=""> 'itk::BoxImageFilter<unsigned char, itk::Image<unsigned char, 3> >' requested here</span></p>
<p class=""><span class=""> public BoxImageFilter< TInputImage, TOutputImage ></span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/build/ITK/ITKLatestRelease/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologicalOpeningImageFilter.h:56:10: note: </b>in</span></p>
<p class=""><span class=""> instantiation of template class 'itk::KernelImageFilter<unsigned char, itk::Image<unsigned char, 3>, itk::BinaryBallStructuringElement<unsigned char, 3,</span></p>
<p class=""><span class=""> itk::NeighborhoodAllocator<unsigned char> > >' requested here</span></p>
<p class=""><span class=""> public KernelImageFilter< TInputImage, TOutputImage, TKernel ></span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class=""><b>/Users/sansomk/code/cpp/us_seg/morph.cxx:63:3: note: </b>in instantiation of template class 'itk::BinaryMorphologicalOpeningImageFilter<unsigned char,</span></p>
<p class=""><span class=""> itk::Image<unsigned char, 3>, itk::BinaryBallStructuringElement<unsigned char, 3, itk::NeighborhoodAllocator<unsigned char> > >' requested here</span></p>
<p class=""><span class=""> FilterType::Pointer filter = FilterType::New();</span></p>
<p class=""><span class=""><b> ^</b></span></p>
<p class=""><span class="">In file included from /Users/sansomk/code/cpp/us_seg/morph.cxx:13:</span></p>
<p class="">here is the code:<br></p><p class="">#if defined(MSCVER)</p><p class=""> #pragma warning ( disable : 4786 )</p><p class="">#endif</p><p class=""><br></p><p class="">#ifdef _BORLANDC_</p><p class=""> #define ITK_LEAN_AND_MEAN</p><p class="">#endif</p><p class=""><br></p><p class="">#include "itkImage.h"</p><p class="">#include "itkImageFileReader.h"</p><p class="">#include "itkImageFileWriter.h"</p><p class="">#include "itkRescaleIntensityImageFilter.h"</p><p class="">#include "itkBinaryBallStructuringElement.h"</p><p class="">#include "itkBinaryMorphologicalClosingImageFilter.h"</p><p class="">#include "itkBinaryMorphologicalOpeningImageFilter.h"</p><p class=""><br></p><p class="">int main(int argc, char * argv[] ) {</p><p class=""><br></p><p class=""> if( argc < 5 ) {</p><p class=""> std::cerr << "Usage: " << std::endl;</p><p class=""> std::cerr << argv [0] << " inputImageFile outputImageFile radiusX(int)"</p><p class=""> << " radiusY(int) radiusZ(int) " << std::endl;</p><p class=""> return EXIT_FAILURE;</p><p class=""> }</p><p class=""> </p><p class=""> </p><p class=""> const unsigned int Dimension = 3;</p><p class=""> </p><p class=""> typedef unsigned char InputPixelType;</p><p class=""> typedef unsigned char OutputPixelType;</p><p class=""> </p><p class=""> typedef itk::Image< InputPixelType, Dimension > InputImageType;</p><p class=""> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;</p><p class=""> </p><p class=""> typedef itk::ImageFileReader< InputImageType> ReaderType;</p><p class=""> typedef itk::ImageFileWriter< OutputImageType> WriterType;</p><p class=""> </p><p class=""> typedef itk::BinaryBallStructuringElement< InputPixelType, Dimension > KernelType;</p><p class=""> </p><p class=""> typedef itk::BinaryMorphologicalOpeningImageFilter< InputPixelType,</p><p class=""> OutputImageType,</p><p class=""> KernelType > FilterType;</p><p class=""> typedef itk::RescaleIntensityImageFilter<OutputImageType, OutputImageType> RescaleFilterType;</p><p class=""> </p><p class=""> </p><p class=""> // Read Image</p><p class=""> ReaderType::Pointer reader = ReaderType::New();</p><p class=""> reader->SetFileName( argv[1] );</p><p class=""> reader->Update();</p><p class=""> </p><p class=""> //Create Kernel (structuring element)</p><p class=""> KernelType::RadiusType radius;</p><p class=""> radius[0] = atoi( argv[3] );</p><p class=""> radius[1] = atoi( argv[4] );</p><p class=""> radius[2] = atoi( argv[5] );</p><p class=""> </p><p class=""> </p><p class=""> KernelType kernel;</p><p class=""> kernel.SetRadius( Dimension );</p><p class=""> kernel.CreateStructuringElement();</p><p class=""> </p><p class=""> // Create morphological filter</p><p class=""> FilterType::Pointer filter = FilterType::New();</p><p class=""> filter->SetInput( reader );</p><p class=""> filter->SetKernel( kernel );</p><p class=""> filter->Update();</p><p class=""> </p><p class=""> // Rescale for output</p><p class=""> RescaleFilterType::Pointer rescaler = RescaleFilterType::New();</p><p class=""> rescaler->SetOutputMinimum( 0 );</p><p class=""> rescaler->SetOutputMaximum( 255 );</p><p class=""> rescaler->SetInput( filter->GetOutput() );</p><p class=""> //rescaler->Update();</p><p class=""> </p><p class=""> // Write output</p><p class=""> WriterType::Pointer writer = WriterType::New();</p><p class=""> writer->SetFileName( argv[2] );</p><p class=""> writer->SetInput( rescaler->GetOutput() );</p><p class=""> writer->Update();</p><p class=""> </p><p class=""> return EXIT_SUCCESS;</p><p class=""><span class=""></span></p><p class="">}</p><div><br></div><div><br><div><br clear="all"><div><br></div>-- <br><div>Kurt Sansom<br></div>
</div></div></div></div>