26 #include <boost/regex.hpp>
28 using boost::regex_match;
31 #include <boost/algorithm/string.hpp>
43 using namespace Euclid::Configuration;
44 namespace po = boost::program_options;
46 namespace SourceXtractor {
55 SegmentationConfig::SegmentationConfig(
long manager_id) :
Configuration(manager_id),
60 return { {
"Detection image", {
62 "Segmentation algorithm to be used. Currently LUTZ is the only choice"},
64 "Disables filtering"},
68 "Lutz sliding window size (0=disable)"},
74 if (algorithm_name !=
"LUTZ") {
81 if (filter_filename !=
"") {
101 convolution_kernel->setValue(0,0, 1);
102 convolution_kernel->setValue(0,1, 2);
103 convolution_kernel->setValue(0,2, 1);
105 convolution_kernel->setValue(1,0, 2);
106 convolution_kernel->setValue(1,1, 4);
107 convolution_kernel->setValue(1,2, 2);
109 convolution_kernel->setValue(2,0, 1);
110 convolution_kernel->setValue(2,1, 2);
111 convolution_kernel->setValue(2,2, 1);
113 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
136 segConfigLogger.
info() <<
"Loaded segmentation filter: " << filename <<
" height: " << convolution_kernel->getHeight() <<
" width: " << convolution_kernel->getWidth();
139 return std::make_shared<BackgroundConvolution>(convolution_kernel,
true);
144 line_stream >> conv >> norm_type;
145 if (conv !=
"CONV") {
148 if (norm_type ==
"NORM") {
151 else if (norm_type ==
"NONORM") {
158 template <
typename T>
161 while (line_stream.
good()) {
162 line_stream >> value;
176 enum class LoadState {
182 LoadState state = LoadState::STATE_START;
183 bool normalize =
false;
185 unsigned int kernel_width = 0;
187 while (file.
good()) {
192 if (line.
size() == 0) {
199 case LoadState::STATE_START:
201 state = LoadState::STATE_FIRST_LINE;
203 case LoadState::STATE_FIRST_LINE:
205 kernel_width = kernel_data.
size();
206 state = LoadState::STATE_OTHER_LINES;
208 case LoadState::STATE_OTHER_LINES:
215 auto kernel_height = kernel_data.
size() / kernel_width;
219 segConfigLogger.
info() <<
"Loaded segmentation filter: " << filename <<
" width: " << convolution_kernel->getWidth() <<
" height: " << convolution_kernel->getHeight();
222 return std::make_shared<BackgroundConvolution>(convolution_kernel, normalize);
void info(const std::string &logMessage)
T regex_replace(T...args)
static Logging getLogger(const std::string &name="")