SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Image.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 
31 ///
32 ///@file Image.h
33 ///
34 ///@author
35 /// Sourced from MeshPort.cc by David Weinstein
36 /// Department of Computer Science
37 /// University of Utah
38 ///
39 
40 #ifndef SCI_DATATYPES_IMAGE_H
41 #define SCI_DATATYPES_IMAGE_H 1
42 
44 #include <Core/Containers/LockingHandle.h>
45 #include <Core/Containers/Array2.h>
46 #include <Core/Datatypes/Color.h>
47 
48 #include <Core/Datatypes/share.h>
49 
50 namespace SCIRun {
51 
52 
53 class Image;
54 typedef LockingHandle<Image> ImageHandle;
55 
56 class SCISHARE Image : public Datatype {
57  /* Complex... */
58 public:
59  float** rows;
60  int xr, yr;
61  Image(int xres, int yres);
62  Image(const Image&);
63  virtual ~Image();
64  int xres() const;
65  int yres() const;
66 
67  inline float getr(int x, int y) {
68  return rows[y][x*2];
69  }
70  inline void set(int x, int y, float r, float i) {
71  rows[y][x*2]=r;
72  rows[y][x*2+1]=i;
73  }
74  float max_abs();
75 
76  virtual Image* clone();
77 
78  // Persistent representation...
79  virtual void io(Piostream&);
81  virtual std::string dynamic_type_name() const { return type_id.type; }
82 };
83 
85 public:
86  ColorImage(int xres, int yres);
87  ~ColorImage();
89  inline Color& get_pixel(int x, int y) {
90  return imagedata(y,x);
91  }
92  inline void put_pixel(int x, int y, const Color& pixel) {
93  imagedata(y,x)=pixel;
94  }
95  int xres() const;
96  int yres() const;
97 };
98 
100 public:
101  DepthImage(int xres, int yres);
102  ~DepthImage();
104  double get_depth(int x, int y) {
105  return depthdata(y,x);
106  }
107  inline void put_pixel(int x, int y, double depth) {
108  depthdata(y,x)=depth;
109  }
110  int xres() const;
111  int yres() const;
112 };
113 
114 } // End namespace SCIRun
115 
116 
117 #endif
double get_depth(int x, int y)
Definition: Image.h:104
Color & get_pixel(int x, int y)
Definition: Image.h:89
Definition: Persistent.h:89
int yr
Definition: Image.h:60
#define SCISHARE
Definition: share.h:39
float getr(int x, int y)
Definition: Image.h:67
Definition: Image.h:56
Definition: Image.h:84
void put_pixel(int x, int y, const Color &pixel)
Definition: Image.h:92
void set(int x, int y, float r, float i)
Definition: Image.h:70
float ** rows
Definition: Image.h:59
Array2< Color > imagedata
Definition: Image.h:88
void put_pixel(int x, int y, double depth)
Definition: Image.h:107
Definition: Datatype.h:56
static PersistentTypeID type_id
Definition: Image.h:80
virtual std::string dynamic_type_name() const
Definition: Image.h:81
LockingHandle< Image > ImageHandle
Definition: Image.h:53
Definition: Persistent.h:64
Array2< double > depthdata
Definition: Image.h:103
Definition: Image.h:99
Interface to dynamic 2D array class.