~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Examples/Registration/ImageRegistration2o.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-05-31 12:07:29 UTC
  • mfrom: (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080531120729-7g7layn480le43ko
Tags: 3.6.0-3
* debian/patches/gccxml-workaround.patch: New.  Work around gccxml issue
  with #include_next; c.f. http://www.gccxml.org/Bug/view.php?id=7134.  
* debian/patches/gcc43.patch: include <cstring> in itkNeighbourhood.h.
  This only showed up in the tcl wrapping step.

* Above two entries fix FTBFS for GCC 4.3-based systems.
  Closes: #478500.

* debian/patches/sharedforward.patch: New.  Ensure that linux/sparc
  systems are not also configured as a SUN sparc system, which requires
  SUN header sys/isa_defs.h.  Closes: #478940, #483312.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   Insight Segmentation & Registration Toolkit
4
4
  Module:    $RCSfile: ImageRegistration2o.cxx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2005/10/06 17:27:41 $
7
 
  Version:   $Revision: 1.3 $
 
6
  Date:      $Date: 2007-11-22 00:30:16 $
 
7
  Version:   $Revision: 1.6 $
8
8
 
9
9
  Copyright (c) Insight Software Consortium. All rights reserved.
10
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
132
132
 
133
133
int main( int argc, char *argv[] )
134
134
{
135
 
  if( argc < 3 )
 
135
  if( argc < 4 )
136
136
    {
137
137
    std::cerr << "Missing Parameters " << std::endl;
138
138
    std::cerr << "Usage: " << argv[0];
139
139
    std::cerr << " fixedImageFile  movingImageFile ";
140
140
    std::cerr << "outputImagefile [differenceImage]" << std::endl;
141
 
    return 1;
 
141
    return EXIT_FAILURE;
142
142
    }
143
143
  
144
144
  // Software Guide : BeginLatex
250
250
  // Software Guide : BeginCodeSnippet
251
251
  metric->SetFixedImageStandardDeviation(  0.4 );
252
252
  metric->SetMovingImageStandardDeviation( 0.4 );
253
 
  metric->SetNumberOfSpatialSamples( 50 );
254
253
  // Software Guide : EndCodeSnippet
255
254
 
256
255
  typedef itk::ImageFileReader< FixedImageType  > FixedImageReaderType;
331
330
 
332
331
 
333
332
  fixedNormalizer->Update();
334
 
  registration->SetFixedImageRegion( 
335
 
       fixedNormalizer->GetOutput()->GetBufferedRegion() );
 
333
  FixedImageType::RegionType fixedImageRegion =
 
334
       fixedNormalizer->GetOutput()->GetBufferedRegion();
 
335
  registration->SetFixedImageRegion( fixedImageRegion );
336
336
 
337
337
  typedef RegistrationType::ParametersType ParametersType;
338
338
  ParametersType initialParameters( transform->GetNumberOfParameters() );
342
342
  
343
343
  registration->SetInitialTransformParameters( initialParameters );
344
344
 
 
345
  // Software Guide : BeginCodeSnippet
 
346
  const unsigned int numberOfPixels = fixedImageRegion.GetNumberOfPixels();
 
347
  
 
348
  const unsigned int numberOfSamples = 
 
349
                        static_cast< unsigned int >( numberOfPixels * 0.01 );
 
350
 
 
351
  metric->SetNumberOfSpatialSamples( numberOfSamples );
 
352
  // Software Guide : EndCodeSnippet
 
353
 
345
354
 
346
355
  //  Software Guide : BeginLatex
347
356
  //  
360
369
 
361
370
 
362
371
  // Software Guide : BeginCodeSnippet
363
 
  optimizer->SetLearningRate( 20.0 );
 
372
  optimizer->SetLearningRate( 15.0 );
364
373
  optimizer->SetNumberOfIterations( 200 );
365
374
  optimizer->MaximizeOn();
366
375
  // Software Guide : EndCodeSnippet
380
389
    { 
381
390
    std::cout << "ExceptionObject caught !" << std::endl; 
382
391
    std::cout << err << std::endl; 
383
 
    return -1;
 
392
    return EXIT_FAILURE;
384
393
    } 
385
394
 
386
395
  ParametersType finalParameters = registration->GetLastTransformParameters();
455
464
  resample->SetSize(    fixedImage->GetLargestPossibleRegion().GetSize() );
456
465
  resample->SetOutputOrigin(  fixedImage->GetOrigin() );
457
466
  resample->SetOutputSpacing( fixedImage->GetSpacing() );
 
467
  resample->SetOutputDirection( fixedImage->GetDirection() );
458
468
  resample->SetDefaultPixelValue( 100 );
459
469
 
460
470
 
561
571
  //
562
572
  //  Software Guide : EndLatex 
563
573
 
564
 
  return 0;
 
574
  return EXIT_SUCCESS;
565
575
}
566
576