Loading...
Searching...
No Matches
CopyOp.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 COPYOP_H_
32#define COPYOP_H_
33
34//#include "ImageOp.h"
35#include "FunctorOp.h"
36
37namespace drain
38{
39
40namespace image
41{
42// help copy
43
44/* Defunct
45 *
46 The type may be one of the followings:
47 - 'C' : unsigned char
48 - 'S' : unsigned short
49 - 'src' : copied from the source
50 - '*' : keep current, or if undefined, copy from the source
51
52 */
53
88class CopyFunctor : public UnaryFunctor {
89
90public:
91
92 CopyFunctor(double scale = 1.0, double bias = 0.0) : UnaryFunctor(__FUNCTION__, "Copies current view to: f=full image, i=image channels, a=alpha channel(s), 0=1st, 1=2nd,...", scale, bias){
93 //this->parameters.link("srcView", srcView = "f");
94 this->parameters.link("dstView", dstView = "");
95 this->parameters.link("scale", this->scale);
96 this->parameters.link("bias", this->bias);
97 //this->parameters.link("LIMIT", this->LIMIT);
98 };
99
100 //virtual
101 inline
102 double operator()(double s) const {
103 return this->scale*s + this->bias;
104 };
105
106 //std::string srcView;
107 std::string dstView;
108
109protected:
110
111 CopyFunctor(const std::string & name, const std::string & description) : UnaryFunctor(name, description){};
112
113};
114
115class CopyOp : public UnaryFunctorOp<CopyFunctor> {
116
117public:
118
119 CopyOp(double scale = 1.0, double bias = 0, bool LIMIT=true) : UnaryFunctorOp<CopyFunctor>(true, true) {
120 this->functor.setScale(scale, bias);
121 //this->parameters.link("LIMIT", this->LIMIT=LIMIT);
122 }
123
124 CopyOp(const CopyOp & cmd) : UnaryFunctorOp<CopyFunctor>(cmd) {
125 //setParameters(p)
126 //this->functor.s
127 //this->parameters.link("LIMIT", this->LIMIT=LIMIT);
128 }
129
130
131 virtual
132 //void make Compatible(const ImageFrame & src, Image & dst) const;
133 void getDstConf(const ImageConf & src, ImageConf & dst) const;
134
135
136 //inline
137 void process(const ImageFrame & srcFrame, Image & dstImage) const;
138
139 virtual
140 inline
141 void traverseChannel(const Channel &src, Channel &dst) const {
142 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
143 mout.debug("start" );
145 }
146
147 virtual
148 inline
149 void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const {
150 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
151 /*
152 mout.warn("src " , src );
153 mout.warn("srcAlpha" , srcAlpha );
154 mout.warn("dst " , dst );
155 mout.warn("dstAlpha" , dstAlpha );
156 */
159
160 }
161
162
163};
164
165} // image::
166
167} // drain::
168
169#endif /*COPYOP_H_*/
170
171// Drain
double scale
Relative scale, typically 1. Optional.
Definition Functor.h:99
double bias
"Relative" bias, typically 0. Optional.
Definition Functor.h:102
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Image with static geometry.
Definition ImageChannel.h:60
Definition CopyOp.h:88
Definition CopyOp.h:115
void process(const ImageFrame &srcFrame, Image &dstImage) const
Main interface. Typically splits processing to each channel.
Definition CopyOp.cpp:82
virtual void traverseChannel(const Channel &src, Channel &dst) const
Apply to single channel.
Definition CopyOp.h:141
virtual void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const
Apply to single channel with alpha.
Definition CopyOp.h:149
virtual void getDstConf(const ImageConf &src, ImageConf &dst) const
Given source image, determine respective dest image configuration.
Definition CopyOp.cpp:39
Struct for image (excluding data)
Definition ImageConf.h:333
Image with static geometry.
Definition ImageFrame.h:67
virtual int srcAlpha() const
Tell if alpha channel(s) is required in input.
Definition ImageMod.h:66
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:184
Class for using simple function objects (like std::functor) for sequential pixel iteration.
Definition FunctorOp.h:135
void traverseChannel(const Channel &src, Channel &dst) const
Process the image.
Definition FunctorOp.h:225
Definition DataSelector.cpp:1277
Definition Functor.h:116