Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BackwardMappingLUTStructs.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #include "BackwardMapping.hh"
26  //#include <Base/Image/ImageIO.hh>
27  //#include <Base/Common/FileHandling.hh>
28 
29 
30 
31 // backward compatibility to gcc < 4.1, all other must have omp.h !
32  #ifdef BIAS_HAVE_OPENMP
33  # if !defined(_OPENMP) && defined(WIN32)
34  # error Please check your OpenMP flags and defines - seem inconsistent.
35  # endif
36  # include <omp.h>
37  #endif
38 
39 
40 
41 using namespace std;
42 
43 namespace BIAS {
44 
45  /** LUT Datastruct Interface **/
46  float* BWM_LUT_Entry_Bilinear::
47  SerializedOut(float* pointerToHeadOfOutputMem)
48  {
49  float out;
50  if(mapped) out = 1;
51  else out = 0;
52  *pointerToHeadOfOutputMem = out;
53  pointerToHeadOfOutputMem++;
54  *pointerToHeadOfOutputMem = xy_weight;
55  pointerToHeadOfOutputMem++;
56  *pointerToHeadOfOutputMem = static_cast<float>(index_0_0);
57  pointerToHeadOfOutputMem++;
58  *pointerToHeadOfOutputMem = xY_weight;
59  pointerToHeadOfOutputMem++;
60  *pointerToHeadOfOutputMem = static_cast<float>(index_0_1);
61  pointerToHeadOfOutputMem++;
62  *pointerToHeadOfOutputMem = Xy_weight;
63  pointerToHeadOfOutputMem++;
64  *pointerToHeadOfOutputMem = static_cast<float>(index_1_0);
65  pointerToHeadOfOutputMem++;
66  *pointerToHeadOfOutputMem = XY_weight;
67  pointerToHeadOfOutputMem++;
68  *pointerToHeadOfOutputMem = static_cast<float>(index_1_1);
69  pointerToHeadOfOutputMem++;
70  return pointerToHeadOfOutputMem;
71  }
72 
73  const float* BWM_LUT_Entry_Bilinear::
74  SerializedIn(const float* pointerToHeadOfInputMem)
75  {
76  float in;
77  in = *pointerToHeadOfInputMem;
78  if(in==1) mapped = true;
79  else mapped = false;
80  pointerToHeadOfInputMem++;
81  xy_weight = *pointerToHeadOfInputMem;
82  pointerToHeadOfInputMem++;
83  index_0_0 = static_cast<int>(*pointerToHeadOfInputMem);
84  pointerToHeadOfInputMem++;
85  xY_weight = *pointerToHeadOfInputMem;
86  pointerToHeadOfInputMem++;
87  index_0_1 = static_cast<int>(*pointerToHeadOfInputMem);
88  pointerToHeadOfInputMem++;
89  Xy_weight = *pointerToHeadOfInputMem;
90  pointerToHeadOfInputMem++;
91  index_1_0 = static_cast<int>(*pointerToHeadOfInputMem);
92  pointerToHeadOfInputMem++;
93  XY_weight = *pointerToHeadOfInputMem;
94  pointerToHeadOfInputMem++;
95  index_1_1 = static_cast<int>(*pointerToHeadOfInputMem);
96  pointerToHeadOfInputMem++;
97  return pointerToHeadOfInputMem;
98  }
99 
100  int BWM_LUT_Entry_Bilinear::
101  GetSerializedSize() {
102  return 9;
103  }
104 
105 
106  float* BWM_LUT_Entry_Trilinear::
107  SerializedOut(float* pointerToHeadOfOutputMem)
108  {
109  float out;
110  if(mapped) out = 1;
111  else out = 0;
112  *pointerToHeadOfOutputMem = out;
113  pointerToHeadOfOutputMem++;
114  *pointerToHeadOfOutputMem = pyr_diff_inv;
115  pointerToHeadOfOutputMem++;
116  *pointerToHeadOfOutputMem = static_cast<float>(pyr_level_low);
117  pointerToHeadOfOutputMem++;
118  *pointerToHeadOfOutputMem = pyr_diff;
119  pointerToHeadOfOutputMem++;
120  *pointerToHeadOfOutputMem = static_cast<float>(pyr_level_high);
121  pointerToHeadOfOutputMem++;
122  pointerToHeadOfOutputMem = stage_0.SerializedOut(pointerToHeadOfOutputMem);
123  pointerToHeadOfOutputMem = stage_1.SerializedOut(pointerToHeadOfOutputMem);
124  return pointerToHeadOfOutputMem;
125  }
126 
127  const float* BWM_LUT_Entry_Trilinear::
128  SerializedIn(const float* pointerToHeadOfInputMem)
129  {
130  float in;
131  in = *pointerToHeadOfInputMem;
132  if(in==1) mapped = true;
133  else mapped = false;
134  pointerToHeadOfInputMem++;
135  pyr_diff_inv = *pointerToHeadOfInputMem;
136  pointerToHeadOfInputMem++;
137  pyr_level_low = static_cast<int>(*pointerToHeadOfInputMem);
138  pointerToHeadOfInputMem++;
139  pyr_diff = *pointerToHeadOfInputMem;
140  pointerToHeadOfInputMem++;
141  pyr_level_high = static_cast<int>(*pointerToHeadOfInputMem);
142  pointerToHeadOfInputMem++;
143  pointerToHeadOfInputMem = stage_0.SerializedIn(pointerToHeadOfInputMem);
144  pointerToHeadOfInputMem = stage_1.SerializedIn(pointerToHeadOfInputMem);
145  return pointerToHeadOfInputMem;
146  }
147 
148  int BWM_LUT_Entry_Trilinear::
149  GetSerializedSize() {
150  return 5+2*BWM_LUT_Entry_Bilinear::GetSerializedSize();
151  }
152 
153 } // namespace BIAS