/* # # File : itkSTMS_ArgumentsAnalysis.hxx # ( C++ header 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 C # ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-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} } */ #ifndef itkSTMS_ArgumentsAnalysis_HXX #define itkSTMS_ArgumentsAnalysis_HXX #include #include #include "itkSTMS_ArgumentsAnalysis.h" namespace itkSTMS { itkSTMS_ArgumentsAnalysis::itkSTMS_ArgumentsAnalysis(int argc, char **argv) { readParams.expDescription = ""; readParams.numTimePoints = 0; readParams.startTimePoint = 1; readParams.epsilon = 0.01; readParams.maxIt = 100 ; readParams.spScales[0] = 1.0; readParams.spScales[1] = 1.0; readParams.spScales[2] = 1.0; readParams.rScale = 1.0; readParams.dim = 3; readParams.merge = false; readParams.help = ""; readParams.isOk = false; this->argc = argc; this->argv = argv; } void itkSTMS_ArgumentsAnalysis::ParametersDisplay() { std::cout << std::endl << std::setw(29) << std::left << "Experiment description" << ": " << readParams.expDescription << std::endl; std::cout << std::setw(29) << std::left << "Image dimension" << ": " << readParams.dim << std::endl; std::cout << std::setw(29) << std::left << "Number of time-points" << ": " << readParams.numTimePoints << std::endl; std::cout << std::setw(29) << std::left << "Staring time point" << ": " << readParams.startTimePoint << std::endl; std::cout << std::setw(29) << std::left << "X scale" << ": " << readParams.spScales[0] << std::endl; std::cout << std::setw(29) << std::left << "Y scale" << ": " << readParams.spScales[1] << std::endl; std::cout << std::setw(29) << std::left << "Z scale" << ": " << readParams.spScales[2] << std::endl; std::cout << std::setw(29) << std::left << "Range scale" << ": " << readParams.rScale << std::endl; std::cout << std::setw(29) << std::left << "Epsilon" << ": " << readParams.epsilon << std::endl; std::cout << std::setw(29) << std::left << "Maximum number of iterations" << ": " << readParams.maxIt << std::endl; std::cout << std::setw(29) << std::left << "Samples merging" << ": " << readParams.merge << std::endl << std::endl; } void itkSTMS_ArgumentsAnalysis::ParametersAnalysisInfo() { std::cout << std::endl << std::setw(17) << std::left << "--expDescription" << ": Path to the XML file used to generate the image sequence." << std::endl; std::cout << std::setw(17) << std::left << "--imageDimension" << ": Number of spatial components. (Default 3)" << std::endl; std::cout << std::setw(17) << std::left << "--numTimePoints" << ": Number of time-points." << std::endl; std::cout << std::setw(17) << std::left << "--startTimePoint" << ": Starting time point (default is 0)" << std::endl; std::cout << std::setw(17) << std::left << "--xScale" << ": Spatial scale used for the x axis. (Default 1.0)" << std::endl; std::cout << std::setw(17) << std::left << "--yScale" << ": Spatial scale used for the z axis. (Default 1.0)" << std::endl; std::cout << std::setw(17) << std::left << "--zScale" << ": Spatial scale used for the z axis. Optional when using 2D images. (Default 1.0)" << std::endl; std::cout << std::setw(17) << std::left << "--rScale" << ": Range scale used to set the tolerance on the infinity norm. (Default 1.0)" << std::endl; std::cout << std::setw(17) << std::left << "--epsilon" << ": Stopping criteria of the STM-S procedure. Minimum global displacement of the samples. (Default 0.01)" << std::endl; std::cout << std::setw(17) << std::left << "--maxIt" << ": Maximum number of iterations of the STM-S procedure. (Default 100)" << std::endl << std::endl; std::cout << std::setw(17) << std::left << "--merge" << ": Specify if the samples are merged during the STMS procedure. No merging by default, no argument is needed after --merge." << std::endl << std::endl; std::cout << std::setw(17) << std::left << "--help" << ": Usage help" << std::endl << std::endl; } void itkSTMS_ArgumentsAnalysis::CheckProvidedParameters(){ if( readParams.expDescription != "") readParams.isOk = true; } void itkSTMS_ArgumentsAnalysis::Update() { int c; bool first_it = true; while (1) { /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "d:i::n:x::y::z::r::e::m::g::h::s::", long_options, &option_index); std::string str; switch (c) { case 'd': readParams.expDescription = std::string(optarg); break; case 'i': str = std::string(optarg); readParams.dim = (unsigned int)std::stoi( str ); break; case 'n': str = std::string(optarg); readParams.numTimePoints = (unsigned int)std::stoi( str ); break; case 's': str = std::string(optarg); readParams.startTimePoint = (unsigned int)std::stoi( str ); break; case 'x': str = std::string(optarg); readParams.spScales[0] = std::stof( str ); break; case 'y': str = std::string(optarg); readParams.spScales[1] = std::stof( str ); break; case 'z': str = std::string(optarg); readParams.spScales[2] = std::stof( str ); break; case 'r': str = std::string(optarg); readParams.rScale = std::stof( str ); break; case 'e': str = std::string(optarg); readParams.epsilon = std::stof( str ); break; case 'm': str = std::string(optarg); readParams.maxIt = (unsigned int)std::stoi( str ); break; case 'g': readParams.merge = true; break; case 'h': std::cout << std::endl << "Usage help:"; ParametersAnalysisInfo(); std::exit( EXIT_SUCCESS ); break; case '?': std::cout << std::endl << "Usage help:"; ParametersAnalysisInfo(); std::exit( EXIT_FAILURE ); break; } if( (c==-1) & first_it ) { std::cout << std::endl << "Usage help:"; ParametersAnalysisInfo(); std::exit( EXIT_SUCCESS ); } first_it = false; /* Detect the end of the options. */ if ( (c==-1) & !first_it ) { break; } } CheckProvidedParameters(); if( readParams.isOk ) { ParametersDisplay(); } else { std::cout << std::endl << "All required parameters are not provided"; ParametersAnalysisInfo(); std::exit( EXIT_FAILURE ); } } } // end of namespace itkSTMS #endif // itkSTMS_ArgumentsAnalysis_HXX