<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2876" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=217102014-13072006>Hello,
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=217102014-13072006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=217102014-13072006>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=217102014-13072006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=217102014-13072006>Corinna</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=217102014-13072006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=217102014-13072006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=217102014-13072006>#if
defined(_MSC_VER)<BR>#pragma warning ( disable : 4786
)<BR>#endif</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=217102014-13072006>#ifdef
__BORLANDC__<BR>#define ITK_LEAN_AND_MEAN<BR>#endif</SPAN></FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2><SPAN class=217102014-13072006>
<DIV><BR>#include "itkActiveShapeModelCalculator.h"</DIV>
<DIV> </DIV>
<DIV>#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include
"itkImageFileWriter.h"<BR>#include "itkImageSeriesReader.h"<BR>#include
"itkNumericSeriesFileNames.h"<BR>#include "itkPNGImageIO.h"<BR>#include
"itkArray.h"</DIV>
<DIV> </DIV>
<DIV>#include <iostream></DIV>
<DIV> </DIV>
<DIV>// ASM Calculator<BR>// input: binary volume containing the training
shapes<BR>// output: mean shape, eigenvectors, eigenvalues</DIV>
<DIV> </DIV>
<DIV>int main( int argc, char * argv[] )<BR>{<BR> if( argc != 4
)<BR> {<BR> std::cerr << "Usage: "
<< argv[0] << " first last imgnames" <<
std::endl;<BR> return EXIT_FAILURE;<BR>
}<BR> <BR> typedef unsigned
char InputPixelType;<BR>
typedef itk::Image < InputPixelType, 3
> InputVolumeType;<BR> typedef
itk::ActiveShapeModelCalculator< InputVolumeType >
ASMCalculatorType;<BR> typedef itk::ImageSeriesReader<
InputVolumeType > SeriesReaderType;<BR> typedef
itk::NumericSeriesFileNames
NameGeneratorType;<BR> <BR> //
read 2D images and construct a volume<BR> SeriesReaderType::Pointer
seriesReader = SeriesReaderType::New();<BR> int first = atoi( argv[1]
);<BR> int last = atoi( argv[2] );<BR> NameGeneratorType::Pointer
nameGenerator = NameGeneratorType::New();<BR>
nameGenerator->SetSeriesFormat( argv[3] );<BR>
nameGenerator->SetStartIndex( first );<BR>
nameGenerator->SetEndIndex( last );<BR>
nameGenerator->SetIncrementIndex( 1 );<BR> seriesReader->SetImageIO(
itk::PNGImageIO::New() );<BR> seriesReader->SetFileNames(
nameGenerator->GetFileNames() );</DIV>
<DIV> </DIV>
<DIV> ASMCalculatorType::Pointer asm_calculator =
ASMCalculatorType::New();</DIV>
<DIV> </DIV>
<DIV> try<BR> {<BR> seriesReader->Update();<BR>
}<BR> catch ( itk::ExceptionObject & err )<BR> {<BR>
std::cerr << "Exception Object caught!" <<
std::endl;<BR> std::cerr << err << std::endl;<BR>
return EXIT_FAILURE;<BR> }</DIV>
<DIV> </DIV>
<DIV> asm_calculator->SetImage( seriesReader->GetOutput() );</DIV>
<DIV> </DIV>
<DIV> try<BR> {<BR>
asm_calculator->GenerateData();<BR> }<BR> catch (
itk::ExceptionObject & err )<BR> {<BR> std::cerr <<
"Exception Object caught!" << std::endl;<BR> std::cerr
<< err << std::endl;<BR> return EXIT_FAILURE;<BR>
}<BR> <BR> itk::Array<double> meanShape;<BR> meanShape =
asm_calculator->GetMeanShape();<BR> for ( unsigned int i=0;
i<meanShape.GetNumberOfElements(); i++ )<BR> {<BR>
std::cout << i << ": " << meanShape.GetElement(i) <<
std::endl;<BR> }</DIV>
<DIV> </DIV>
<DIV> return EXIT_SUCCESS;<BR>}<BR></SPAN></FONT></DIV></BODY></HTML>