HighBoostOp.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 HIGHBOOSTOP_H_
32 #define HIGHBOOSTOP_H_
33 
34 //#include "SlidingWindowAverage.h"
35 #include "ImageOp.h"
36 
37 #include "FastAverageOp.h"
38 #include "drain/util/FunctorPack.h"
39 
40 
41 namespace drain
42 {
43 
44 namespace image
45 {
46 
47 
48 // Returns src - scale*src2
49 //template <class T=unsigned char,class T2=unsigned char>
50 /*
51 class ScaledSubtractionOp: public MathOp
52 {
53 public:
54 
55  ScaledSubtractionOp() : MathOp(__FUNCTION__, "An arithmetic operator.") {
56  //setParameters(p);
57  };
58 
59  // dst = MathOp<T,T2>::limit(static_cast<double>(src) - this->scale*src2 + this->bias);
60 
61 
62  inline
63  double filterValueD(double src, double src2) const {
64  return (src - scaleD*src2 + offsetD);
65  };
66 
67 };
68 */
69 
71 
73 class HighBoostOp : public ImageOp
74 {
75 public:
76 
77  HighBoostOp(int width=3, int height=3, double coeff=0.5) : ImageOp(__FUNCTION__, "Mixture of original and high-pass filtered image") {
78  parameters.link("width", this->width = width);
79  parameters.link("height", this->height = height);
80  parameters.link("coeff", this->coeff = coeff);
81  };
82 
83  virtual
84  void process(const ImageFrame &src, Image &dst) const {
85 
86  makeCompatible(src.getConf(), dst);
87 
88  FastAverageOp(width,height).process(src,dst);
89 
91  sub.LIMIT = true;
92  sub.functor.setScale(coeff);
93  sub.process(src, dst);
94  //sub.traverseFrame(src,dst,dst);
95 
96  //ScaledSubtractionOp(coeff).process(src,dst,dst);
97  };
98 
99  int width;
100  int height;
101  double coeff;
102 
103 };
104 
105 
106 }
107 
108 }
109 
110 #endif /*HIGHPASSOP_H_*/
111 
112 // Drain
Class for using two-parameter function objects (like std::functor) for sequential and spatial pixel i...
Definition: FunctorOp.h:306
Sliding window averaging operator with optional weighting support.
Definition: FastAverageOp.h:301
Enhances details by mixing original image and result of HighPassOp op.
Definition: HighBoostOp.h:74
virtual void process(const ImageFrame &src, Image &dst) const
Main interface. Typically splits processing to each channel.
Definition: HighBoostOp.h:84
Image with static geometry.
Definition: ImageFrame.h:67
Base class for image processing functions.
Definition: ImageOp.h:49
virtual void makeCompatible(const ImageConf &src, Image &dst) const
Depending on the operator, modifies the geometry and type of dst.
Definition: ImageOp.cpp:54
virtual void process(const ImageFrame &src, Image &dst) const
Main interface. Typically splits processing to each channel.
Definition: ImageOp.cpp:126
ImageOp(const std::string &name=__FUNCTION__, const std::string &description="")
Definition: ImageOp.h:156
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Definition: DataSelector.cpp:1277