RunLengthOp.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 RUNLENGTHOP_H_
32 #define RUNLENGTHOP_H_
33 
34 #include <stdexcept>
35 
36 
37 #include "ImageOp.h"
38 
39 
40 namespace drain
41 {
42 
43 namespace image
44 {
45 
47 
50 // c onvert -frame 1 +append image.png runLengthHorz.png -resize 50% runLengthHorz2.png #exec
51 class RunLengthOp : public ImageOp
52 {
53 public:
54 
55  RunLengthOp(const std::string &name, double threshold=0) :
56  ImageOp(name, "Computes lengths of segments of intensity above threshold.") {
57  parameters.link("threshold", this->threshold = threshold);
58  };
59 
60  double threshold;
61 
62  inline
63  void traverseChannels(const ImageTray<const Channel> & src, ImageTray<Channel> & dst) const {
64  drain::Logger mout(getImgLog(), __FILE__, __FUNCTION__); //REPL this->name+"[const ChannelTray &, ChannelTray &]", __FUNCTION__);
65  //mout.error() << "not implemented; consider forwarding to processChannelsSeparately()" << mout.endl;
67  }
68 
69 
70 };
71 
72 
74 
83 class RunLengthHorzOp : public RunLengthOp {
84 
85 public:
86 
88 
91  RunLengthHorzOp(double threshold = 0.0) : RunLengthOp(__FUNCTION__, threshold) {};
92 
93 protected:
94 
95  void traverseChannel(const Channel &src, Channel &dst) const ;
96 
97 
98 };
99 
101 
107 class RunLengthVertOp : public RunLengthOp {
108 
109 public:
110 
112 
115  RunLengthVertOp(double threshold = 0.0) : RunLengthOp(__FUNCTION__, threshold) {};
116 
117 protected:
118 
119  //void process(const ImageFrame &src, ImageFrame &dst) const ;
120  void traverseChannel(const Channel &src, Channel &dst) const ;
121 
122 };
123 
124 }
125 }
126 
127 #endif /* RUNLENGTHOP_H_*/
128 
129 // Drain
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Image with static geometry.
Definition: ImageChannel.h:60
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
Computes lengths of horizontal segments.
Definition: RunLengthOp.h:83
void traverseChannel(const Channel &src, Channel &dst) const
Apply to single channel.
Definition: RunLengthOp.cpp:45
RunLengthHorzOp(double threshold=0.0)
Default constructor.
Definition: RunLengthOp.h:91
Base class for RunLengthHorzOp and RunLengthVertOp.
Definition: RunLengthOp.h:52
Computes lengths of vertical segments.
Definition: RunLengthOp.h:107
void traverseChannel(const Channel &src, Channel &dst) const
Computes lengths of horizontal or vertical segments.
Definition: RunLengthOp.cpp:126
RunLengthVertOp(double threshold=0.0)
Default constructor.
Definition: RunLengthOp.h:115
Definition: DataSelector.cpp:1277