Loading...
Searching...
No Matches
SegmentStatisticsOp.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 SEGMENT_STATISTICS_OP_H
32#define SEGMENT_STATISTICS_OP_H
33
34#include "SegmentAreaOp.h" // TODO prune to SegmentOp.h
35
36
37namespace drain
38{
39namespace image
40{
41
43
79{
80public:
81
83
85 inline
86 SegmentStatisticsOp(const std::string & statistics="d", double min=1, double max=255, double scale=1.0, double offset=0) :
87 SegmentOp(__FUNCTION__,"Segment statistics: area, mx, my, variance, slimness, horizontality, verticality, elongation") {
88 parameters.link("statistics", this->statistics = statistics, "aAxXyYsSlhve");
89 parameters.link("intensity", this->intensity.tuple(), "min:max");
90 //parameters.link("min", this->min = min);
91 //parameters.link("max", this->max = max);
92 parameters.link("functor", this->functorStr); // = "FuzzyStep"
93 this->intensity.set(min,max);
94 };
95
96 SegmentStatisticsOp(const SegmentStatisticsOp & op) : SegmentOp(__FUNCTION__, "Segment statistics: area, mx, my, variance, slimness, horizontality, verticality, elongation."){
97 parameters.copyStruct(op.getParameters(), op, *this);
98 }
99
100 std::string statistics;
101
103 //void makeCompatible(const ImageFrame & src, Image & dst) const;
104
105 void getDstConf(const ImageConf & src, ImageConf & dst) const; // TODO: src, src2, dst
106
107
108//protected:
109
110 virtual
111 void traverseChannels(const ImageTray<const Channel> & src, ImageTray<Channel> & dst) const;
112
113
114
115};
116
117
118
119} // namespace image
120} // namespace drain
121
122
123#endif /* SEGMENTAREAOP_H */
124
125// Drain
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition ReferenceMap.h:399
Struct for image (excluding data)
Definition ImageConf.h:333
Container applicable for Channels and Images, with alpha support.
Definition ImageTray.h:267
A base class for computing statistics of segments. As segment is an area of connected pixels.
Definition SegmentOp.h:53
Computes statistics of segments: area, centroid, horizontality, verticality, variance and elongation....
Definition SegmentStatisticsOp.h:79
virtual void traverseChannels(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Definition SegmentStatisticsOp.cpp:97
SegmentStatisticsOp(const std::string &statistics="d", double min=1, double max=255, double scale=1.0, double offset=0)
Default constructor.
Definition SegmentStatisticsOp.h:86
void getDstConf(const ImageConf &src, ImageConf &dst) const
Resizes dst, ensures src area and channel count for each stat. .
Definition SegmentStatisticsOp.cpp:44
Definition DataSelector.cpp:1277