<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.6003" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>Hello,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>I am using Matlab 7.10.0 (R2010a).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>I tried to attach VS to the Matlab process and run my
.mex32, but I don't have any clue ..</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>The process crashes with an Access Violation
(Exception ... (ITKCommon) in Matlab.exe ).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>I thought a library might missing whith Matlab, but the
process wouldn't run at the beginning is it?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>And as for my VS settings, they are supposed to be the same
as when it works without Matlab, but I may miss someting.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>Thanks for your help,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=633542216-12102010><FONT face=Arial
color=#0000ff size=2>Guillaume</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=fr dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> patrik.brynolfsson@gmail.com
[mailto:patrik.brynolfsson@gmail.com] <B>On Behalf Of </B>Patrik
Brynolfsson<BR><B>Sent:</B> Tuesday, October 12, 2010 5:42 PM<BR><B>To:</B>
Salvai, Guillaume R&D/FR<BR><B>Cc:</B>
insight-users@itk.org<BR><B>Subject:</B> Re: [Insight-users] ITK Image
registration within Matlab -> Segmentation Violation<BR></FONT><BR></DIV>
<DIV></DIV>Your code doesn't crash for me, maybe there is something wrong with
your VS settings? What version of Matlab are you using?<BR
clear=all>--- <BR>Patrik Brynolfsson<BR><BR><BR><BR><BR>
<DIV class=gmail_quote>2010/10/12 Patrik Brynolfsson <SPAN dir=ltr><<A
href="mailto:patrik.brynolfsson@radfys.umu.se">patrik.brynolfsson@radfys.umu.se</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV class=im><SPAN
style="FONT-SIZE: 13px; FONT-FAMILY: arial, sans-serif; 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>
<DIV class=gmail_quote>
<DIV class=im>2010/10/12 Guitarum <SPAN dir=ltr><<A
href="mailto:guillaume.salvai@sanofi-aventis.com"
target=_blank>guillaume.salvai@sanofi-aventis.com</A>></SPAN><BR></DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><BR>
<DIV>
<DIV></DIV>
<DIV class=h5>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></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></DIV><BR></BODY></HTML>