Dear MITK users,

the mitkCalculateGrayValueStatisticsTool throws an itk warning after use (I'm using ITK 3.4), because the itk::MapContainer (histogram) is not created using New().

WARNING: In ..\..\..\src\InsightToolkit-3.4.0\Code\Common\itkLightObject.cxx, line 203 LightObject (00E4EFFC): Trying to delete object with non-zero reference count.

Attached there is a patch that adjusts the code for using the container as an itk::Pointer.

Best,
Marius
Index: Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp
===================================================================
--- Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp  (revision 15934)
+++ Core/Interactions/mitkCalculateGrayValueStatisticsTool.cpp  (working copy)
@@ -157,7 +157,7 @@
   typedef itk::MapContainer<TPixel, long int> HistogramType;
   TPixel minimum = std::numeric_limits<TPixel>::max();
   TPixel maximum = std::numeric_limits<TPixel>::min();
-  HistogramType histogram;
+  HistogramType::Pointer histogram = HistogramType::New();
     
   double mean(0.0);
   double sd(0.0);
@@ -179,7 +179,7 @@
 
       if ( segmentationIterator.Get() > 0 )
       {
-        ++histogram[referenceIterator.Get()];
+        ++(*histogram)[referenceIterator.Get()];
         if (referenceIterator.Get() < minimum) minimum = 
referenceIterator.Get();
         if (referenceIterator.Get() > maximum) maximum = 
referenceIterator.Get();
       
@@ -224,8 +224,8 @@
   // evaluate histogram, generate quantiles
   long int totalCount(0);
 
-  for ( typename HistogramType::iterator iter = histogram.begin();
-        iter != histogram.end();
+  for ( typename HistogramType::iterator iter = histogram->begin();
+        iter != histogram->end();
         ++iter )
   {
     totalCount += iter->second;
@@ -242,8 +242,8 @@
 
   double relativeCurrentCount(0.0);
 
-  for ( typename HistogramType::iterator iter = histogram.begin();
-        iter != histogram.end();
+  for ( typename HistogramType::iterator iter = histogram->begin();
+        iter != histogram->end();
         ++iter )
   {
     TPixel grayvalue = iter->first;
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to