<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">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... ?</span><br clear="all">
---<br>Patrik Brynolfsson<br><br><br>
<br><br><div class="gmail_quote">2010/10/12 Guitarum <span dir="ltr"><<a href="mailto:guillaume.salvai@sanofi-aventis.com">guillaume.salvai@sanofi-aventis.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hello everybody,<br>
<br>
I'am attempting to perform an image registration using ITK.<br>
First of all, I've done it within Visual Studio, and it works perfectly.<br>
<br>
Now, I simply want to implement this within Matlab, using mexFunction.<br>
I copy what I had done, with no input/output argument for the mexFunction.<br>
I added the useful include files and libraries, and it compiles well.<br>
However, I got a Segmentation Violation while running the programme .mex32<br>
<br>
Then I investigate and the problem seems to come from a itkImageRegistration<br>
object.<br>
Here is a code which sheds light on the problem that I didn't manage to<br>
handle .. (it isn't my entire code, but the rest works well). I comment it<br>
explaining the tests I've done.<br>
<br>
/* BEGINNING */<br>
<br>
// MEX<br>
#include "mex.h"<br>
<br>
// ITK<br>
#include "itkTranslationTransform.h"<br>
#include "itkMattesMutualInformationImageToImageMetric.h"<br>
#include "itkImageRegistrationMethod.h"<br>
<br>
<br>
const unsigned int Dimension = 3;<br>
typedef unsigned char PixelType;<br>
typedef float InternalPixelType;<br>
<br>
typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br>
typedef itk::MattesMutualInformationImageToImageMetric< InternalImageType,<br>
InternalImageType > MetricType;<br>
typedef itk::TranslationTransform< double, Dimension> TransformType;<br>
typedef itk::ImageRegistrationMethod< InternalImageType , InternalImageType<br>
> RegistrationType;<br>
<br>
<br>
// The program entry point<br>
void mexFunction(int nlhs, mxArray *plhs[],<br>
int nrhs, const mxArray *prhs[])<br>
{<br>
<br>
mexPrintf("Begin !\n");<br>
<br>
// Test of MetricType. It exists and the function<br>
SetNumberOfHistogramBins works.<br>
MetricType::Pointer metric = MetricType::New();<br>
metric->SetNumberOfHistogramBins( 50 );<br>
<br>
// Test of transformType. OK.<br>
TransformType::Pointer transform = TransformType::New();<br>
TransformType::ParametersType testTransf(3);<br>
testTransf[0]=1;<br>
testTransf[1]=2;<br>
testTransf[2]=3;<br>
transform->SetParameters(testTransf);<br>
<br>
mexPrintf("OK1 !\n");<br>
<br>
// That part doesn't crash. So I guess RegistrationType is correctly<br>
define.<br>
RegistrationType::ParametersType testReg(3);<br>
testReg[0]=1;<br>
testReg[1]=2;<br>
testReg[2]=3;<br>
<br>
mexPrintf("OK2 !\n");<br>
<br>
// It crashes here ! Segmentation Violation.<br>
RegistrationType::Pointer reg = RegistrationType::New();<br>
<br>
}<br>
<br>
/*END*/<br>
<br>
I found that the last code line crashes, although it is a basic object<br>
creation.<br>
Furthermore, it works for TransformType and MetricType, and those are very<br>
similar to Registration Type.<br>
<br>
I'm somehow a newbie with ITK, so it might be a basic mistake. But I can't<br>
find it, besides it works within VC++ ...<br>
Does anybody have an idea? I'll be very grateful for any help.<br>
<br>
Thanks very much in advance,<br>
Guillaume<br>
<br>
--<br>
View this message in context: <a href="http://old.nabble.com/ITK-Image-registration-within-Matlab--%3E-Segmentation-Violation-tp29940926p29940926.html" target="_blank">http://old.nabble.com/ITK-Image-registration-within-Matlab--%3E-Segmentation-Violation-tp29940926p29940926.html</a><br>
Sent from the ITK - Users mailing list archive at Nabble.com.<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>