[Insight-users] ITK Image registration within Matlab -> Segmentation Violation
Guitarum
guillaume.salvai at sanofi-aventis.com
Tue Oct 12 03:48:00 EDT 2010
Hello everybody,
I'am attempting to perform an image registration using ITK.
First of all, I've done it within Visual Studio, and it works perfectly.
Now, I simply want to implement this within Matlab, using mexFunction.
I copy what I had done, with no input/output argument for the mexFunction.
I added the useful include files and libraries, and it compiles well.
However, I got a Segmentation Violation while running the programme .mex32
Then I investigate and the problem seems to come from a itkImageRegistration
object.
Here is a code which sheds light on the problem that I didn't manage to
handle .. (it isn't my entire code, but the rest works well). I comment it
explaining the tests I've done.
/* BEGINNING */
// MEX
#include "mex.h"
// ITK
#include "itkTranslationTransform.h"
#include "itkMattesMutualInformationImageToImageMetric.h"
#include "itkImageRegistrationMethod.h"
const unsigned int Dimension = 3;
typedef unsigned char PixelType;
typedef float InternalPixelType;
typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
typedef itk::MattesMutualInformationImageToImageMetric< InternalImageType,
InternalImageType > MetricType;
typedef itk::TranslationTransform< double, Dimension> TransformType;
typedef itk::ImageRegistrationMethod< InternalImageType , InternalImageType
> RegistrationType;
// The program entry point
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
mexPrintf("Begin !\n");
// Test of MetricType. It exists and the function
SetNumberOfHistogramBins works.
MetricType::Pointer metric = MetricType::New();
metric->SetNumberOfHistogramBins( 50 );
// Test of transformType. OK.
TransformType::Pointer transform = TransformType::New();
TransformType::ParametersType testTransf(3);
testTransf[0]=1;
testTransf[1]=2;
testTransf[2]=3;
transform->SetParameters(testTransf);
mexPrintf("OK1 !\n");
// That part doesn't crash. So I guess RegistrationType is correctly
define.
RegistrationType::ParametersType testReg(3);
testReg[0]=1;
testReg[1]=2;
testReg[2]=3;
mexPrintf("OK2 !\n");
// It crashes here ! Segmentation Violation.
RegistrationType::Pointer reg = RegistrationType::New();
}
/*END*/
I found that the last code line crashes, although it is a basic object
creation.
Furthermore, it works for TransformType and MetricType, and those are very
similar to Registration Type.
I'm somehow a newbie with ITK, so it might be a basic mistake. But I can't
find it, besides it works within VC++ ...
Does anybody have an idea? I'll be very grateful for any help.
Thanks very much in advance,
Guillaume
--
View this message in context: http://old.nabble.com/ITK-Image-registration-within-Matlab--%3E-Segmentation-Violation-tp29940926p29940926.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list