[Insight-users] What does 'This class in not thread safe' mean exactly?

Luis Ibanez luis.ibanez at kitware.com
Sat Nov 27 21:22:27 EST 2004


Hi Mark,

 From the Doxygen documentation of MattesMutualInformation:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1MattesMutualInformationImageToImageMetric.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
> 
> 





More information about the Insight-users mailing list