[Insight-users] Fw: problem

Sarah Waldron sarah.waldron11 at yahoo.com
Mon Oct 5 11:47:18 EDT 2009


This is the error I get: 

Building CXX object CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o
Linking CXX executable ImageRegistration1
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()':
ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()]+0x8): undefined reference to `typeinfo for itk::Statistics::DenseFrequencyContainer'
ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()]+0x55): undefined reference to `typeinfo for itk::Statistics::DenseFrequencyContainer'
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::SetToZero()':
ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE9SetToZeroEv[itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::SetToZero()]+0x18): undefined reference to `itk::Statistics::DenseFrequencyContainer::SetToZero()'
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::Initialize(itk::Size<1u> const&)':
ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE10InitializeERKNS_4SizeILj1EEE[itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::Initialize(itk::Size<1u> const&)]+0x236): undefined reference to `itk::Statistics::DenseFrequencyContainer::Initialize(unsigned long)'
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::IncreaseFrequency(unsigned long const&, float)':
ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE17IncreaseFrequencyERKmf[itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::IncreaseFrequency(unsigned long const&, float)]+0x2b): undefined reference to `itk::Statistics::DenseFrequencyContainer::IncreaseFrequency(unsigned long, float)'
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::GetFrequency(unsigned long const&) const':
ImageRegistration1.cxx:(.text._ZNK3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE12GetFrequencyERKm[itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::GetFrequency(unsigned long const&) const]+0x22): undefined reference to `itk::Statistics::DenseFrequencyContainer::GetFrequency(unsigned long) const'
CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::DenseFrequencyContainer::New()':
ImageRegistration1.cxx:(.text._ZN3itk10Statistics23DenseFrequencyContainer3NewEv[itk::Statistics::DenseFrequencyContainer::New()]+0x3f): undefined reference to `itk::Statistics::DenseFrequencyContainer::DenseFrequencyContainer()'
collect2: ld returned 1 exit status
make[2]: *** [ImageRegistration1] Error 1
make[1]: *** [CMakeFiles/ImageRegistration1.dir/all] Error 2
make: *** [all] Error 2


Thanks,
Sarah

--- On Mon, 10/5/09, Gabriele Arnulfo <tartuz at gmail.com> wrote:

From: Gabriele Arnulfo <tartuz at gmail.com>
Subject: Re: [Insight-users] Fw:  problem
To: "Sarah Waldron" <sarah.waldron11 at yahoo.com>
Cc: insight-users at itk.org
Date: Monday, October 5, 2009, 2:51 PM

Hi Sarah,

>The code performs a linking error.

try to paste here the error that occurs with your code, maybe you can
receive better answer.



On Mon, Oct 05, 2009 at 07:21:13AM -0700, Sarah Waldron wrote:
> Did everyone get this email? I'm not getting any response from anyone
> Thanks
> 
> insight-users at itk.org
> 
> --- On Fri, 10/2/09, Sarah Waldron <sarah.waldron11 at yahoo.com> wrote:
> 
> From: Sarah Waldron <sarah.waldron11 at yahoo.com>
> Subject: [Insight-users] problem
> To: insight-users at itk.org
> Date: Friday, October 2, 2009, 6:01 PM
> 
> Hi ,
> Im new to ITK and I'm having some trouble with this program I'm writing. I want the program to perform rigid registration (translation only) but perform histogram matching first. The code performs a linking error. I've attached the *.cxx and cmakelists file. 
> Thanks,
> Sarah
> 
> 
> 
> 
> 
>       
> -----Inline Attachment Follows-----
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
>       
> #include "itkImageRegistrationMethod.h"
> #include "itkTranslationTransform.h"
> #include "itkMeanSquaresImageToImageMetric.h"
> #include "itkLinearInterpolateImageFunction.h"
> #include "itkRegularStepGradientDescentOptimizer.h"
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkResampleImageFilter.h"
> #include "itkCastImageFilter.h"
> #include "itkRescaleIntensityImageFilter.h"
> #include "itkSubtractImageFilter.h"
> #include "itkHistogramMatchingImageFilter.h"
> 
> 
> 
> class CommandIterationUpdate : public itk::Command 
> {
> public:
>   typedef  CommandIterationUpdate   Self;
>   typedef  itk::Command             Superclass;
>   typedef itk::SmartPointer<Self>  Pointer;
>   itkNewMacro( Self );
> 
> protected:
>   CommandIterationUpdate() {};
> 
> public:
> 
>   typedef itk::RegularStepGradientDescentOptimizer     OptimizerType;
>   typedef const OptimizerType                         *OptimizerPointer;
> 
>   void Execute(itk::Object *caller, const itk::EventObject & event)
>   {
>     Execute( (const itk::Object *)caller, event);
>   }
> 
>   void Execute(const itk::Object * object, const itk::EventObject & event)
>   {
>     OptimizerPointer optimizer = 
>                          dynamic_cast< OptimizerPointer >( object );
> 
>     if( ! itk::IterationEvent().CheckEvent( &event ) )
>       {
>       return;
>       }
> 
>     std::cout << optimizer->GetCurrentIteration() << " = ";
>     std::cout << optimizer->GetValue() << " : ";
>     std::cout << optimizer->GetCurrentPosition() << std::endl;
>   }
>    
> };
> 
> 
> int main( int argc, char *argv[] )
> {
>   if( argc < 4 )
>     {
>     std::cerr << "Missing Parameters " << std::endl;
>     std::cerr << "Usage: " << argv[0];
>     std::cerr << " fixedImageFile  movingImageFile ";
>     std::cerr << "outputImagefile [differenceImageAfter]";
>     std::cerr << "[differenceImageBefore]" << std::endl;
>     return EXIT_FAILURE;
>     }
>   
>   const    unsigned int    Dimension = 2;
>   typedef  unsigned int           PixelType;
>   typedef itk::Image< PixelType, Dimension >  FixedImageType;
>   typedef itk::Image< PixelType, Dimension >  MovingImageType;
> 
>   typedef itk::ImageFileReader< FixedImageType  > FixedImageReaderType;
>   typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
>   FixedImageReaderType::Pointer  fixedImageReader  = FixedImageReaderType::New();
>   MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
>   fixedImageReader->SetFileName(  argv[1] );
>   movingImageReader->SetFileName( argv[2] );
>   fixedImageReader->Update();
>   movingImageReader->Update();
> 
>   typedef float InternalPixelType;
>   typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
>   typedef itk::CastImageFilter< FixedImageType, InternalImageType > FixedImageCasterType;
>   typedef itk::CastImageFilter< MovingImageType, InternalImageType > MovingImageCasterType;
>   FixedImageCasterType::Pointer fixedImageCaster   = FixedImageCasterType::New();
>   MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New();
> 
>   fixedImageCaster->SetInput( fixedImageReader->GetOutput() );
>   movingImageCaster->SetInput( movingImageReader->GetOutput() );
> 
>   fixedImageCaster->Update();
>   movingImageCaster->Update();
> 
> typedef itk::HistogramMatchingImageFilter< InternalImageType, InternalImageType >   MatchingFilterType;
> MatchingFilterType::Pointer matcher = MatchingFilterType::New();
> matcher->SetInput( movingImageCaster->GetOutput() );
> matcher->SetReferenceImage( fixedImageCaster->GetOutput() );
> matcher->SetNumberOfHistogramLevels( 1024 );
> matcher->SetNumberOfMatchPoints( 7 );
> matcher->ThresholdAtMeanIntensityOn();
> 
>  
>   typedef itk::TranslationTransform< double, Dimension > TransformType;
>   typedef itk::RegularStepGradientDescentOptimizer       OptimizerType;
>   typedef itk::MeanSquaresImageToImageMetric< InternalImageType, InternalImageType >    MetricType;
>   typedef itk:: LinearInterpolateImageFunction< InternalImageType, double          >    InterpolatorType;
>   typedef itk::ImageRegistrationMethod< InternalImageType, InternalImageType >    RegistrationType;
> 
>   MetricType::Pointer         metric        = MetricType::New();
>   TransformType::Pointer      transform     = TransformType::New();
>   OptimizerType::Pointer      optimizer     = OptimizerType::New();
>   InterpolatorType::Pointer   interpolator  = InterpolatorType::New();
>   RegistrationType::Pointer   registration  = RegistrationType::New();
> 
>   registration->SetMetric(        metric        );
>   registration->SetOptimizer(     optimizer     );
>   registration->SetTransform(     transform     );
>   registration->SetInterpolator(  interpolator  );
> 
> 
>   registration->SetFixedImage(    fixedImageCaster->GetOutput()    );
>   registration->SetMovingImage(   matcher->GetOutput()   );
> 
> 
>   typedef RegistrationType::ParametersType ParametersType;
>   ParametersType initialParameters( transform->GetNumberOfParameters() );
> 
>   initialParameters[0] = 0.0;  // Initial offset in mm along X
>   initialParameters[1] = 0.0;  // Initial offset in mm along Y
>   
>   registration->SetInitialTransformParameters( initialParameters );
>   
>   //  It is usually desirable to fine tune the parameters of the optimizer.
>   //  Each optimizer has particular parameters that must be interpreted in the
>   //  context of the optimization strategy it implements. The optimizer used in
>   //  this example is a variant of gradient descent that attempts to prevent it
>   //  from taking steps that are too large.  At each iteration, this optimizer
>   //  will take a step along the direction of the \doxygen{ImageToImageMetric}
>   //  derivative. The initial length of the step is defined by the user. Each
>   //  time the direction of the derivative abruptly changes, the optimizer
>   //  assumes that a local extrema has been passed and reacts by reducing the
>   //  step length by a half. After several reductions of the step length, the
>   //  optimizer may be moving in a very restricted area of the transform
>   //  parameter space. The user can define how small the step length should be
>   //  to consider convergence to have been reached. This is equivalent to defining
>   //  the precision with which the final transform should be known.
>   //
>   //  The initial step length is defined with the method
>   //  \code{SetMaximumStepLength()}, while the tolerance for convergence is
>   //  defined with the method \code{SetMinimumStepLength()}.
>  
>   optimizer->SetMaximumStepLength( 4.00 );  
>   optimizer->SetMinimumStepLength( 0.01 );
>   optimizer->SetNumberOfIterations( 200 );
>   // Connect an observer
>   CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();
>   optimizer->AddObserver( itk::IterationEvent(), observer );
> 
>   try 
>     { 
>     registration->Update(); 
>     } 
>   catch( itk::ExceptionObject & err ) 
>     { 
>     std::cerr << "ExceptionObject caught !" << std::endl; 
>     std::cerr << err << std::endl; 
>     return EXIT_FAILURE;
>     } 
>   //  The result of the registration process is an array of parameters that
>   //  defines the spatial transformation in an unique way. This final result is
>   //  obtained using the \code{GetLastTransformParameters()} method.
>   ParametersType finalParameters = registration->GetLastTransformParameters();
> 
>   //  In the case of the \doxygen{TranslationTransform}, there is a
>   //  straightforward interpretation of the parameters.  Each element of the
>   //  array corresponds to a translation along one spatial dimension.
>   const double TranslationAlongX = finalParameters[0];
>   const double TranslationAlongY = finalParameters[1];
>   const unsigned int numberOfIterations = optimizer->GetCurrentIteration();
> 
>   //  The value of the image metric corresponding to the last set of parameters
>   //  can be obtained with the \code{GetValue()} method of the optimizer.
>   const double bestValue = optimizer->GetValue();
> 
>   std::cout << "Result = " << std::endl;
>   std::cout << " Translation X = " << TranslationAlongX  << std::endl;
>   std::cout << " Translation Y = " << TranslationAlongY  << std::endl;
>   std::cout << " Iterations    = " << numberOfIterations << std::endl;
>   std::cout << " Metric value  = " << bestValue          << std::endl;
> 
>   typedef itk::ResampleImageFilter< MovingImageType, FixedImageType >    ResampleFilterType;
>   
>   ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>   resampler->SetInput( movingImageReader->GetOutput() );
>   resampler->SetTransform( registration->GetOutput()->Get() );
>   FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
>   resampler->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );
>   resampler->SetOutputOrigin(  fixedImage->GetOrigin() );
>   resampler->SetOutputSpacing( fixedImage->GetSpacing() );
>   resampler->SetOutputDirection( fixedImage->GetDirection() );
>   resampler->SetDefaultPixelValue( 100 );
>   
>   typedef unsigned char OutputPixelType;
>   typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>   typedef itk::CastImageFilter< FixedImageType, OutputImageType > CastFilterType;
>   typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>   
>   WriterType::Pointer      writer =  WriterType::New();
>   CastFilterType::Pointer  caster =  CastFilterType::New();
>   writer->SetFileName( argv[3] );
> 
>   caster->SetInput( resampler->GetOutput() );
>   writer->SetInput( caster->GetOutput()   );
>   writer->Update();
>   typedef itk::SubtractImageFilter< FixedImageType, FixedImageType, FixedImageType > DifferenceFilterType;
> 
>   DifferenceFilterType::Pointer difference = DifferenceFilterType::New();
> 
>   difference->SetInput1( fixedImageReader->GetOutput() );
>   difference->SetInput2( resampler->GetOutput() );
>   typedef itk::RescaleIntensityImageFilter< FixedImageType, OutputImageType >   RescalerType;
> 
>   RescalerType::Pointer intensityRescaler = RescalerType::New();
>   
>   intensityRescaler->SetInput( difference->GetOutput() );
>   intensityRescaler->SetOutputMinimum(   0 );
>   intensityRescaler->SetOutputMaximum( 255 );
> 
>   resampler->SetDefaultPixelValue( 1 );
>   WriterType::Pointer writer2 = WriterType::New();
>   writer2->SetInput( intensityRescaler->GetOutput() );  
> 
>   if( argc > 4 )
>     {
>     writer2->SetFileName( argv[4] );
>     writer2->Update();
>     }
> 
>   TransformType::Pointer identityTransform = TransformType::New();
>   identityTransform->SetIdentity();
>   resampler->SetTransform( identityTransform );
>   
>   if( argc > 5 )
>     {
>     writer2->SetFileName( argv[5] );
>     writer2->Update();
>     }
> 
>   return EXIT_SUCCESS;
> }
> 

> PROJECT(ImageRegistration1)
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
>   INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
>   MESSAGE(FATAL_ERROR
>           "ITK not found. Please set ITK_DIR.")
> ENDIF(ITK_FOUND)
> 
> ADD_EXECUTABLE(ImageRegistration1 ImageRegistration1.cxx )
> TARGET_LINK_LIBRARIES(ImageRegistration1 ITKIO ITKNumerics)

> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


-- 
=============================================
Gabriele Arnulfo
BioEngineering Phd Student.
Bio-Lab, DIST - University of Genoa
Viale Causa 13, 16145 Genova - ITALY
Tel    :    (+39) 010-353-2789
Fax    :    (+39) 010-353-2948
Email    :    gabriele.arnulfo_at_gmail.com
Web     :    http://ga.mtvl.org
------------------------------------
In a world without wall,
            who needs WindowS?
------------------------------------
=============================================





      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091005/3ed074ec/attachment-0001.htm>


More information about the Insight-users mailing list