SimpleITK/Advisory Review Board: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
Line 17: Line 17:
<pre>
<pre>
// Read the image
// Read the image
itk::simple::ImageFileReader reader;
ImageFileReader reader;
itk::simple::Image::Pointer im = reader.execute( "sample/path/to/image.jpg" );
Image::Pointer im = reader.execute( "sample/path/to/image.jpg" );


// Apply Gaussian with sigma = 2
// Apply Gaussian with sigma = 2
itk::simple::Gaussian filter;
Gaussian filter;
im = filter.execute( im, 2 );
im = filter.execute( im, 2 );


// Write out the image
// Write out the image
itk::simple::ImageFileWriter writer;
ImageFileWriter writer;
writer.execute( im, "sample/path/to/output.png" );
writer.execute( im, "sample/path/to/output.png" );
</pre>
</pre>
Line 32: Line 32:
<pre>
<pre>
// Read the image
// Read the image
itk::simple::ImageFileReader reader;
ImageFileReader reader;
reader.SetFilename( "sample/path/to/image.jpg" );
reader.SetFilename( "sample/path/to/image.jpg" );
itk::simple::Image::Pointer im = reader.execute();
Image::Pointer im = reader.execute();


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


// Write out the image
// Write out the image
itk::simple::ImageFileWriter writer;
ImageFileWriter writer;
writer.SetFilename( "sample/path/to/output.png" );
writer.SetFilename( "sample/path/to/output.png" );
writer.execute( im );
writer.execute( im );
Line 50: Line 50:
<pre>
<pre>
// Read the image
// Read the image
itk::simple::ImageFileReader reader;
ImageFileReader reader;
reader.SetFilename( "sample/path/to/image.jpg" );
reader.SetFilename( "sample/path/to/image.jpg" );


// Apply Gaussian with sigma = 2
// Apply Gaussian with sigma = 2
itk::simple::Gaussian filter;
Gaussian filter;
filter.SetSigma( 2 );
filter.SetSigma( 2 );
filter.SetInput( reader.getOutput() );
filter.SetInput( reader.getOutput() );


// Write out the image
// Write out the image
itk::simple::ImageFileWriter writer;
ImageFileWriter writer;
writer.SetFilename( "sample/path/to/output.png" );
writer.SetFilename( "sample/path/to/output.png" );
writer.SetInput( filter->GetOutput() );
writer.SetInput( filter->GetOutput() );
Line 76: Line 76:
<pre>
<pre>
// Open the fixed and moving images
// Open the fixed and moving images
itk::simple::ImageFileReader reader;
ImageFileReader reader;
itk::simple::Image::Pointer fixedImage = reader.execute( "path/to/fixed.jpg" );
Image::Pointer fixedImage = reader.execute( "path/to/fixed.jpg" );
itk::simple::Image::Pointer movingImage = reader.execute( "path/to/moving.jpg" );
Image::Pointer movingImage = reader.execute( "path/to/moving.jpg" );


// Register the moving image to the fixed image
// Register the moving image to the fixed image
itk::simple::AffineRegistrator registrator;
AffineRegistrator registrator;
itk::simple::AffineTransform transform;
AffineTransform transform;
transform = registrator.execute( fixedImage, movingImage );
transform = registrator.execute( fixedImage, movingImage );


// Resample the moving image
// Resample the moving image
itk::simple::Resampler resampler;
Resampler resampler;
movingImage = resampler.execute( movingImage, transform );
movingImage = resampler.execute( movingImage, transform );


// Write out the resampled image
// Write out the resampled image
itk::simple::ImageFileWriter writer;
ImageFileWriter writer;
writer.ececute( movingImage, "path/to/output.png" );
writer.ececute( movingImage, "path/to/output.png" );
</pre>
</pre>
Line 97: Line 97:
<pre>
<pre>
// Open the fixed and moving images
// Open the fixed and moving images
itk::simple::ImageFileReader reader;
ImageFileReader reader;
reader.SetFilename( "path/to/fixed.jpg" );
reader.SetFilename( "path/to/fixed.jpg" );
itk::simple::Image::Pointer fixedImage = reader.execute();
Image::Pointer fixedImage = reader.execute();
reader.SetFilename( "path/to/moving.jpg" );
reader.SetFilename( "path/to/moving.jpg" );
itk::simple::Image::Pointer movingImage = reader.execute();
Image::Pointer movingImage = reader.execute();


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


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


// Write out the resampled image
// Write out the resampled image
itk::simple::ImageFileWriter writer;
ImageFileWriter writer;
writer.SetFilename( "path/to/output.png" );
writer.SetFilename( "path/to/output.png" );
writer.ececute( movingImage );
writer.ececute( movingImage );
Line 124: Line 124:
<pre>
<pre>
// Open the fixed and moving images
// Open the fixed and moving images
itk::simple::ImageFileReader reader1;
ImageFileReader reader1;
itk::simple::ImageFileReader reader2;
ImageFileReader reader2;
reader1.SetFilename( "path/to/fixed.jpg" );
reader1.SetFilename( "path/to/fixed.jpg" );
reader2.SetFilename( "path/to/moving.jpg" );
reader2.SetFilename( "path/to/moving.jpg" );


// Register the moving image to the fixed image
// Register the moving image to the fixed image
itk::simple::AffineRegistrator registrator;
AffineRegistrator registrator;
registrator.SetFixedImage( reader1.GetOutput() );
registrator.SetFixedImage( reader1.GetOutput() );
registrator.SetMovingImage( reader2.GetOutput() );
registrator.SetMovingImage( reader2.GetOutput() );


// Resample the moving image
// Resample the moving image
itk::simple::Resampler resampler;
Resampler resampler;
resampler.SetInput( reader2.GetOutput() );
resampler.SetInput( reader2.GetOutput() );
resampler.SetTransform( registrator.GetOutput() );
resampler.SetTransform( registrator.GetOutput() );


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

Revision as of 20:17, 2 September 2010

  • 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
ImageFileReader reader;
Image::Pointer im = reader.execute( "sample/path/to/image.jpg" );

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

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

Procedural with parameter setting

// Read the image
ImageFileReader reader;
reader.SetFilename( "sample/path/to/image.jpg" );
Image::Pointer im = reader.execute();

// 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
ImageFileReader reader;
reader.SetFilename( "sample/path/to/image.jpg" );

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

// 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
ImageFileReader reader;
Image::Pointer fixedImage = reader.execute( "path/to/fixed.jpg" );
Image::Pointer movingImage = reader.execute( "path/to/moving.jpg" );

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

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

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

Procedural with parameter setting

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

// 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
ImageFileReader reader1;
ImageFileReader reader2;
reader1.SetFilename( "path/to/fixed.jpg" );
reader2.SetFilename( "path/to/moving.jpg" );

// Register the moving image to the fixed image
AffineRegistrator registrator;
registrator.SetFixedImage( reader1.GetOutput() );
registrator.SetMovingImage( reader2.GetOutput() );

// Resample the moving image
Resampler resampler;
resampler.SetInput( reader2.GetOutput() );
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();

Level Set

Region Growing

Watershed

QuadEdgeMesh