QualityOverrideOp.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 #ifndef QUALITYOVERRIDEOP_H_
32 #define QUALITYOVERRIDEOP_H_
33 
34 
35 //#include "ImageOp.h"
36 #include "QualityOp.h"
37 
38 namespace drain
39 {
40 
41 namespace image
42 {
43 
44 
46 
70 {
71 
72 public:
73 
74  typedef float quality_t;
75 
81  QualityOverrideOp(quality_t advantage = 1.0, quality_t decay = 1.0): QualityOp(__FUNCTION__,
82  "Compares two images, preserving pixels having higher alpha value. Src alpha is pre-multiplied with advantage."){
83  parameters.link("advantage", this->advantage = advantage, "0.8..1.2");
84  parameters.link("decay", this->decay = decay, "0...1");
85  };
86 
87  /*
88  inline
89  QualityOverrideOp(const QualityOverrideOp & op) : QualityOp(op){
90  parameters.copyStruct(op.getParameters(), op, *this);
91  };
92  */
93 
94  virtual
95  ~QualityOverrideOp(){};
96 
97  virtual
98  void traverseChannels(const ImageTray<const Channel> & src, ImageTray<Channel> & dst) const;
99 
100  virtual
101  void traverseChannels(const ImageTray<const Channel> & src1, const ImageTray<const Channel> & src2, ImageTray<Channel> & dst) const;
102 
103  // Inapplicable for separate images.
104  virtual inline
105  void traverseChannel(const Channel &src, Channel &dst) const {
106  Logger mout(getImgLog(), __FILE__, __FUNCTION__);
107  mout.error("Inapplicable for single channels, needs alpha channels" );
108  }
109 
111  virtual inline
112  void traverseChannel(const Channel &src, const Channel &srcWeight, Channel &dst, Channel &dstWeight) const {
113  Logger mout(getImgLog(), __FILE__, __FUNCTION__);
114  mout.note("fwd as trays" );
115  traverseAsChannelTrays(src, srcWeight, dst, dstWeight);
116  }
117 
118 
119  quality_t advantage;
120  quality_t decay;
121 
122 };
123 
124 
125 
126 }
127 
128 }
129 
130 #endif /*QUALITYOVERRIDE_H_*/
131 
132 // Drain
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & error(const TT &... args)
Echoes.
Definition: Log.h:412
Logger & note(const TT &... args)
For top-level information.
Definition: Log.h:485
Image with static geometry.
Definition: ImageChannel.h:60
void traverseAsChannelTrays(const ImageFrame &src, ImageFrame &dst) const
Redirect to processing as trays. This is the opposite of processChannels...() functions.
Definition: ImageOp.h:210
Container applicable for Channels and Images, with alpha support.
Definition: ImageTray.h:267
Definition: QualityOp.h:44
Overwrites pixels of destination image in locations where destination weight is lower.
Definition: QualityOverrideOp.h:70
virtual void traverseChannel(const Channel &src, const Channel &srcWeight, Channel &dst, Channel &dstWeight) const
fwd as trays
Definition: QualityOverrideOp.h:112
virtual void traverseChannel(const Channel &src, Channel &dst) const
Apply to single channel.
Definition: QualityOverrideOp.h:105
QualityOverrideOp(quality_t advantage=1.0, quality_t decay=1.0)
Definition: QualityOverrideOp.h:81
Definition: DataSelector.cpp:1277