31#ifndef RACK_RADAR_WINDOWS_H
32#define RACK_RADAR_WINDOWS_H
37#include <drain/TypeUtils.h>
38#include <drain/util/Fuzzy.h>
39#include <drain/util/Functor.h>
40#include <drain/util/FunctorBank.h>
41#include <drain/image/Window.h>
42#include <drain/image/SegmentProber.h>
43#include <drain/image/SlidingWindow.h>
44#include <drain/image/GaussianWindow.h>
45#include <drain/imageops/FunctorOp.h>
46#include <drain/imageops/GaussianAverageOp.h>
50#include "data/PolarODIM.h"
51#include "data/Quantity.h"
106 this->widthM = widthM;
107 this->heightD = heightD;
137 this->widthM = widthM;
138 this->heightD = heightD;
150 void updatePixelSize(
const PolarODIM & inputODIM);
183template <
class C,
class R=RadarWindowCore>
208 mout.
debug2(
"src props for odim: " , src.getProperties() );
210 this->odimSrc.updateFromMap(src.getProperties());
211 mout.info(
"NI=" , this->odimSrc.getNyquist(LOG_WARNING) );
212 mout.info(
"copied odim: " ,
EncodingODIM(this->odimSrc) );
217 mout.
debug2(
"src Scaling: " , src.getScaling() );
236 if (drain::Type::call<drain::typeIsSmallInt>(this->dst.
getType())){
239 mout.info(
"(not implemented: functor scaling for small int dst)" );
248 this->coordinateHandler.set(this->src.getGeometry(), this->src.getCoordinatePolicy());
257 if (this->odimSrc.area.height == 0)
258 mout.
error(
"src odim.area.height==0" );
261 const double r =
static_cast<double>(this->odimSrc.area.height) / (2.0*M_PI);
262 const int max =
static_cast<int>(this->odimSrc.area.width);
264 rangeNorm =
static_cast<int>(r);
266 rangeNormEnd =
static_cast<int>(r *
static_cast<double>(this->conf.frame.height));
267 if ((rangeNorm <= 0) || (rangeNormEnd >= max)){
268 mout.
note(rangeNorm ,
'-' , rangeNormEnd );
283 this->
setLoopLimits(this->conf.frame.width, this->conf.frame.height);
285 else if (this->
location.x < rangeNormEnd){
286 this->
setLoopLimits(this->conf.frame.width, (rangeNorm * this->conf.frame.height)/(this->location.x+1) );
302template <
class C,
class R=RadarWindowCore>
317 if (this->coordinateHandler.
validate(p)){
318 double x = this->src.template get<double>(p);
319 if ((x != this->odimSrc.nodata) && (x != this->odimSrc.undetect))
326 if (this->coordinateHandler.
validate(p)){
327 double x = this->src.template get<double>(p);
328 if ((x != this->odimSrc.nodata) && (x != this->odimSrc.undetect))
414 this->dst.
putScaled(this->
location.x, this->location.y, this->myFunctor(sum/
static_cast<double>(count)));
417 this->dst.
put(this->
location, this->odimSrc.undetect);
465 if (this->coordinateHandler.
validate(p)){
466 double x = this->src.template get<double>(p);
467 if (this->odimSrc.isValue(x)){
468 this->w = this->srcWeight.template get<sum_t>(p);
469 this->sum += w*this->odimSrc.scaling.fwd(x);
478 if (this->coordinateHandler.
validate(p)){
479 double x = this->src.template get<double>(p);
480 if (this->odimSrc.isValue(x)){
481 this->w = this->srcWeight.template get<sum_t>(p);
482 this->sum -= w*this->odimSrc.scaling.fwd(x);
492 this->dst.
put(this->
location, this->odimSrc.scaling.inv(this->sum/sumW));
494 this->dstWeight.put(this->
location, sumW/
static_cast<sum_t
>(this->count));
497 this->dst.
put(this->
location, this->odimSrc.undetect);
498 this->dstWeight.put(this->
location, 0);
545 void setCoeff(
double c){
547 throw std::runtime_error(
"RadarWindowSoftMax: zero coeff");
568 sum -= ::exp(coeff * x);
574 sum += ::exp(coeff * x);
583 this->dst.
put(this->
location, this->fuzzifier(coeffInv*::log(sum/
static_cast<double>(count))));
642 double countD =
static_cast<double>(count);
643 this->dst.
put(this->
location, this->fuzzifier( ::sqrt(sum2/countD - sum*sum/(countD*countD)) ));
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & note(const TT &... args)
For top-level information.
Definition Log.h:489
Logger & error(const TT &... args)
Echoes.
Definition Log.h:416
Logger & debug2(const TT &... args)
Debug information.
Definition Log.h:676
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition TupleBase.h:287
Tuple of N elements of type T.
Definition UniTuple.h:65
bool validate(Point2D< int > &p) const
Handles the coordinate, returning true if the position is reversible.
Definition CoordinateHandler.h:238
Image with static geometry.
Definition ImageFrame.h:67
void put(size_t i, T x)
Sets the intensity in location i to x. See \address.
Definition ImageFrame.h:192
void putScaled(size_t i, size_t j, double x)
Put intensity using original physical value.
Definition ImageFrame.h:241
const std::type_info & getType() const
Get the storage type.
Definition ImageLike.h:100
Window implementation that uses incremental update of state.
Definition SlidingWindow.h:50
virtual bool reset()
Returns false, if traversal should be ended.
Definition SlidingWindow.h:212
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition Window.h:56
bool resetAtEdges
To avoid accumulated numerical errors esp. with floats, reset the statistics at row/cols ends....
Definition Window.h:529
Point2D< int > location
Current location of this window.
Definition Window.h:523
size_t getSamplingArea()
Returns the area which has eventually been scaled (in a non-linear coordinate system)
Definition Window.h:492
void setLoopLimits()
Sets the actual traversal range inside the window. Sometimes applied dynamically by reset().
Definition Window.h:608
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition EncodingODIM.h:75
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Definition RadarWindows.h:350
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:410
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:398
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:404
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:392
Definition RadarWindows.h:84
RadarWindowConfig(int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:102
RadarWindowConfig(const FT &ftor, int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:131
void adjustMyConf(const RadarWindowConfig &conf, const PolarODIM &inputODIM)
Copies configuration from conf and update pixel frame (width x height).
Definition RadarWindows.cpp:54
void setPixelConf(RadarWindowConfig &conf, const PolarODIM &inputODIM) const
Copies configuration to conf and update its pixel frame (width x height).
Definition RadarWindows.cpp:37
bool invertPolar
Compensate the polar coordinate system to correspond the Cartesian one in computations.
Definition RadarWindows.h:92
bool relativeScale
If true, use speed up to -1.0...+1.0 instead of -Vnyq...+Vnyq.
Definition RadarWindows.h:95
double contributionThreshold
Minimum percentage of detected values in a window (not undetect and nodata)
Definition RadarWindows.h:89
Definition RadarWindows.h:156
double NI
Definition RadarWindows.h:171
RadarWindowCore()
Will act as base class: Window<RadarWindowCore> : public RadarWindowCore {...}, init currently not su...
Definition RadarWindows.h:164
Like pixel window, but width is metres and height is degrees.
Definition RadarWindows.h:65
Definition RadarWindows.h:536
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:581
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:567
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:573
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:561
Sliding window for computing standard deviation of scalar quantities.
Definition RadarWindows.h:597
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:639
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:621
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:629
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:613
Definition RadarWindows.h:428
virtual void addPixel(drain::Point2D< int > &p) final
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:464
virtual void removePixel(drain::Point2D< int > &p) final
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:477
virtual void write() final
Write the result in the target image.
Definition RadarWindows.h:490
virtual void clear() final
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:456
A two-dimensional image processing window that handles the special ODIM codes and scales the result....
Definition RadarWindows.h:184
void setImageLimits() const
Sets internal limits corresponding to image geometries. Typically using coordHandler.
Definition RadarWindows.h:247
void setSrcFrame(const drain::image::ImageFrame &src)
Sets input image and retrieves ODIM metadata from image Properties.
Definition RadarWindows.h:204
virtual void initialize() override
Sets class-specific initial values. Does not change general window state (e.g. location)....
Definition RadarWindows.h:232
virtual bool reset()
Returns false, if traversal should be ended.
Definition RadarWindows.h:280
void setRangeNorm()
To compensate polar geometry, set applicable range for pixel area scaling.
Definition RadarWindows.h:253
Definition RadarWindows.h:303
virtual void addPixel(drain::Point2D< int > &p)
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:325
virtual void removePixel(drain::Point2D< int > &p)
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:316
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:335
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:339
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:1277
Definition DataSelector.cpp:44