1 /*------------------------------------------------------------------------=
4 Module: $RCSfile: clitkListOfPair.cxx,v $
6 Date: $Date: 2010/01/06 13:32:01 $
7 Version: $Revision: 1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 ------------------------------------------------------------------------=*/
20 #ifndef CLITKLISTOFPAIR_CXX
21 #define CLITKLISTOFPAIR_CXX
24 ------------------------------------------------=
25 * @file clitkListOfPair.cxx
26 * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
27 * @date 27 Feb 2007 09:55:56
32 ------------------------------------------------=*/
34 #include "clitkListOfPair.h"
36 //--------------------------------------------------------------------
37 double clitk::convertValue(double v,
38 const std::multimap<double, double> & conversionTable,
40 std::map<double, double>::const_iterator i;
41 i = conversionTable.lower_bound(v);
42 if (i == conversionTable.end()) {
43 std::cerr << "The value " << v << " is out of the table" << std::endl;
48 double p2 = i->second;
49 if (i != conversionTable.begin()) i--;
51 double p1 = i->second;
55 if ((v-v1) > (v2-v)) return p2;
59 double w = (v-v1)/(v2-v1);
60 return p1*(1.0-w)+w*p2;
63 //--------------------------------------------------------------------
65 #endif /* end #define CLITKLISTOFPAIR_CXX */