X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Lib%2FPrePostProcessing%2FitkSTMS_TemporalSetToImageSequence.txx;fp=Lib%2FPrePostProcessing%2FitkSTMS_TemporalSetToImageSequence.txx;h=115918763c8368d28107ba013fb5d0bac3d73e15;hb=52d9a4ff6a971908206fcb9bed99942480de4ef8;hp=2d5131821dafa43f4ff2b394f9b137b0ed8f0e49;hpb=bd84bb06e5d774db2969d836670bddefbed6a1b9;p=STMS.git diff --git a/Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx b/Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx index 2d51318..1159187 100755 --- a/Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx +++ b/Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx @@ -67,8 +67,8 @@ namespace itkSTMS { -template < class ImageType, class ClassImageType > -itkSTMS_TemporalSetToImageSequence < ImageType, ClassImageType > +template < class ImageType, class ClassImageType, class OutputImageType> +itkSTMS_TemporalSetToImageSequence < ImageType, ClassImageType, OutputImageType > ::itkSTMS_TemporalSetToImageSequence( IndexSampleSetType* cl, SpatialSampleSetType* sp, RangeSampleSetType* ra, itkSTMS::ParamsAnalysisOutputType* params, itkSTMS::ParserOutputType* desc ) { @@ -81,9 +81,9 @@ itkSTMS_TemporalSetToImageSequence < ImageType, ClassImageType > } -template < class ImageType, class ClassImageType > +template < class ImageType, class ClassImageType, class OutputImageType > void -itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > +itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType, OutputImageType > ::GenerateImageSequence() { bool first = true; @@ -114,9 +114,7 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > std::string outputPath, classPath; - ClassImagePointer classImage - = ClassImageType::New(); - + ClassImagePointer classImage = ClassImageType::New(); classImage->SetRegions( classRegion ); classImage->Allocate(); classImage->FillBuffer( 15.0 ); @@ -128,23 +126,22 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > "_Y-"+std::to_string((unsigned int)stmsParameters->spScales[1])+ "_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+ "_R-"+std::to_string(stmsParameters->rScale)+ - expDescription->outputImageExtension; + expDescription->outputClassExtension; - ClassWriterPointer classWriter - = ClassWriterType::New(); + ClassWriterPointer classWriter = ClassWriterType::New(); classWriter->SetFileName( classPath ); // Filetered image sequence and class image saving 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 +151,14 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > "_R-"+std::to_string(stmsParameters->rScale)+"_"+ buffer+expDescription->outputImageExtension; - ImagePointer outImage - = ImageType::New(); + + typename OutputImageType::Pointer outImage = OutputImageType::New(); outImage->SetRegions( region ); outImage->Allocate(); - outImage->FillBuffer( 15.0 ); + outImage->FillBuffer( 0 ); - WriterPointer writer - = WriterType::New(); + WriterPointer writer = WriterType::New(); writer->SetFileName( outputPath ); //#pragma omp parrallel for ... @@ -176,7 +172,7 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > classIndex[k] = outIndex[k]; } - outImage->SetPixel( outIndex, rangeSet->at( classSet->at(j)-1 )[i-1]*stmsParameters->rScale ); + outImage->SetPixel( outIndex, static_cast(rangeSet->at( classSet->at(j)-1 )[i-1]*stmsParameters->rScale) ); if( first ) classImage->SetPixel(classIndex, classSet->at(j)); @@ -195,9 +191,9 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > } -template < class ImageType, class ClassImageType> +template < class ImageType, class ClassImageType, class OutputImageType> void -itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType > +itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType, OutputImageType> ::GenerateCSVFile(const std::string &delimiter) { std::string CSVFilename = expDescription->experimentPath+expDescription->outputFolder+ @@ -207,13 +203,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 ; jsize() ; ++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;