iRoCS Toolbox  1.1.0
ImageAccessWrapper.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2008 Alexandra Teynor
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 /**********************************************************
24  *
25  * ImageAccessWrapper
26  * Ensures acces to the image for different image types
27  *
28  * author: Alex Teynor (teynor@informatik.uni-freiburg.de)
29  * Dec. 2008
30  *
31  *********************************************************/
32 
33 #ifndef _BLITZIMAGEACCESSWRAPPER_HH
34 #define _BLITZIMAGEACCESSWRAPPER_HH
35 
36 #ifdef HAVE_CONFIG_H
37 #include <config.hh>
38 #endif
39 
40 // Blitz arrays
41 #include <blitz/array.h>
42 #include "BlitzRGBColor.hh"
43 
46 
47 public:
48 
49  enum ImageType {
53  };
54 
55  ImageAccessWrapper (blitz::Array<unsigned char, 3>& data);
56  ImageAccessWrapper (blitz::Array<unsigned char, 2>& data);
57  ImageAccessWrapper (blitz::Array<blitz::TinyVector<unsigned char,3>, 2>&
58  data);
59 
60  //PIXEL setting functions --------------------------------
61  // Coordinates are given in y,x (analogus to array indexing)
62  // Coordinates might also be given as a TinyVector: (y,x)
63  // Pixel (0/0) in the upper left corner
64  void setPixel(int y, int x,
65  unsigned char R,
66  unsigned char G,
67  unsigned char B);
68 
69  void setPixel(int y, int x,
70  const BlitzRGBColor& col);
71 
72 
73  void setPixel(blitz::TinyVector<int,2>& pos,
74  unsigned char R,
75  unsigned char G,
76  unsigned char B);
77 
78  void setPixel(blitz::TinyVector<int,2>& pos,
79  const BlitzRGBColor& col);
80 
81 
82  void resize(int y, int x);
83 
84  void resize(blitz::TinyVector<int,2>& pos);
85 
86  int height() const;
87  int width() const;
88 
89  unsigned char getPixelR(int y, int x) const;
90  unsigned char getPixelG(int y, int x) const;
91  unsigned char getPixelB(int y, int x) const;
92 
93  int getImageType() const;
94 
95 
96  unsigned char* data() const;
97 
98 private:
99 
100  //image type
101  ImageType type;
102 
103  //pointer to different image types (only one present, according to type)
104  blitz::Array<unsigned char, 3>* layeredDataRGB;
105  blitz::Array<unsigned char, 2>* layeredDataGray;
106  blitz::Array<blitz::TinyVector<unsigned char,3>,2>* vectDataRGB;
107 
108 
109 };
110 
111 
112 
113 #endif
114 
unsigned char getPixelG(int y, int x) const
unsigned char getPixelB(int y, int x) const
void resize(int y, int x)
int getImageType() const
int height() const
To allow for different blitz storage formats to be handeled equally.
int width() const
void setPixel(int y, int x, unsigned char R, unsigned char G, unsigned char B)
unsigned char * data() const
ImageAccessWrapper(blitz::Array< unsigned char, 3 > &data)
unsigned char getPixelR(int y, int x) const
blitz::TinyVector< unsigned char, 3 > BlitzRGBColor