1 /*------------------------------------------------------------------------=
6 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
7 l'Image). All rights reserved. See Doc/License.txt or
8 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notices for more information.
14 ------------------------------------------------------------------------=*/
17 #ifndef CLITKLISTOFPAIR_CXX
18 #define CLITKLISTOFPAIR_CXX
21 ------------------------------------------------=
22 * @file clitkListOfPair.cxx
23 * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
24 * @date 27 Feb 2007 09:55:56
29 ------------------------------------------------=*/
31 #include "clitkListOfPair.h"
33 //--------------------------------------------------------------------
34 double clitk::convertValue(double v,
35 const std::multimap<double, double> & conversionTable,
37 std::multimap<double, double>::const_iterator i;
38 i = conversionTable.lower_bound(v);
39 if (i == conversionTable.end()) {
40 std::cerr << "The value " << v << " is out of the table" << std::endl;
45 double p2 = i->second;
46 if (i != conversionTable.begin()) i--;
48 double p1 = i->second;
52 if ((v-v1) > (v2-v)) return p2;
56 double w = (v-v1)/(v2-v1);
57 return p1*(1.0-w)+w*p2;
60 //--------------------------------------------------------------------
62 #endif /* end #define CLITKLISTOFPAIR_CXX */