]> Creatis software - STMS.git/commitdiff
- static cast for signed unsigned comparisons
authorThomas Greneir <thomas.grenier@insa-lyon.fr>
Tue, 19 Sep 2017 15:08:59 +0000 (17:08 +0200)
committerThomas Greneir <thomas.grenier@insa-lyon.fr>
Tue, 19 Sep 2017 15:08:59 +0000 (17:08 +0200)
- csv output file cleaned

Lib/PrePostProcessing/itkSTMS_ImageSequenceToTemporalSet.txx
Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx
Lib/SpatioTemporalMeanShift/itkSTMS_BlurringSTMS.txx
Src/STMS_GrayLevelFiltering.cxx

index ed74c3c32b1b8155ead8ff4b429afc59c5ffb73d..1f55193634d6a06e846263ed9ce405023155fc9a 100755 (executable)
@@ -120,20 +120,18 @@ itkSTMS_ImageSequenceToTemporalSet< ImageType, MaskImageType >
         idx = 0;
 
         char buffer[6];
-        int n = 0;
+        // int n = 0; // used to debug sprintf : n = sprintf( ...
 
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) n=sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) n=sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) n=sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) n=sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) n=sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
 
         std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+buffer+expDescription->imageExtension;
 
-        ImagePointer image
-                = ImageType::New();
-        ReaderPointer reader
-                = itk::ImageFileReader< ImageType >::New();
+        ImagePointer image       = ImageType::New();
+        ReaderPointer reader     = itk::ImageFileReader< ImageType >::New();
 
         reader->SetFileName( imagePath );
         reader->Update();
index 2d5131821dafa43f4ff2b394f9b137b0ed8f0e49..c988bb7b821ce23edb88557b4ca76b01be6de67d 100755 (executable)
@@ -138,13 +138,13 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
     for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
     {
         char buffer[6];
-        int n;
+         // int n;
 
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) n=sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) n=sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) n=sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) n=sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
-        if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) n=sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) sprintf( buffer, "%05d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) sprintf( buffer, "%04d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) sprintf( buffer, "%03d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) sprintf( buffer, "%02d", i + stmsParameters->startTimePoint - 1);
+        if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) sprintf( buffer, "%01d", i + stmsParameters->startTimePoint - 1);
 
         outputPath = expDescription->experimentPath+expDescription->outputFolder+
                 expDescription->outputCommonRoot+
@@ -154,15 +154,12 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
                 "_R-"+std::to_string(stmsParameters->rScale)+"_"+
                 buffer+expDescription->outputImageExtension;
 
-        ImagePointer outImage
-                = ImageType::New();
-
+        ImagePointer outImage           = ImageType::New();
         outImage->SetRegions( region );
         outImage->Allocate();
         outImage->FillBuffer( 15.0 );
 
-        WriterPointer writer
-                = WriterType::New();
+        WriterPointer writer            = WriterType::New();
         writer->SetFileName( outputPath );
 
         //#pragma omp parrallel for ...
@@ -207,13 +204,14 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
             "_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+
             "_R-"+std::to_string(stmsParameters->rScale)+".csv";
 
-    std::cout << "Writing CSV File (classID, nb of pixels, values of time serie), : " << CSVFilename << std::endl;
+    std::cout << "Writing CSV File (classID, nb of pixels, values of time serie) : " << CSVFilename << std::endl;
     std::ofstream ofs;
     ofs.open (CSVFilename.c_str(), std::ofstream::out | std::ofstream::trunc);
 
     for(unsigned int j=0 ; j<rangeSet->size() ; ++j)
     {
         ofs << j+1 << delimiter << std::count (classSet->begin(), classSet->end(), j+1);
+        ofs << delimiter << stmsParameters->startTimePoint << delimiter << stmsParameters->numTimePoints;
         for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
            ofs << delimiter << rangeSet->at(j)[i-1]*stmsParameters->rScale ;
         ofs << std::endl;
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)
                                                 {
index 6de788375fa7c36391b51c0a6653590728bb11eb..f999b5f7be4470c452f8f17f241809e8f4c47c3f 100755 (executable)
@@ -60,7 +60,7 @@
 #include <iomanip>
 #include <ctime>
 
-#define STMS_NUMBERING_FORM_ONE "001"
+#define STMS_NUMBERING_FORM_ONE "01"
 
 #include "itkImage.h"
 #include "itkSTMS_ArgumentsAnalysis.h"