[Insight-users] Erreur de segmentation

Yoann Moreau yoann.moreau at gmail.com
Wed Sep 23 17:53:04 EDT 2009


Hi all !

I'm in trouble with famous "Erreur of segmentation", I try to read about
this problem in different post, but I 'm always still in the fog. (not sure
about that expression).

What mean that error : Erreur de segmentation
Is it due to OTB ? Gdal ( I suspect this one) ? or a misstake in the matrix
(I'm still not sure of that expression) ? or simply an error in source code
?

Anyway I'm working on a Debian Etch with Gdal version 1.5.2 and otb 3.0
Thank for explanation.


(The aim of my work is to apply a centered2rigidtransform to an image for
which I define the parameters there is my source code in case :

#include "otbImage.h"


#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"

#include "itkCenteredRigid2DTransform.h"
#include "itkResampleImageFilter.h"


int main( int argc, char *argv[] )
{
  if ( argc < 6 )
  {
    std::cerr << "Missing Parameters " << std::endl;
    std::cerr << "Usage: " << argv[0];
    std::cerr << " ImageFile ";
    std::cerr << " angle centreRotX centreRotY transX transY ";
    std::cerr << " OutputImageFile";
    std::cerr << " "<< std::endl;
    return EXIT_FAILURE;
  }


const    unsigned int    Dimension = 2;
typedef  unsigned short   PixelType;

typedef otb::Image< PixelType, Dimension >  ImageType;
typedef otb::ImageFileReader< ImageType  > ImageReaderType;

ImageReaderType::Pointer  ImageReader  = ImageReaderType::New();

ImageReader->SetFileName(  argv[1] );
ImageReader->Update();

ImageType::Pointer Image = ImageReader->GetOutput();

typedef itk::ResampleImageFilter<  ImageType,  ImageType >
ResampleFilterType;
typedef itk::CenteredRigid2DTransform< double > TransformType;


ResampleFilterType::Pointer resample = ResampleFilterType::New();

const unsigned int FinalParametersLength = 5;
typedef TransformType::ParametersType FinalParametersType;

FinalParametersType Parameters;

Parameters[0] =atoi(argv[2]);

Parameters[1] = atoi(argv[3]);

Parameters[2] = atoi(argv[4]);

Parameters[3] = atoi(argv[5]);

Parameters[4] = atoi(argv[6]);

TransformType::Pointer finalTransform = TransformType::New();
finalTransform->SetParameters( Parameters );

  std::cout << "Origin  = " << Image->GetOrigin() <<std::endl;
  std::cout << " Spacing  = " << Image->GetSpacing()  << std::endl;
  std::cout << " Size   = " << Image->GetLargestPossibleRegion().GetSize()
<< std::endl;

  resample->SetTransform( finalTransform );
  resample->SetInput( ImageReader->GetOutput() );
  resample->SetSize( Image->GetLargestPossibleRegion().GetSize() );
  resample->SetOutputOrigin(  Image->GetOrigin() );
  resample->SetOutputSpacing( Image->GetSpacing() );
  resample->SetDefaultPixelValue( 1 );

 typedef otb::ImageFileWriter < ImageType >  WriterType;
WriterType::Pointer      writer =  WriterType::New();
 writer->SetFileName( argv[7] );
  writer->SetInput( resample->GetOutput() );

  try
  {
    writer->Update();
  }
  catch ( itk::ExceptionObject & excp )
  {
    std::cerr << "ExceptionObject while writing the resampled image !" <<
std::endl;
    std::cerr << excp << std::endl;
    return EXIT_FAILURE;
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090924/62f6b347/attachment-0001.htm>


More information about the Insight-users mailing list