QualityOp.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 QUALITY_OP_H_
32 #define QUALITY_OP_H_
33 
34 
35 #include "ImageOp.h"
36 
37 namespace drain
38 {
39 
40 namespace image
41 {
42 
43 
44 class QualityOp : public ImageOp {
45 
46 public:
47 
48  QualityOp(const std::string & name, const std::string & description) : ImageOp(name, description){
49  };
50 
52  virtual
53  //void makeCompatible(const ImageFrame & src, Image & dst) const;
54  void getDstConf(const ImageConf &srcConf, ImageConf & dstConf) const;
55 
56  // TODO:
57 
58  /*
59  virtual
60  void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const {
61  ImageTray<const Channel> srcTray;
62  srcTray.setChannels(src, srcAlpha);
63  ImageTray<Channel> dstTray;
64  dstTray.setChannels(dst, dstAlpha);
65  traverseChannels(srcTray, dstTray);
66  };
67  */
68 };
69 
70 
71 
72 class QualityThresholdOp : public QualityOp {
73 
74 public:
75 
76  inline
77  QualityThresholdOp(double threshold=0.0, double replace=NAN) :
78  QualityOp(__FUNCTION__, "Threshold data with quality") {
79  parameters.link("threshold", this->threshold = threshold, "0.0...1.0");
80  parameters.link("replace", this->replace = replace);
81  };
82 
83  virtual inline
84  void traverseChannels(const ImageTray<const Channel> & src, ImageTray<Channel> & dst) const {
86  // traverseChannelsEqually(src, dst);
87  // traverseChannelsRepeated(src, dst);
88  // traverseMultiChannel(src, dst);
89  }
90 
91  virtual
92  void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const;
93 
94  double threshold;
95  double replace;
96 
97 };
98 
99 
100 }
101 }
102 
103 #endif /*QUALITY_OP_H_*/
104 
105 // Drain
Image with static geometry.
Definition: ImageChannel.h:60
Struct for image (excluding data)
Definition: ImageConf.h:333
virtual int srcAlpha() const
Tell if alpha channel(s) is required in input.
Definition: ImageMod.h:66
Base class for image processing functions.
Definition: ImageOp.h:49
ImageOp(const std::string &name=__FUNCTION__, const std::string &description="")
Definition: ImageOp.h:156
void traverseChannelsSeparately(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Process each (src,dst) channel pair independently. Raise error if their counts differ.
Definition: ImageOp.cpp:340
Container applicable for Channels and Images, with alpha support.
Definition: ImageTray.h:267
Definition: QualityOp.h:44
virtual void getDstConf(const ImageConf &srcConf, ImageConf &dstConf) const
Essentially same as in ImageOp?
Definition: QualityOp.cpp:41
Definition: QualityOp.h:72
virtual void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const
Apply to single channel with alpha.
Definition: QualityOp.cpp:85
Definition: DataSelector.cpp:1277