# Difference between revisions of "SimpleITK/Advisory Review Board"

• Harvey Cline, Kitware Inc.
• Raghu Machiraju, The State University of Ohio
• John Galeotti, CMU
• Hans Johnson, University of Iowa
• Fabrice de Chaumont, Pasteur Institute
• New students in the UNC CISMM project (taylorr@cs.unc.edu)
• Jesus Caban, NLM-NIH

# ARB Prototype Code

## Gaussian Blur

• Open an image
• Filter the image with a Gaussian blur using sigma = 2
• Write the image back out

#### Procedural

```// Read the image

// Apply Gaussian with sigma = 2
im = GaussianFilter::Execute(im, 2);

// Write out the image
ImageFileWriter::Execute(im, "sample/path/to/output.png");
```

#### Filter Blocks

```// Read the image

// Apply Gaussian with sigma = 2
Gaussian filter;
filter.SetSigma( 2 );
im = filter.execute( im );

// Write out the image
ImageFileWriter writer;
writer.SetFilename( "sample/path/to/output.png" );
writer.execute( im );
```

#### Pipelined

```// Read the image

// Apply Gaussian with sigma = 2
Gaussian filter;
filter.SetSigma( 2 );

// Write out the image
ImageFileWriter writer;
writer.SetFilename( "sample/path/to/output.png" );
writer.SetInput( filter->GetOutput() );

// Execute the pipieline
writer.Update();
```

## Image Registration

• Open two images (one fixed, one moving)
• Register the moving image to the fixed image using affine registration
• Resample the moving image using the computed transform
• Write the resampled image out

#### Procedural

```// Open the fixed and moving images
Image::Pointer fixedImage = ImageFileReader::Execute( "path/to/fixed.jpg" );
Image::Pointer movingImage = ImageFileReader::Execute( "path/to/moving.jpg" );

// Register the moving image to the fixed image
AffineTransform::Pointer transform AffineRegistrator::Execute( fixedImage, movingImage );

// Resample the moving image
movingImage = ImageResampler::Execute( movingImage, transform );

// Write out the resampled image
ImageFileWriter::Ececute( movingImage, "path/to/output.png" );
```

#### Filter blocks

```// Open the fixed and moving images

// Register the moving image to the fixed image
AffineRegistrator registrator;
registrator.SetFixedImage( fixedImage );
registrator.SetMovingImage( movingImage );
AffineTransform transform;
transform = registrator.execute();

// Resample the moving image
Resampler resampler;
resampler.SetTransform( transform );
movingImage = resampler.execute( movingImage );

// Write out the resampled image
ImageFileWriter writer;
writer.SetFilename( "path/to/output.png" );
writer.ececute( movingImage );
```

#### Pipeline

```// Open the fixed and moving images

// Register the moving image to the fixed image
AffineRegistrator registrator;

// Resample the moving image
Resampler resampler;
resampler.SetTransform( registrator.GetOutput() );

// Write out the resampled image
ImageFileWriter writer;
writer.SetFilename( "path/to/output.png" );
writer.SetInput( movingImage );

// Execute the pipeline
writer.Update();
```

#### Enum approach

```// NOTE: Language = C#
// Create metric
itk::simple::simpleMetric metric;
metric.setType( itk::simple::MattesMutualInformation );
metric.setParameterInt( "NumberOfHistogramBins", 30 );
metric.setParameterInt( "NumberOfSpatialSamples", 1000 );

// Create interpolator
itk::simple::simpleInterpolator interpolator;
interpolator.setType( itk::simple::LanczosWindowedSincInterpolation );

// Create transform
itk::simple::simpleTransform transform;
transform.setType( itk::simple::AffineTransform );

// Create optimizer
itk::simple::simpleOptimizer optimizer;
optimizer.setParameterInt( "NumberOfIterations", 100 );
optimizer.setParameterDouble( "MinimumStepLength", 0.005 );
optimizer.setParameterDouble( "MaximumStepLength", 1.0 );
optimizer.setParameterBoolean( "Maximize", true );

// Registration
itk::simple::simpleRegistration registration;
registration.setMetric( metric );
registration.setInterpolator( interpolator );
registration.setTransform( transform );
registration.setOptimizer( optimizer );
```