<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">This is the error I get: <br><br>Building CXX object CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o<br>Linking CXX executable ImageRegistration1<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()':<br>ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()]+0x8): undefined reference to `typeinfo for itk::Statistics::DenseFrequencyContainer'<br>ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory<itk::Statistics::DenseFrequencyContainer>::Create()]+0x55): undefined reference to `typeinfo for
itk::Statistics::DenseFrequencyContainer'<br>CMakeFiles/ImageRegistration1..dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::SetToZero()':<br>ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE9SetToZeroEv[itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::SetToZero()]+0x18): undefined reference to `itk::Statistics::DenseFrequencyContainer::SetToZero()'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::Initialize(itk::Size<1u> const&)':<br>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)'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::IncreaseFrequency(unsigned long const&, float)':<br>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)'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram<float, 1u, itk::Statistics::DenseFrequencyContainer>::GetFrequency(unsigned long const&)
const':<br>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'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::DenseFrequencyContainer::New()':<br>ImageRegistration1.cxx:(.text._ZN3itk10Statistics23DenseFrequencyContainer3NewEv[itk::Statistics::DenseFrequencyContainer::New()]+0x3f): undefined reference to `itk::Statistics::DenseFrequencyContainer::DenseFrequencyContainer()'<br>collect2: ld returned 1 exit status<br>make[2]: *** [ImageRegistration1] Error 1<br>make[1]: *** [CMakeFiles/ImageRegistration1.dir/all] Error 2<br>make: *** [all] Error 2<br><br><br>Thanks,<br>Sarah<br><br>--- On <b>Mon, 10/5/09, Gabriele
Arnulfo <i><tartuz@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Gabriele Arnulfo <tartuz@gmail.com><br>Subject: Re: [Insight-users] Fw: problem<br>To: "Sarah Waldron" <sarah.waldron11@yahoo..com><br>Cc: insight-users@itk.org<br>Date: Monday, October 5, 2009, 2:51 PM<br><br><div class="plainMail">Hi Sarah,<br><br>>The code performs a linking error.<br><br>try to paste here the error that occurs with your code, maybe you can<br>receive better answer.<br><br><br><br>On Mon, Oct 05, 2009 at 07:21:13AM -0700, Sarah Waldron wrote:<br>> Did everyone get this email? I'm not getting any response from anyone<br>> Thanks<br>> <br>> <a ymailto="mailto:insight-users@itk.org" href="/mc/compose?to=insight-users@itk.org">insight-users@itk.org</a><br>> <br>> --- On Fri, 10/2/09, Sarah Waldron <<a ymailto="mailto:sarah.waldron11@yahoo..com"
href="/mc/compose?to=sarah.waldron11@yahoo.com">sarah.waldron11@yahoo.com</a>> wrote:<br>> <br>> From: Sarah Waldron <<a ymailto="mailto:sarah.waldron11@yahoo.com" href="/mc/compose?to=sarah.waldron11@yahoo.com">sarah.waldron11@yahoo.com</a>><br>> Subject: [Insight-users] problem<br>> To: <a ymailto="mailto:insight-users@itk.org" href="/mc/compose?to=insight-users@itk.org">insight-users@itk.org</a><br>> Date: Friday, October 2, 2009, 6:01 PM<br>> <br>> Hi ,<br>> 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. <br>> Thanks,<br>> Sarah<br>> <br>> <br>> <br>> <br>> <br>> <br>> -----Inline Attachment Follows-----<br>> <br>>
_____________________________________<br>> Powered by www.kitware.com<br>> <br>> Visit other Kitware open-source projects at<br>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>> <br>> Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk..org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>> <br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>> <br>> <br>> <br>> <br>> #include "itkImageRegistrationMethod.h"<br>> #include "itkTranslationTransform.h"<br>> #include "itkMeanSquaresImageToImageMetric.h"<br>> #include "itkLinearInterpolateImageFunction.h"<br>> #include
"itkRegularStepGradientDescentOptimizer.h"<br>> #include "itkImage.h"<br>> #include "itkImageFileReader.h"<br>> #include "itkImageFileWriter..h"<br>> #include "itkResampleImageFilter.h"<br>> #include "itkCastImageFilter.h"<br>> #include "itkRescaleIntensityImageFilter.h"<br>> #include "itkSubtractImageFilter.h"<br>> #include "itkHistogramMatchingImageFilter.h"<br>> <br>> <br>> <br>> class CommandIterationUpdate : public itk::Command <br>> {<br>> public:<br>> typedef CommandIterationUpdate Self;<br>> typedef itk::Command Superclass;<br>> typedef itk::SmartPointer<Self> Pointer;<br>> itkNewMacro( Self );<br>> <br>> protected:<br>> CommandIterationUpdate() {};<br>> <br>> public:<br>>
<br>> typedef itk::RegularStepGradientDescentOptimizer OptimizerType;<br>> typedef const OptimizerType *OptimizerPointer;<br>> <br>> void Execute(itk::Object *caller, const itk::EventObject & event)<br>> {<br>> Execute( (const itk::Object *)caller, event);<br>> }<br>> <br>> void Execute(const itk::Object * object, const itk::EventObject & event)<br>> {<br>> OptimizerPointer optimizer = <br>> dynamic_cast< OptimizerPointer >( object );<br>> <br>> if( ! itk::IterationEvent().CheckEvent( &event )
)<br>> {<br>> return;<br>> }<br>> <br>> std::cout << optimizer->GetCurrentIteration() << " = ";<br>> std::cout << optimizer->GetValue() << " : ";<br>> std::cout << optimizer->GetCurrentPosition() << std::endl;<br>> }<br>> <br>> };<br>> <br>> <br>> int main( int argc, char *argv[] )<br>> {<br>> if( argc < 4 )<br>> {<br>> std::cerr << "Missing Parameters " << std::endl;<br>> std::cerr << "Usage: " << argv[0];<br>> std::cerr << " fixedImageFile movingImageFile ";<br>> std::cerr <<
"outputImagefile [differenceImageAfter]";<br>> std::cerr << "[differenceImageBefore]" << std::endl;<br>> return EXIT_FAILURE;<br>> }<br>> <br>> const unsigned int Dimension = 2;<br>> typedef unsigned int PixelType;<br>> typedef itk::Image< PixelType, Dimension > FixedImageType;<br>> typedef itk::Image< PixelType, Dimension > MovingImageType;<br>> <br>> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;<br>> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;<br>> FixedImageReaderType::Pointer fixedImageReader =
FixedImageReaderType::New();<br>> MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();<br>> fixedImageReader->SetFileName( argv[1] );<br>> movingImageReader->SetFileName( argv[2] );<br>> fixedImageReader->Update();<br>> movingImageReader->Update();<br>> <br>> typedef float InternalPixelType;<br>> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br>> typedef itk::CastImageFilter< FixedImageType, InternalImageType > FixedImageCasterType;<br>> typedef itk::CastImageFilter< MovingImageType, InternalImageType > MovingImageCasterType;<br>> FixedImageCasterType::Pointer fixedImageCaster =
FixedImageCasterType::New();<br>> MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New();<br>> <br>> fixedImageCaster->SetInput( fixedImageReader->GetOutput() );<br>> movingImageCaster->SetInput( movingImageReader->GetOutput() );<br>> <br>> fixedImageCaster->Update();<br>> movingImageCaster->Update();<br>> <br>> typedef itk::HistogramMatchingImageFilter< InternalImageType, InternalImageType > MatchingFilterType;<br>> MatchingFilterType::Pointer matcher = MatchingFilterType::New();<br>> matcher->SetInput( movingImageCaster->GetOutput() );<br>> matcher->SetReferenceImage( fixedImageCaster->GetOutput() );<br>> matcher->SetNumberOfHistogramLevels( 1024 );<br>> matcher->SetNumberOfMatchPoints( 7 );<br>>
matcher->ThresholdAtMeanIntensityOn();<br>> <br>> <br>> typedef itk::TranslationTransform< double, Dimension > TransformType;<br>> typedef itk::RegularStepGradientDescentOptimizer OptimizerType;<br>> typedef itk::MeanSquaresImageToImageMetric< InternalImageType, InternalImageType > MetricType;<br>> typedef itk:: LinearInterpolateImageFunction< InternalImageType, double > InterpolatorType;<br>> typedef itk::ImageRegistrationMethod< InternalImageType, InternalImageType > RegistrationType;<br>> <br>> MetricType::Pointer metric = MetricType::New();<br>> TransformType::Pointer transform
= TransformType::New();<br>> OptimizerType::Pointer optimizer = OptimizerType::New();<br>> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>> RegistrationType::Pointer registration = RegistrationType::New();<br>> <br>> registration->SetMetric( metric );<br>> registration->SetOptimizer( optimizer );<br>> registration->SetTransform( transform );<br>> registration->SetInterpolator( interpolator );<br>> <br>> <br>> registration->SetFixedImage(
fixedImageCaster->GetOutput() );<br>> registration->SetMovingImage( matcher->GetOutput() );<br>> <br>> <br>> typedef RegistrationType::ParametersType ParametersType;<br>> ParametersType initialParameters( transform->GetNumberOfParameters() );<br>> <br>> initialParameters[0] = 0.0; // Initial offset in mm along X<br>> initialParameters[1] = 0.0; // Initial offset in mm along Y<br>> <br>> registration->SetInitialTransformParameters( initialParameters );<br>> <br>> // It is usually desirable to fine tune the parameters of the optimizer.<br>> // Each optimizer has particular parameters that must be interpreted in the<br>> // context of the
optimization strategy it implements. The optimizer used in<br>> // this example is a variant of gradient descent that attempts to prevent it<br>> // from taking steps that are too large. At each iteration, this optimizer<br>> // will take a step along the direction of the \doxygen{ImageToImageMetric}<br>> // derivative. The initial length of the step is defined by the user. Each<br>> // time the direction of the derivative abruptly changes, the optimizer<br>> // assumes that a local extrema has been passed and reacts by reducing the<br>> // step length by a half. After several reductions of the step length, the<br>> // optimizer may be moving in a very restricted area of the transform<br>> // parameter space. The user
can define how small the step length should be<br>> // to consider convergence to have been reached. This is equivalent to defining<br>> // the precision with which the final transform should be known.<br>> //<br>> // The initial step length is defined with the method<br>> // \code{SetMaximumStepLength()}, while the tolerance for convergence is<br>> // defined with the method \code{SetMinimumStepLength()}.<br>> <br>> optimizer->SetMaximumStepLength( 4.00 ); <br>> optimizer->SetMinimumStepLength( 0.01 );<br>> optimizer->SetNumberOfIterations( 200 );<br>> // Connect an observer<br>> CommandIterationUpdate::Pointer observer =
CommandIterationUpdate::New();<br>> optimizer->AddObserver( itk::IterationEvent(), observer );<br>> <br>> try <br>> { <br>> registration->Update(); <br>> } <br>> catch( itk::ExceptionObject & err ) <br>> { <br>> std::cerr << "ExceptionObject caught !" << std::endl; <br>> std::cerr << err << std::endl; <br>> return EXIT_FAILURE;<br>> } <br>> // The result of the registration process is an array of parameters that<br>> // defines the spatial transformation in an unique way. This final result is<br>> // obtained using the \code{GetLastTransformParameters()}
method.<br>> ParametersType finalParameters = registration->GetLastTransformParameters();<br>> <br>> // In the case of the \doxygen{TranslationTransform}, there is a<br>> // straightforward interpretation of the parameters. Each element of the<br>> // array corresponds to a translation along one spatial dimension.<br>> const double TranslationAlongX = finalParameters[0];<br>> const double TranslationAlongY = finalParameters[1];<br>> const unsigned int numberOfIterations = optimizer->GetCurrentIteration();<br>> <br>> // The value of the image metric corresponding to the last set of parameters<br>> // can be obtained with the \code{GetValue()} method of the optimizer.<br>> const double bestValue =
optimizer->GetValue();<br>> <br>> std::cout << "Result = " << std::endl;<br>> std::cout << " Translation X = " << TranslationAlongX << std::endl;<br>> std::cout << " Translation Y = " << TranslationAlongY << std::endl;<br>> std::cout << " Iterations = " << numberOfIterations << std::endl;<br>> std::cout << " Metric value = " << bestValue << std::endl;<br>> <br>> typedef itk::ResampleImageFilter< MovingImageType, FixedImageType > ResampleFilterType;<br>> <br>> ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br>> resampler->SetInput( movingImageReader->GetOutput()
);<br>> resampler->SetTransform( registration->GetOutput()->Get() );<br>> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();<br>> resampler->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );<br>> resampler->SetOutputOrigin( fixedImage->GetOrigin() );<br>> resampler->SetOutputSpacing( fixedImage->GetSpacing() );<br>> resampler->SetOutputDirection( fixedImage->GetDirection() );<br>> resampler->SetDefaultPixelValue( 100 );<br>> <br>> typedef unsigned char OutputPixelType;<br>> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>> typedef itk::CastImageFilter< FixedImageType, OutputImageType > CastFilterType;<br>> typedef
itk::ImageFileWriter< OutputImageType > WriterType;<br>> <br>> WriterType::Pointer writer = WriterType::New();<br>> CastFilterType::Pointer caster = CastFilterType::New();<br>> writer->SetFileName( argv[3] );<br>> <br>> caster->SetInput( resampler->GetOutput() );<br>> writer->SetInput( caster->GetOutput() );<br>> writer->Update();<br>> typedef itk::SubtractImageFilter< FixedImageType, FixedImageType, FixedImageType > DifferenceFilterType;<br>> <br>> DifferenceFilterType::Pointer difference = DifferenceFilterType::New();<br>> <br>> difference->SetInput1( fixedImageReader->GetOutput() );<br>> difference->SetInput2(
resampler->GetOutput() );<br>> typedef itk::RescaleIntensityImageFilter< FixedImageType, OutputImageType > RescalerType;<br>> <br>> RescalerType::Pointer intensityRescaler = RescalerType::New();<br>> <br>> intensityRescaler->SetInput( difference->GetOutput() );<br>> intensityRescaler->SetOutputMinimum( 0 );<br>> intensityRescaler->SetOutputMaximum( 255 );<br>> <br>> resampler->SetDefaultPixelValue( 1 );<br>> WriterType::Pointer writer2 = WriterType::New();<br>> writer2->SetInput( intensityRescaler->GetOutput() ); <br>> <br>> if( argc > 4 )<br>> {<br>> writer2->SetFileName( argv[4] );<br>>
writer2->Update();<br>> }<br>> <br>> TransformType::Pointer identityTransform = TransformType::New();<br>> identityTransform->SetIdentity();<br>> resampler->SetTransform( identityTransform );<br>> <br>> if( argc > 5 )<br>> {<br>> writer2->SetFileName( argv[5] );<br>> writer2->Update();<br>> }<br>> <br>> return EXIT_SUCCESS;<br>> }<br>> <br><br>> PROJECT(ImageRegistration1)<br>> FIND_PACKAGE(ITK)<br>> IF(ITK_FOUND)<br>> INCLUDE(${ITK_USE_FILE})<br>> ELSE(ITK_FOUND)<br>> MESSAGE(FATAL_ERROR<br>> "ITK not found. Please set ITK_DIR.")<br>>
ENDIF(ITK_FOUND)<br>> <br>> ADD_EXECUTABLE(ImageRegistration1 ImageRegistration1.cxx )<br>> TARGET_LINK_LIBRARIES(ImageRegistration1 ITKIO ITKNumerics)<br><br>> _____________________________________<br>> Powered by www.kitware.com<br>> <br>> Visit other Kitware open-source projects at<br>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>> <br>> Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>> <br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br><br><br>-- <br>=============================================<br>Gabriele Arnulfo<br>BioEngineering Phd Student.<br>Bio-Lab, DIST - University of
Genoa<br>Viale Causa 13, 16145 Genova - ITALY<br>Tel : (+39) 010-353-2789<br>Fax : (+39) 010-353-2948<br>Email : gabriele.arnulfo_at_gmail.com<br>Web : <a href="http://ga.mtvl.org" target="_blank">http://ga.mtvl.org</a><br>------------------------------------<br>In a world without wall,<br> who needs WindowS?<br>------------------------------------<br>=============================================<br><br><br></div></blockquote></td></tr></table><br>