Loading...
Searching...
No Matches
ImageMod.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 IMAGE_MODIFIER_H_
32#define IMAGE_MODIFIER_H_
33
34//#include "drain/util/LinearScaling.h"
35#include "drain/util/BeanLike.h"
36// #include "drain/image/ drain::ValueScaling.h"
37#include "drain/image/Image.h"
38//#include "ImageChannel.h"
39#include "drain/image/ImageTray.h"
40//#include "Sampler.h"
41
42
43
44namespace drain {
45
46namespace image {
47
49
52class ImageMod : public BeanLike {
53
54public:
55
56 bool physicalScale;
57
59
65 virtual inline
66 int srcAlpha() const {
67 return 0;
68 };
69
71
74 virtual
75 void process(Image & dst) const;
76
77
79
84 virtual
85 void traverseChannels(ImageTray<Channel> & dst) const;
86
87
89
92 //virtual void traverse rame(ImageFrame & dst) const;
93
94
95
97
100 virtual
101 inline
102 void traverseChannel(Channel & dst) const {
103 drain::Logger mout(getImgLog(), __FILE__, __FUNCTION__); //REPL this->name+"(ImageMod)", __FUNCTION__);
104 mout.warn("(Channel &): not implemented" );
105 };
106
108
111 virtual
112 inline
113 void traverseChannel(Channel & dst, Channel & dstAlpha) const {
114 drain::Logger mout(getImgLog(), __FILE__, __FUNCTION__); //REPL this->name+"(ImageMod)", __FUNCTION__);
115 mout.debug("(Channel &, Channel &alpha): not implemented" );
116 };
117
118
119
120 virtual
121 inline
122 void help(std::ostream & ostr = std::cout) const {
123 toStream(ostr);
124 }
125
127 virtual
128 void traverseChannels(ImageFrame & dst) const;
129
130protected:
131
136 inline
137 ImageMod(const std::string &name = __FUNCTION__, const std::string &description="") :
138 // Remove trailing "Op", if it exists. Start find from the end-2
139 BeanLike(name.substr(0, name.find("Op", name.size()-2)), description) , physicalScale(true) {
140
141 };
142
143 inline
144 ImageMod(const ImageMod & op) : BeanLike(op) , physicalScale(true) {
145 };
146
147 inline
148 virtual ~ImageMod(){};
149
150
151
153 virtual
154 void processChannelsSeparately(ImageTray<Channel> & dst) const;
155
156
158 /* This default implementation does nothing.
159 */
160 virtual
161 inline
162 void initialize(Image & dst) const {};
163
165 /* This default implementation does nothing.
166 */
167 virtual
168 inline
169 void initializeAlpha(const Image & srcAlpha, Image & dstAlpha) const {
170 //dstAlpha.initialize(src.getType(), src.getWidth(), src.getHeight(), 1);
171 };
172
173
174
175};
176
177
178
179
180
181
182} // namespace image
183
184} // namespace drain
185
186
187#endif /* IMAGE_OP_H_ */
188
189// Drain
Something which has a name, a description and possibly some parameters of varying type.
Definition BeanLike.h:60
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Image with static geometry.
Definition ImageChannel.h:60
Image with static geometry.
Definition ImageFrame.h:67
Class for operations that modify an existing image instead of producing a new image.
Definition ImageMod.h:52
ImageMod(const std::string &name=__FUNCTION__, const std::string &description="")
Definition ImageMod.h:137
virtual int srcAlpha() const
Tell if alpha channel(s) is required in input.
Definition ImageMod.h:66
virtual void traverseChannels(ImageTray< Channel > &dst) const
Run this modifier for a set of channels.
Definition ImageMod.cpp:61
virtual void traverseChannel(Channel &dst, Channel &dstAlpha) const
Run this modifier for an image frame.
Definition ImageMod.h:113
virtual void processChannelsSeparately(ImageTray< Channel > &dst) const
Run this modifier by calling traverseChannel(Channel &) for each image.
Definition ImageMod.cpp:68
virtual void process(Image &dst) const
Run this modifier for an image.
Definition ImageMod.cpp:48
virtual void traverseChannel(Channel &dst) const
Run this modifier for an image frame.
Definition ImageMod.h:102
virtual void initializeAlpha(const Image &srcAlpha, Image &dstAlpha) const
Modifies the geometry and the type of dst such that traverseChannel(Channel &) can be called.
Definition ImageMod.h:169
virtual void initialize(Image &dst) const
Modifies the geometry and the type of dst such that traverseChannel(Channel &) can be called.
Definition ImageMod.h:162
Container applicable for Channels and Images, with alpha support.
Definition ImageTray.h:267
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:184
Definition DataSelector.cpp:1277