Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CorrespondenceMap.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2007 (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 <Base/Common/BIASpragma.hh>
26 
27 #define _CRT_SECURE_NO_DEPRECATE
28 #include <stdio.h>
29 
30 #include <Base/Image/Image.hh>
31 #include "CorrespondenceMap.hh"
32 
33 
34 using namespace BIAS;
35 using namespace std;
36 
37 
38 template <class StorageType>
40 {
41 
42 }
43 
44 template <class StorageType>
45 int CorrespondenceMap<StorageType>::Read(const std::string filename,
46  unsigned int width,
47  unsigned int height) {
48  if (!this->IsEmpty()) this->Release();
49  this->Init(width, height, 2);
50  //this->SetColorModel(ImageBase::CM_Grey);
51  ifstream thefile(filename.c_str());
52  StorageType** IDA=this->GetImageDataArray();
53  cout<<"Loading correspondences from file "<<filename<<" ";
54  for (unsigned int y=0; y<height; y++) {
55  if (y%50==0) cout<<y*100/width<<"% "<<flush;
56  for (unsigned int x=0; x<width; x++) {
57  thefile >> (IDA[y][2*x]);
58  thefile >> (IDA[y][2*x+1]);
59  if (!thefile.good()) return -1;
60  }
61  }
62  cout<<endl;
63  return 0;
64 }
65 
66 
67 // template instantiation
68 
69 #define INST(type)\
70 template class BIASImage_EXPORT CorrespondenceMap<type>
71 //template ostream& operator<<<type>(ostream & , Image<type> const & );
72 //template istream& operator>><type>(istream& , Image<type>& );
73 namespace BIAS{
74 INST(unsigned char);
75 INST(float);
76 
77 #ifdef BUILD_IMAGE_INT
78 INST(int);
79 #endif
80 #ifdef BUILD_IMAGE_CHAR
81 INST(char);
82 #endif
83 #ifdef BUILD_IMAGE_SHORT
84 INST(short);
85 #endif
86 #ifdef BUILD_IMAGE_USHORT
87 INST(unsigned short);
88 #endif
89 #ifdef BUILD_IMAGE_UINT
90 INST(unsigned int);
91 #endif
92 #ifdef BUILD_IMAGE_DOUBLE
93 INST(double);
94 #endif
95 }
int Read(const std::string filename, unsigned int width=720, unsigned int height=576)
read from ascii file vector as two doubles each line, starting with first image column, then second
INST(unsigned char)
The image template class for specific storage types.
Definition: Image.hh:78