Loading...
Searching...
No Matches
ImageLike.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25 */
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31#ifndef IMAGELIKE_H_
32#define IMAGELIKE_H_ "ImageLike 1.1, 2020/02 Markus.Peura@fmi.fi"
33
34/*
35#include <stddef.h> // size_t
36
37##include "../util/Caster.h"
38#include "../util/ValueScaling.h"
39
40#include "Geometry.h"
41#include "Coordinates.h"
42*/
43#include "ImageConf.h"
44
45namespace drain
46{
47
49namespace image
50{
51
52
54
58// Consider: in future, may be merged to ImageConf ?
59// Consider : ImageLike<CONF> : protected CONF {
60
61class ImageLike { // public ImageConf { // or rename ImageBase
62
63public:
64
65 inline
66 ImageLike() {};
67
68 inline
69 ImageLike(const ImageLike &image){
70 std::cerr << __FILE__ << __FUNCTION__ << " setConf/Geom has no effect\n";
71 conf.setConf(image.conf);
72 //conf.setEncoding(image.getEncoding());
73 //conf.setCoordinatePolicy(image.getCoordinatePolicy());
74 };
75
76 /*
77 inline
78 ImageLike(const ImageConf &conf){
79 std::cerr << __FILE__ << __FUNCTION__ << " setConf has no effect\n";
80 //setConf(conf);
81 }
82 */
83
84 virtual inline
85 ~ImageLike(){};
86
87 /*
88 inline
89 const ImageConf & getConf() const {
90 return conf; // *this;
91 }
92
93 virtual inline
94 const Encoding & getEncoding() const {
95 return conf; // *this;
96 }
97 */
99 inline
100 const std::type_info & getType() const {
101 return conf.caster.getType();
102 }
103
104 inline
105 bool typeIsSet() const {
106 return conf.caster.typeIsSet();
107 };
108
109
110 virtual inline // CHECK if virtual needed
111 const Geometry & getGeometry() const {
112 return conf;
113 }
114
115
116 inline
117 size_t getWidth() const {
118 return conf.getWidth();
119 };
120
121 inline
122 size_t getHeight() const {
123 return conf.getHeight();
124 };
125
126 inline
127 size_t getArea() const {
128 return conf.getArea();
129 };
130
131 inline
132 size_t getChannelCount() const {
133 return conf.getChannelCount(); // getGeometry unneeded?
134 };
135
136
137 inline
138 const size_t getImageChannelCount() const {
139 return conf.getImageChannelCount();
140 };
141
142
143 inline
144 const size_t getAlphaChannelCount() const {
145 return conf.getAlphaChannelCount();
146 };
147
148
149 inline
150 bool hasAlphaChannel() const {
151 return conf.hasAlphaChannel();
152 };
153
154
155 inline
156 size_t getVolume() const {
157 return conf.getVolume();
158 };
159
160 inline
161 bool isEmpty() const {
162 return conf.isEmpty();
163 };
164
165 // 2025
167 inline
168 operator bool() const {
169 return !conf.isEmpty();
170 };
171
173 inline
175 return conf.coordinatePolicy;
176 }
177
179 inline
183
184 // TODO: lower?
185 template <class T>
186 inline
187 void setCoordinatePolicy(const T & policy){
188 conf.coordinatePolicy.set(policy);
189 }
190
191 // TODO: lower?
192 inline
193 void setCoordinatePolicy(EdgePolicy::index_t xUnderFlowPolicy, EdgePolicy::index_t yUnderFlowPolicy, EdgePolicy::index_t xOverFlowPolicy, EdgePolicy::index_t yOverFlowPolicy){
194 conf.coordinatePolicy.set(xUnderFlowPolicy, yUnderFlowPolicy, xOverFlowPolicy, yOverFlowPolicy);
195 }
196
197 virtual inline
198 const drain::ValueScaling & getScaling() const {
199 return conf.getScaling();
200 }
201
202
203 // Notice: scaling is modifiable.
204 virtual inline
205 drain::ValueScaling & getScaling() {
206 return conf.getScaling();
207 }
208
209 // Notice: scaling is modifiable.
210 virtual inline
211 void setScaling(const drain::ValueScaling & scaling){
212 conf.setScaling(scaling);
213 }
214
215 // Notice: scaling is modifiable.
216 virtual inline
217 void setScaling(double scale, double offset){
218 conf.setScaling(scale, offset);
219 }
220
221
222
223 template <class T>
224 inline
225 typename drain::typeLimiter<T>::value_t getLimiter() const {
226 return drain::Type::call<drain::typeLimiter<T> >(conf.caster.getType());
227 }
228
229
230
231
232
233protected:
234
235 ImageConf conf;
236
237};
238
239
240} // image::
241} // drain::
242
243#endif /* IMAGELIKE_H_*/
const std::type_info & getType() const
Returns type_info of the current type.
Definition Caster.h:144
Linear scaling and physical range for image intensities.
Definition ValueScaling.h:64
virtual void setScaling(double scale, double offset)
Set linear scaling.
Definition ValueScaling.h:136
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition ValueScaling.h:147
Policies for coordinate underflows and overflows.
Definition CoordinatePolicy.h:106
Caster caster
In base class(es), mainly for storing storage type. In derived classes, also for value conversions.
Definition ImageConf.h:97
Definition Geometry.h:145
size_t getChannelCount() const
Set...
Definition Geometry.h:257
CoordinatePolicy coordinatePolicy
Rules to handle under- and overflows of horizontal and vertical coordinates.
Definition ImageConf.h:383
A base class for images.
Definition ImageLike.h:61
CoordinatePolicy & getCoordinatePolicy()
Coord policy.
Definition ImageLike.h:180
const CoordinatePolicy & getCoordinatePolicy() const
Coord policy.
Definition ImageLike.h:174
const std::type_info & getType() const
Get the storage type.
Definition ImageLike.h:100
Class for ensuring that variable of type D remains within limits of type S.
Definition TypeUtils.h:96
Definition DataSelector.cpp:1277