Hi all !<br><br>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).<br><br>What mean that error : Erreur de segmentation<br>
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 ?<br><br>Anyway I'm working on a Debian Etch with Gdal version 1.5.2 and otb 3.0<br>
Thank for explanation.<br><br><br>(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 :<br><br>#include "otbImage.h"<br><br><br>
#include "otbImageFileReader.h"<br>#include "otbImageFileWriter.h"<br><br>#include "itkCenteredRigid2DTransform.h"<br>#include "itkResampleImageFilter.h"<br><br><br>int main( int argc, char *argv[] )<br>
{<br> if ( argc < 6 )<br> {<br> std::cerr << "Missing Parameters " << std::endl;<br> std::cerr << "Usage: " << argv[0];<br> std::cerr << " ImageFile ";<br>
std::cerr << " angle centreRotX centreRotY transX transY ";<br> std::cerr << " OutputImageFile";<br> std::cerr << " "<< std::endl;<br> return EXIT_FAILURE;<br>
}<br><br><br>const unsigned int Dimension = 2;<br>typedef unsigned short PixelType;<br><br>typedef otb::Image< PixelType, Dimension > ImageType;<br>typedef otb::ImageFileReader< ImageType > ImageReaderType;<br>
<br>ImageReaderType::Pointer ImageReader = ImageReaderType::New();<br><br>ImageReader->SetFileName( argv[1] );<br>ImageReader->Update();<br><br>ImageType::Pointer Image = ImageReader->GetOutput();<br><br>typedef itk::ResampleImageFilter< ImageType, ImageType > ResampleFilterType;<br>
typedef itk::CenteredRigid2DTransform< double > TransformType;<br> <br><br>ResampleFilterType::Pointer resample = ResampleFilterType::New();<br><br>const unsigned int FinalParametersLength = 5;<br>typedef TransformType::ParametersType FinalParametersType;<br>
<br>FinalParametersType Parameters;<br><br>Parameters[0] =atoi(argv[2]);<br><br>Parameters[1] = atoi(argv[3]);<br><br>Parameters[2] = atoi(argv[4]);<br><br>Parameters[3] = atoi(argv[5]);<br><br>Parameters[4] = atoi(argv[6]);<br>
<br>TransformType::Pointer finalTransform = TransformType::New();<br>finalTransform->SetParameters( Parameters );<br><br> std::cout << "Origin = " << Image->GetOrigin() <<std::endl;<br>
std::cout << " Spacing = " << Image->GetSpacing() << std::endl;<br> std::cout << " Size = " << Image->GetLargestPossibleRegion().GetSize() << std::endl;<br>
<br> resample->SetTransform( finalTransform );<br> resample->SetInput( ImageReader->GetOutput() );<br> resample->SetSize( Image->GetLargestPossibleRegion().GetSize() );<br> resample->SetOutputOrigin( Image->GetOrigin() );<br>
resample->SetOutputSpacing( Image->GetSpacing() );<br> resample->SetDefaultPixelValue( 1 );<br><br> typedef otb::ImageFileWriter < ImageType > WriterType;<br>WriterType::Pointer writer = WriterType::New();<br>
writer->SetFileName( argv[7] );<br> writer->SetInput( resample->GetOutput() );<br><br> try<br> {<br> writer->Update();<br> }<br> catch ( itk::ExceptionObject & excp )<br> {<br> std::cerr << "ExceptionObject while writing the resampled image !" << std::endl;<br>
std::cerr << excp << std::endl;<br> return EXIT_FAILURE;<br> }<br>