[Insight-users] weird landmarks for Active Shape Model

Buerger, Corinna (ext) corinna.buerger.ext at siemens.com
Thu Jul 13 10:35:35 EDT 2006


Hello, 
 
I want to use Active Shape models for segmentation tasks. Unfortunately,
I didn't find too much information on the image type required by
itk::ActiveShapeModelCalculator. I use itk::ImageSeriesReader for
constructing a volume. The program compiles and runs fine. Only trouble
is that the calculated mean shape vector contains really strange
landmarks. I tried it out for very small png-images (2 colors)
containing a simple rectangle each. Below, please find my code. Any help
on understanding these weird effects would be highly appreciated.
 
Corinna
 
 
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
 
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
 

#include "itkActiveShapeModelCalculator.h"
 
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImageSeriesReader.h"
#include "itkNumericSeriesFileNames.h"
#include "itkPNGImageIO.h"
#include "itkArray.h"
 
#include <iostream>
 
// ASM Calculator
// input: binary volume containing the training shapes
// output: mean shape, eigenvectors, eigenvalues
 
int main( int argc, char * argv[] )
{
  if( argc != 4 )
    {
    std::cerr << "Usage: " << argv[0] << " first last imgnames" <<
std::endl;
    return EXIT_FAILURE;
    }
  
  typedef unsigned char           InputPixelType;
  typedef itk::Image < InputPixelType,  3 >      InputVolumeType;
  typedef itk::ActiveShapeModelCalculator< InputVolumeType >
ASMCalculatorType;
  typedef itk::ImageSeriesReader< InputVolumeType >
SeriesReaderType;
  typedef itk::NumericSeriesFileNames          NameGeneratorType;
  
  // read 2D images and construct a volume
  SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();
  int first = atoi( argv[1] );
  int last = atoi( argv[2] );
  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
  nameGenerator->SetSeriesFormat( argv[3] );
  nameGenerator->SetStartIndex( first );
  nameGenerator->SetEndIndex( last );
  nameGenerator->SetIncrementIndex( 1 );
  seriesReader->SetImageIO( itk::PNGImageIO::New() );
  seriesReader->SetFileNames( nameGenerator->GetFileNames() );
 
  ASMCalculatorType::Pointer asm_calculator = ASMCalculatorType::New();
 
  try
  {
   seriesReader->Update();
  }
  catch ( itk::ExceptionObject & err )
  {
   std::cerr << "Exception Object caught!" << std::endl;
   std::cerr << err << std::endl;
   return EXIT_FAILURE;
  }
 
  asm_calculator->SetImage( seriesReader->GetOutput() );
 
  try
  {
    asm_calculator->GenerateData();
  }
  catch ( itk::ExceptionObject & err )
  {
   std::cerr << "Exception Object caught!" << std::endl;
   std::cerr << err << std::endl;
   return EXIT_FAILURE;
  }
  
  itk::Array<double> meanShape;
  meanShape = asm_calculator->GetMeanShape();
  for ( unsigned int i=0; i<meanShape.GetNumberOfElements(); i++ )
  {
    std::cout << i << ": " << meanShape.GetElement(i) << std::endl;
  }
 
  return EXIT_SUCCESS;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060713/2298043f/attachment.html


More information about the Insight-users mailing list