[Insight-users] Active Shape Model

amine kabous aminek86 at hotmail.com
Tue Nov 20 16:56:26 EST 2007


Hello, i want to use active shape model for segmentation of medical Image 2d. for constructing a volume itk::ImageSeriesReader. the programm compile fine, but it crash in run time, it tell me that   BMPImageIO could not open file c:\130.bmp for reading.please find my program, and if you have any suggestion, telle it to meThanks #include "itkActiveShapeModelCalculator.h"#include "itkImage.h"#include "itkImageFileReader.h"#include "itkImageFileWriter.h"#include "itkImageSeriesReader.h"#include "itkNumericSeriesFileNames.h"#include "itkBMPImageIO.h"#include "itkArray.h"#include "itkActiveShapeModelGradientSearchMethod.h"#include <iostream> using namespace std; int main( int argc, char * argv[] ){typedef unsigned char InputPixelType;typedef itk::Image < InputPixelType, 3 > InputVolumeType;typedef itk::Image< unsigned char, 2 > Image2DType;typedef itk::ActiveShapeModelCalculator< InputVolumeType > ASMCalculatorType;typedef itk::ImageSeriesReader< InputVolumeType > SeriesReaderType;typedef itk::NumericSeriesFileNames NameGeneratorType;SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();nameGenerator->SetSeriesFormat( "c:\\130.bmp" );nameGenerator->SetStartIndex( 1 );nameGenerator->SetEndIndex( 2 );nameGenerator->SetIncrementIndex( 1 );seriesReader->SetFileNames( nameGenerator->GetFileNames()); seriesReader->SetImageIO( itk::BMPImageIO::New() );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();vnl_vector<double> eigenValues = asm_calculator->GetEigenvalues();vnl_matrix<double> eigenVectors = asm_calculator->GetEigenvector();for ( unsigned int i=0; i<meanShape.GetNumberOfElements(); i++ ){std::cout << i << ": " << meanShape.GetElement(i) << std::endl;}std::cout << "Vecteurs Propres:" << std::endl;for(unsigned int i = 0; i < eigenVectors.rows(); i++) {std::cout<< eigenVectors.get_row(i)<<" ";} std::cout <<""<<std::endl;cout << "Valeurs Propres:" << endl;cout << eigenValues << endl;typedef itk::ActiveShapeModelGradientSearchMethod< Image2DType> ImageSearchType;ImageSearchType::Pointer ImageSearch = ImageSearchType::New();const unsigned int m_LenghtOfProfile = 3;const unsigned int m_NumberOfIteration = 2;typedef itk::ImageFileReader< Image2DType > Reader2DType;Reader2DType::Pointer reader1 = Reader2DType::New();const char * input2DFilename = argv[2];reader1->SetFileName( input2DFilename );reader1->Update( );ImageSearch->SetImage( reader1->GetOutput() );ImageSearch->SetLenghtOfProfile( m_LenghtOfProfile );ImageSearch->SetNumberOfIteration( m_NumberOfIteration );ImageSearch->SetMeanShape( asm_calculator->GetMeanShape() + 0.5);ImageSearch->SetEigenValues( asm_calculator->GetEigenvalues() );ImageSearch->SetEigenVectors( asm_calculator->GetEigenvector() );ImageSearch->GenerateData();ImageSearch->Print(std::cout);typedef ImageSearchType::Superclass GenericEstimator2Type;std::cout << ImageSearch->GenericEstimator2Type::GetNameOfClass() << std::endl;cout << "The new shape: " <<ImageSearch->GetNewShape() <<endl;return EXIT_SUCCESS;} Téléchargez le nouveau Windows Live Messenger ! Essayez-le ! 
_________________________________________________________________
Téléchargez le nouveau Windows Live Messenger !
http://get.live.com/messenger/overview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071120/bf04a327/attachment.html


More information about the Insight-users mailing list