[Insight-users] ITK Image registration within Matlab -> Segmentation Violation
Patrik Brynolfsson
patrik.brynolfsson at radfys.umu.se
Tue Oct 12 10:55:39 EDT 2010
You can debug the code by attatching matlab to VS. Tools/Attatch to
process, select matlab. Then just set a break point and run the code from
matlab. Maybe that sheds some light to the problem... ?
---
Patrik Brynolfsson
2010/10/12 Guitarum <guillaume.salvai at sanofi-aventis.com>
>
> 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.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101012/e12da85f/attachment.htm>
More information about the Insight-users
mailing list