31#ifndef DRAIN_SLIDING_WINDOW_HISTOGRAM_H_
32#define DRAIN_SLIDING_WINDOW_HISTOGRAM_H_
35#include "drain/util/Histogram.h"
36#include "SlidingWindowOp.h"
48 std::string valueFunc;
64template <
class R = WindowCore>
90 histogram.
setSize(this->conf.bins);
93 histogram.
setRange(this->src.getConf().template getTypeMin<int>(), this->src.getConf().template getTypeMax<int>());
95 mout.
attention(
"Range: ", this->src.getConf().template getTypeMin<int>(),
'-' , this->src.getConf().template getTypeMax<int>());
97 if (!this->conf.valueFunc.empty()){
98 histogram.setValueFunc(this->conf.valueFunc.at(0));
104 mout.
warn(
"histogram=", histogram,
" ");
105 mout.debug3(this->coordinateHandler);
115 drain::Logger mout(getImgLog(),
"SlidingWindowHistogramWeighted", __FUNCTION__);
128 this->coordinateHandler.set(this->src.getGeometry(), this->src.getCoordinatePolicy());
134 if (this->coordinateHandler.
validate(p))
135 histogram.decrement(this->src.template get<int>(p));
141 if (this->coordinateHandler.
validate(p))
142 histogram.increment(this->src.template get<int>(p));
147 this->dst.
put(this->
location, histogram.getValue());
182 this->dst.
put(this->
location, this->histogram.getValue());
184 this->dstWeight.put(this->
location, this->histogram.
getMean<
double>());
197 if (this->coordinateHandler.
validate(p))
198 this->histogram.increment(this->src.
get<
int>(p), this->srcWeight.get<
int>(p));
203 if (this->coordinateHandler.
validate(p))
204 this->histogram.decrement(this->src.
get<
int>(p), this->srcWeight.get<
int>(p));
236 "A pipeline implementation of window histogram; valueFunc=[asmdvNX] (avg,sum,median,stddev,variance,miN,maX)"){
237 parameters.link(
"valueFunc", this->conf.valueFunc = valueFunc,
"asmdvXN");
238 parameters.link(
"percentage", this->conf.percentage = percentage);
239 parameters.link(
"bins", this->conf.bins = bins);
Class for computing a histogram and some statistics: average, min, max, mean, std....
Definition Histogram.h:61
void clearBins()
Does not change the size of the histogram.
Definition Histogram.h:94
void setRange(double dataMin, double dataMax)
Set range of original (physical) values to be mapped on the limited number of bins....
Definition Histogram.cpp:76
void setMedianPosition(double pos)
Set location of the median, if not in the middle (50%).
Definition Histogram.h:177
T getMean() const
Unscaled mean.
Definition Histogram.h:326
void setSampleCount(long int n)
Does not change the size of the histogram.
Definition Histogram.h:113
void setSize(size_t s)
Sets the number of bins; the resolution of the histogram.
Definition Histogram.cpp:62
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
Logger & attention(const TT &... args)
Possible error, but execution can continue. Special type of Logger::warn().
Definition Log.h:476
bool validate(Point2D< int > &p) const
Handles the coordinate, returning true if the position is reversible.
Definition CoordinateHandler.h:238
Definition SlidingWindowHistogramOp.h:52
void put(size_t i, T x)
Sets the intensity in location i to x. See \address.
Definition ImageFrame.h:189
T get(size_t i) const
Gets the intensity at location i. See address().
Definition ImageFrame.h:251
Window histogram for computing [asmdvNX] = iAverage, sum, median, stddev, variance,...
Definition SlidingWindowHistogramOp.h:231
Definition SlidingWindowHistogramOp.h:169
virtual void write()
Write the result in the target image.
Definition SlidingWindowHistogramOp.h:181
virtual void removePixel(Point2D< int > &p)
Removes a pixel from window statistics. Unvalidated location.
Definition SlidingWindowHistogramOp.h:202
virtual void addPixel(Point2D< int > &p)
Adds a pixel to window statistics. Unvalidated location.
Definition SlidingWindowHistogramOp.h:191
Base class for median and str histogram based statistics.
Definition SlidingWindowHistogramOp.h:65
virtual void setImageLimits() const
Sets internal limits corresponding to image geometries. Typically using coordHandler.
Definition SlidingWindowHistogramOp.h:127
virtual void write()
Write the result in the target image.
Definition SlidingWindowHistogramOp.h:146
virtual void removePixel(Point2D< int > &p)
Removes a pixel from window statistics. Unvalidated location.
Definition SlidingWindowHistogramOp.h:133
virtual void addPixel(Point2D< int > &p)
Adds a pixel to window statistics. Unvalidated location.
Definition SlidingWindowHistogramOp.h:139
virtual void initialize()
Definition SlidingWindowHistogramOp.h:82
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition SlidingWindowHistogramOp.h:113
Template for operators applying pipeline-like sliding window.
Definition SlidingWindowOp.h:59
Window implementation that uses incremental update of state.
Definition SlidingWindow.h:50
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition Window.h:56
Point2D< int > location
Current location of this window.
Definition Window.h:523
void setLoopLimits()
Sets the actual traversal range inside the window. Sometimes applied dynamically by reset().
Definition Window.h:608
size_t getArea()
Returns the nominal area in pixels.
Definition Window.h:486
Definition DataSelector.cpp:1277
Definition SlidingWindowHistogramOp.h:44