Skip to content

Commit

Permalink
BUG: Compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntustison committed Apr 10, 2020
1 parent 4658cde commit e0d7766
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
26 changes: 20 additions & 6 deletions Examples/SimulateDisplacementField.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <algorithm>
#include "ReadWriteData.h"

#include "itkCastImageFilter.h"
#include "itkSimulatedBSplineDisplacementFieldSource.h"
#include "itkSimulatedExponentialDisplacementFieldSource.h"

Expand All @@ -27,13 +28,13 @@ namespace ants
template <unsigned int ImageDimension>
int SimulateDisplacementField( int argc, char *argv[] )
{
using RealType = double;
using RealImageType = itk::Image<RealType, ImageDimension>;
using RealType = float;
using ImageType = itk::Image<RealType, ImageDimension>;
using VectorType = itk::Vector<RealType, ImageDimension>;
using DisplacementFieldType = itk::Image<VectorType, ImageDimension>;

typename RealImageType::Pointer domainImage;
ReadImage<RealImageType>( domainImage, argv[3] );
typename ImageType::Pointer domainImage;
ReadImage<ImageType>( domainImage, argv[3] );

if ( argc < 5 )
{
Expand Down Expand Up @@ -95,8 +96,14 @@ int SimulateDisplacementField( int argc, char *argv[] )
}
}

using RealImageType = typename BSplineSimulatorType::RealImageType;
using CastImageFilterType = itk::CastImageFilter<ImageType, RealImageType>;
typename CastImageFilterType::Pointer caster = CastImageFilterType::New();
caster->SetInput( domainImage );
caster->Update();

typename BSplineSimulatorType::Pointer bsplineSimulator = BSplineSimulatorType::New();
bsplineSimulator->SetDisplacementFieldDomainFromImage( domainImage );
bsplineSimulator->SetDisplacementFieldDomainFromImage( caster->GetOutput() );
bsplineSimulator->SetNumberOfRandomPoints( numberOfRandomPoints );
bsplineSimulator->SetEnforceStationaryBoundary( enforceStationaryBoundary );
bsplineSimulator->SetDisplacementNoiseStandardDeviation( standardDeviationDisplacementField );
Expand All @@ -117,8 +124,15 @@ int SimulateDisplacementField( int argc, char *argv[] )
}

using ExponentialSimulatorType = itk::SimulatedExponentialDisplacementFieldSource<DisplacementFieldType>;

using RealImageType = typename ExponentialSimulatorType::RealImageType;
using CastImageFilterType = itk::CastImageFilter<ImageType, RealImageType>;
typename CastImageFilterType::Pointer caster = CastImageFilterType::New();
caster->SetInput( domainImage );
caster->Update();

typename ExponentialSimulatorType::Pointer exponentialSimulator = ExponentialSimulatorType::New();
exponentialSimulator->SetDisplacementFieldDomainFromImage( domainImage );
exponentialSimulator->SetDisplacementFieldDomainFromImage( caster->GetOutput() );
exponentialSimulator->SetNumberOfRandomPoints( numberOfRandomPoints );
exponentialSimulator->SetEnforceStationaryBoundary( enforceStationaryBoundary );
exponentialSimulator->SetDisplacementNoiseStandardDeviation( standardDeviationDisplacementField );
Expand Down
1 change: 1 addition & 0 deletions Utilities/itkSimulatedExponentialDisplacementFieldSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SimulatedExponentialDisplacementFieldSource final:

using OutputImageType = TOutputImage;
using OutputImagePointer = typename OutputImageType::Pointer;
using OutputPixelComponentType = typename Superclass::OutputPixelComponentType;

/** Method for creation through the object factory. */
itkNewMacro( Self );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ SimulatedExponentialDisplacementFieldSource<TOutputImage>
RealType variance = std::pow( this->m_SmoothingStandardDeviation, 2 );
if( variance > 0.0 )
{
using GaussianSmoothingOperatorType = GaussianOperator<RealType, ImageDimension>;
using GaussianSmoothingOperatorType = GaussianOperator<OutputPixelComponentType, ImageDimension>;
GaussianSmoothingOperatorType gaussianSmoothingOperator;

using GaussianSmoothingSmootherType = VectorNeighborhoodOperatorImageFilter<OutputImageType, OutputImageType>;
Expand Down

0 comments on commit e0d7766

Please sign in to comment.