]> Creatis software - STMS.git/blobdiff - Lib/SpatioTemporalMeanShift/itkSTMS_BlurringSTMS.txx
- static cast for signed unsigned comparisons
[STMS.git] / Lib / SpatioTemporalMeanShift / itkSTMS_BlurringSTMS.txx
index 8dda23294f68d22d78f162114c33d79b41374739..1e37fbdb3581916f6fbad649bc4d79187477345c 100755 (executable)
@@ -60,6 +60,7 @@
 #ifndef itkSTMS_BlurringSTMS_TXX
 #define itkSTMS_BlurringSTMS_TXX
 
+#include <limits>
 #include <random>
 #include <algorithm>
 #include <iterator>
@@ -524,7 +525,7 @@ void
 itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
 ::FinalMerging()
 {
-    unsigned int size = INFINITY;
+    unsigned int size = std::numeric_limits<unsigned int>::max() - 1; // INFINITY;
     std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+STMS_NUMBERING_FORM_ONE+expDescription->imageExtension;
 
     while(size > classSet->size()){
@@ -628,7 +629,8 @@ itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
                                         idx[0] = refClass->at(m)[0]+x;
                                         idx[1] = refClass->at(m)[1]+y;
 
-                                        if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
+                                        if(   ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) )  && (idx[0]>0)
+                                            && (idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) )  && (idx[1]>0) )
                                         {
                                             if(image->GetPixel(idx) == 2)
                                             {
@@ -656,7 +658,8 @@ itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
                                         idx[0] = candClass->at(m)[0]+x;
                                         idx[1] = candClass->at(m)[1]+y;
 
-                                        if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
+                                        if(   ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 )
+                                           && ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) )
                                         {
                                             if(image->GetPixel(idx) == 1)
                                             {
@@ -691,7 +694,9 @@ itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
                                             idx[1] = refClass->at(m)[1]+y;
                                             idx[2] = refClass->at(m)[2]+z;
 
-                                            if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
+                                            if(  ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && (idx[0] > 0) &&
+                                                 ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && (idx[1] > 0) &&
+                                                 ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && (idx[2] > 0)  )
                                             {
                                                 if(image->GetPixel(idx) == 2)
                                                 {
@@ -724,7 +729,9 @@ itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
                                             idx[1] = candClass->at(m)[1]+y;
                                             idx[2] = candClass->at(m)[2]+z;
 
-                                            if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
+                                            if(   ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 ) &&
+                                                  ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) &&
+                                                  ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && ( idx[2] > 0 ) )
                                             {
                                                 if(image->GetPixel(idx) == 1)
                                                 {