[Insight-users] What does 'This class in not thread safe' mea
n exactly?
Miller, James V (Research)
millerjv at crd.ge.com
Mon Nov 29 15:28:00 EST 2004
Mark,
I do not see anything in this code that would keep you from using
separate instances of this class in different threads. I think the
message was meant to tell you that you cannot call methods of on
a single instance of the metric from multiple threads without taking
additional synchronization steps.
Jim
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Saturday, November 27, 2004 9:22 PM
To: Mark Wyszomierski
Cc: Insight-users at itk.org
Subject: Re: [Insight-users] What does 'This class in not thread safe'
mean exactly?
Hi Mark,
From the Doxygen documentation of MattesMutualInformation:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1MattesMutualInformationI
mageToImageMetric.html
>
> 2. This class in not thread safe due the private data structures used
> to the store the sampled points and the marginal and joint pdfs.
>
One of the aspects that may be causing the crashes is the fact that
this Metric uses the Random Iterator, which in its turn uses the
random number generator. You may want to experimetn with the code
that generates the random samples inside the random iterator.
These are lines 91-109 from
Insight/Code/Common/
itkImageRandomConstIteratorWithIndex.txx
they look like:
vnl_sample_uniform(0.0f,double(m_NumberOfPixelsInRegion)-0.5) );
BTW, just to double check.... are you sure that the crashes
are not actual exceptions being thrown ?
are you setting try/catch block around the computation of the
metric ?
It is not uncommon for Image Metrics to throw exceptions when
the overlap between the two images is too small.
Regards,
Luis
---------------------------
Mark Wyszomierski wrote:
> Hi all,
>
> I am trying out the MultiResImageRegistration2 example. I wrote an app
> that will use the register function in separate threads to register
> more than 1 set of images at a time.
>
> This application, when using the example in
> MultiResImageRegistration2, will crash at random points. I read in the
> itkMattesMutualInformationImageToImageMetric documentation that this
> class is not thread safe - does this mean I cannot use it in a
> multithreaded app, and perhaps this is the cause of my crashes? (I
> have been running other registration examples in multiple threads
> without problems). I don't get any errors when the registration method
> is launched, I'll just receive random crashes at random times!
>
> Thanks!
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list