[Insight-users] ITK Image registration within Matlab -> Segmentation Violation

Guillaume.Salvai at sanofi-aventis.com Guillaume.Salvai at sanofi-aventis.com
Tue Oct 12 12:31:36 EDT 2010


Hello,
 
I am using Matlab 7.10.0 (R2010a).
I tried to attach VS to the Matlab process and run my .mex32, but I
don't have any clue ..
The process crashes with an Access Violation (Exception ... (ITKCommon)
in Matlab.exe ).
 
I thought a library might missing whith Matlab, but the process wouldn't
run at the beginning is it?
And as for my VS settings, they are supposed to be the same as when it
works without Matlab, but I may miss someting.
 
Thanks for your help,
Guillaume

________________________________

From: patrik.brynolfsson at gmail.com [mailto:patrik.brynolfsson at gmail.com]
On Behalf Of Patrik Brynolfsson
Sent: Tuesday, October 12, 2010 5:42 PM
To: Salvai, Guillaume R&D/FR
Cc: insight-users at itk.org
Subject: Re: [Insight-users] ITK Image registration within Matlab ->
Segmentation Violation


Your code doesn't crash for me, maybe there is something wrong with your
VS settings? What version of Matlab are you using?
--- 
Patrik Brynolfsson





2010/10/12 Patrik Brynolfsson <patrik.brynolfsson at radfys.umu.se>


	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-Segmenta
tion-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/88dd0634/attachment.htm>


More information about the Insight-users mailing list