/* # # File : STMS_GrayLevelFiltering.cxx # ( C++ example file - STMS ) # # Description : STMS lib that implements the STMS filter and clustering. # This file is a part of the STMS Library project. # ( https://www.creatis.insa-lyon.fr/site7/fr/realisations ) # # [1] S. Mure, Grenier, T., Meier, S., Guttmann, R. G., et Benoit-Cattin, H., # « Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification », # Pattern Recognition Letters, vol. 68, Part 1, p. 48 - 55, 2015. # # Copyright : Thomas GRENIER - Simon MURE # ( https://www.creatis.insa-lyon.fr/~grenier/ ) # # License : CeCILL V2.1 # ( http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt) # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # */ /* Please don't forget to cite our work : @article {MURE-15a, title = {Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification}, journal = {Pattern Recognition Letters}, volume = {68, Part 1}, year = {2015}, pages = {48 - 55}, issn = {0167-8655}, doi = {http://dx.doi.org/10.1016/j.patrec.2015.07.021}, url = {http://www.sciencedirect.com/science/article/pii/S0167865515002305}, author = {S. Mure and T Grenier and Meier, S. and Guttmann, R.G. and H. Benoit-Cattin} } */ #include #include #define STMS_NUMBERING_FORM_ONE "0001" #include "itkImage.h" #include "itkSTMS_ArgumentsAnalysis.h" #include "itkSTMS_ImageSequenceToTemporalSet.h" #include "itkSTMS_TemporalSetToImageSequence.h" #include "itkSTMS_BlurringSTMS.h" #include typedef float PixelType; typedef unsigned char OutputPixelType2D; typedef float OutputPixelType3D; double gettime_hp() { struct timespec timestamp; clock_gettime(CLOCK_REALTIME, ×tamp); return timestamp.tv_sec * 1000.0 + timestamp.tv_nsec * 1.0e-6; } // Only --expDescription and numTimePoints parameter are compulsory. //--expDescription /run/media/mure/HDD/Recherche/These/CVS/Mure/Dev/Cpp/itkSTMS/Data/P43_Parser.xml --imageDimension 2 --xScale 20 --yScale 20 --rScale 1 --epsilon 0.1 --maxIt 20 --numTimePoints 25 --merge //--expDescription /run/media/mure/HDD/Recherche/These/CVS/Mure/Dev/Cpp/itkSTMS/Data/L43_3_Parser.xml --imageDimension 3 --xScale 1000 --yScale 1000 --zScale 1000 --rScale 0.75 --epsilon 0.1 --maxIt 50 --numTimePoints 25 --merge //--expDescription /run/media/mure/HDD/Recherche/These/CVS/Mure/Dev/Cpp/itkSTMS/Data/Simu_Parser.xml --imageDimension 2 --xScale 255 --yScale 255 --rScale 0.4 --epsilon 0.01 --maxIt 50 --numTimePoints 8 //--expDescription /run/media/mure/HDD/Recherche/These/CVS/Mure/Dev/Cpp/itkSTMS/Data/G1_Parser.xml --imageDimension 3 --xScale 1000 --yScale 1000 --zScale 1000 --rScale 0.15 --epsilon 0.01 --maxIt 50 --numTimePoints 8 // --expDescription E:/Documents/Creatis/Projets/15_MUST/Data_Cardiac/Parser_AIF_Cardiac.xml --imageDimension 2 --xScale 10 --yScale 10 --rScale 10 --numTimePoints 80 int main(int argc, char **argv){ double dtime; std::cout << "The Numbering form is set to numbers like = " << STMS_NUMBERING_FORM_ONE << std::endl; std::cout << "size : " << sizeof(STMS_NUMBERING_FORM_ONE) << std::endl; itkSTMS::itkSTMS_ArgumentsAnalysis* argsAnalysis = new itkSTMS::itkSTMS_ArgumentsAnalysis(argc, argv); argsAnalysis->Update(); itkSTMS::ParamsAnalysisOutputType* params = argsAnalysis->GetSTMSParams(); switch(params->dim){ case 2: { typedef itk::Image< PixelType, 2 > ImageType2D; typedef itk::Image< OutputPixelType2D, 2 > OutputImageType2D; typedef itk::Image< unsigned char, 2 > MaskImageType2D; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::IndexType IndexType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::SpatialType SpatialType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::IndexSampleSetType IndexSampleSetType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::SpatialSampleSetType SpatialSampleSetType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::RangeSampleSetType RangeSampleSetType; typedef itk::Image< IndexType, 2 > ClassImageType2D; dtime=gettime_hp(); itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >* preProcess = new itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D > ( params ); preProcess->GenerateDataSets(); dtime = gettime_hp()-dtime; std::cout<GetIndexSet(); IndexSampleSetType* classSet = preProcess->GetClassSet(); IndexSampleSetType* weightsSet = preProcess->GetWeightsSet(); SpatialSampleSetType* spatialSet = preProcess->GetSpatialSet(); RangeSampleSetType* rangeSet = preProcess->GetRangeSet(); dtime=gettime_hp(); itkSTMS::itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType2D >* stmsFilter = new itkSTMS::itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType2D > (indexSet, classSet, weightsSet, spatialSet, rangeSet, params, preProcess->GetExperimentDescription()); stmsFilter->GenerateData(); dtime = gettime_hp()-dtime; std::cout<* postProcess = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType2D, ClassImageType2D, OutputImageType2D>(stmsFilter->GetClassMemory(), stmsFilter->GetSpatialMemory(), stmsFilter->GetRangeSet(), params, preProcess->GetExperimentDescription()); postProcess->GenerateImageSequence(); if(preProcess->GetExperimentDescription()->outputCSV == "true" ) postProcess->GenerateCSVFile(); dtime = gettime_hp()-dtime; std::cout< ImageType3D; typedef itk::Image< OutputPixelType3D, 3 > OutputImageType3D; typedef itk::Image< unsigned char, 3 > MaskImageType3D; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::IndexType IndexType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::SpatialType SpatialType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::IndexSampleSetType IndexSampleSetType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::SpatialSampleSetType SpatialSampleSetType; typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::RangeSampleSetType RangeSampleSetType; dtime=gettime_hp(); itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >* preProcess = new itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D > ( params ); preProcess->GenerateDataSets(); dtime = gettime_hp()-dtime; std::cout<GetIndexSet(); IndexSampleSetType* classSet = preProcess->GetClassSet(); IndexSampleSetType* weightsSet = preProcess->GetWeightsSet(); SpatialSampleSetType* spatialSet = preProcess->GetSpatialSet(); RangeSampleSetType* rangeSet = preProcess->GetRangeSet(); dtime=gettime_hp(); itkSTMS::itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType3D >* stmsFilter = new itkSTMS::itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType3D > (indexSet, classSet, weightsSet, spatialSet, rangeSet, params, preProcess->GetExperimentDescription()); stmsFilter->GenerateData(); dtime = gettime_hp()-dtime; std::cout<* postProcess = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType3D, MaskImageType3D, OutputImageType3D >(stmsFilter->GetClassMemory(), stmsFilter->GetSpatialMemory(), stmsFilter->GetRangeSet(), params, preProcess->GetExperimentDescription()); postProcess->GenerateImageSequence(); if(preProcess->GetExperimentDescription()->outputCSV == "true" ) postProcess->GenerateCSVFile(); dtime = gettime_hp()-dtime; std::cout<