31 #ifndef FASTAVERAGEOP_H_
32 #define FASTAVERAGEOP_H_
36 #include "drain/image/SlidingWindow.h"
54 typedef float value_t;
72 Logger mout(getImgLog(),
"SlidingStripeAverage", __FUNCTION__);
73 this->setImageLimits();
74 this->setLoopLimits();
82 mout.debug3(
"scaling (including area): " , scaling.toStr() );
84 mout.debug3(this->dst.getCoordinatePolicy() );
102 if (this->coordinateHandler.validate(p)){
103 sum += this->src.template get<value_t>(p);
110 void removePixel(Point2D<int> & p){
111 if (this->coordinateHandler.validate(p)){
112 sum -= this->src.template get<value_t>(p);
124 this->dst.put(this->location, scaling.
inv(sum /
static_cast<value_t
>(count)) );
130 void setImageLimits()
const {
131 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
132 mout.debug(this->src );
133 this->coordinateHandler.set(this->src.getGeometry(), this->src.getCoordinatePolicy());
134 mout.debug(this->coordinateHandler );
172 Logger mout(getImgLog(),
"SlidingStripeAverageWeighted", __FUNCTION__);
174 this->setImageLimits();
175 this->setLoopLimits();
186 mout.
debug(
"scaling:" , this->scaling );
189 this->scalingW.
setConversionScale(this->srcWeight.getScaling(), this->dstWeight.getScaling());
191 mout.
debug(
"scalingW:" , this->scalingW );
221 if (this->coordinateHandler.validate(p)){
222 this->w = this->srcWeight.template get<sum_t>(p);
223 this->sum += w*this->src.template get<sum_t>(p);
230 void removePixel(Point2D<int> & p){
231 if (this->coordinateHandler.validate(p)){
232 this->w = this->srcWeight.template get<sum_t>(p);
233 this->sum -= w*this->src.template get<sum_t>(p);
243 this->dst.put(this->location, this->scaling.
inv(this->sum/sumW));
246 this->dst.put(this->location, 0);
249 this->dstWeight.put(this->location, this->scalingW.
inv(sumW/
static_cast<sum_t
>(this->count)));
306 "Window averaging with optional weighting support.", width, height) {
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & debug(const TT &... args)
Public, yet typically used "internally", when TIMING=true.
Definition: Log.h:676
Linear scaling and physical range for image intensities.
Definition: ValueScaling.h:64
void setConversionScale(double scale, double offset=0.0, double scaleOut=1.0, double offsetOut=0.0)
If the intensities of the image correspond to a physical value (like temperature),...
Definition: ValueScaling.h:182
double inv(double y) const
Inverse scaling: given physically meaningful value y, returns the corresponding code value.
Definition: ValueScaling.h:301
Image with static geometry.
Definition: ImageChannel.h:60
Sliding window averaging operator with optional weighting support.
Definition: FastAverageOp.h:301
virtual void traverseChannel(const Channel &src, Channel &dst) const
Main operation, for plain (unweighted) image data.
Definition: FastAverageOp.cpp:55
virtual void traverseChannels(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Delegates the invocation separately for each channel.
Definition: FastAverageOp.h:321
void getDstConf(const ImageConf &src, ImageConf &dst) const
Forces equal dst image. (Future versions may support different encoding.)
Definition: FastAverageOp.cpp:44
Utility for explicitly.
Definition: FastAverageOp.h:347
virtual int srcAlpha() const
Tell if alpha channel(s) is required in input.
Definition: FastAverageOp.h:367
Struct for image (excluding data)
Definition: ImageConf.h:333
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
Stripe window for computing weight averages.
Definition: FastAverageOp.h:153
virtual void initialize()
Definition: FastAverageOp.h:170
Stripe window for computing averages.
Definition: FastAverageOp.h:50
virtual void initialize()
Definition: FastAverageOp.h:70
Definition: WindowOp.h:50
Definition: DataSelector.cpp:1277