31#ifndef RACK_RADAR_WINDOWS_H
32#define RACK_RADAR_WINDOWS_H
37#include <drain/TypeUtils.h>
38#include <drain/image/Window.h>
39#include <drain/image/SlidingWindow.h>
42#include "data/PolarODIM.h"
97 this->widthM = widthM;
98 this->heightD = heightD;
128 this->widthM = widthM;
129 this->heightD = heightD;
141 void updatePixelSize(
const PolarODIM & inputODIM);
174template <
class C,
class R=RadarWindowCore>
199 mout.
debug2(
"src props for odim: " , src.getProperties() );
201 this->odimSrc.updateFromMap(src.getProperties());
202 mout.info(
"NI=" , this->odimSrc.getNyquist(LOG_WARNING) );
203 mout.info(
"copied odim: " ,
EncodingODIM(this->odimSrc) );
208 mout.
debug2(
"src Scaling: " , src.getScaling() );
227 if (drain::Type::call<drain::typeIsSmallInt>(this->dst.
getType())){
230 mout.info(
"(not implemented: functor scaling for small int dst)" );
239 this->coordinateHandler.set(this->src.getGeometry(), this->src.getCoordinatePolicy());
248 if (this->odimSrc.area.height == 0)
249 mout.
error(
"src odim.area.height==0" );
252 const double r =
static_cast<double>(this->odimSrc.area.height) / (2.0*M_PI);
253 const int max =
static_cast<int>(this->odimSrc.area.width);
255 rangeNorm =
static_cast<int>(r);
257 rangeNormEnd =
static_cast<int>(r *
static_cast<double>(this->conf.frame.height));
258 if ((rangeNorm <= 0) || (rangeNormEnd >= max)){
259 mout.
note(rangeNorm ,
'-' , rangeNormEnd );
274 this->
setLoopLimits(this->conf.frame.width, this->conf.frame.height);
276 else if (this->
location.x < rangeNormEnd){
277 this->
setLoopLimits(this->conf.frame.width, (rangeNorm * this->conf.frame.height)/(this->location.x+1) );
293template <
class C,
class R=RadarWindowCore>
308 if (this->coordinateHandler.
validate(p)){
309 double x = this->src.template get<double>(p);
310 if ((x != this->odimSrc.nodata) && (x != this->odimSrc.undetect))
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))
405 this->dst.
putScaled(this->
location.x, this->location.y, this->myFunctor(sum/
static_cast<double>(count)));
408 this->dst.
put(this->
location, this->odimSrc.undetect);
456 if (this->coordinateHandler.
validate(p)){
457 double x = this->src.template get<double>(p);
458 if (this->odimSrc.isValue(x)){
459 this->w = this->srcWeight.template get<sum_t>(p);
460 this->sum += w*this->odimSrc.scaling.fwd(x);
469 if (this->coordinateHandler.
validate(p)){
470 double x = this->src.template get<double>(p);
471 if (this->odimSrc.isValue(x)){
472 this->w = this->srcWeight.template get<sum_t>(p);
473 this->sum -= w*this->odimSrc.scaling.fwd(x);
483 this->dst.
put(this->
location, this->odimSrc.scaling.inv(this->sum/sumW));
485 this->dstWeight.put(this->
location, sumW/
static_cast<sum_t
>(this->count));
488 this->dst.
put(this->
location, this->odimSrc.undetect);
489 this->dstWeight.put(this->
location, 0);
536 void setCoeff(
double c){
538 throw std::runtime_error(
"RadarWindowSoftMax: zero coeff");
559 sum -= ::exp(coeff * x);
565 sum += ::exp(coeff * x);
574 this->dst.
put(this->
location, this->fuzzifier(coeffInv*::log(sum/
static_cast<double>(count))));
633 double countD =
static_cast<double>(count);
634 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:313
Logger & note(const TT &... args)
For top-level information.
Definition Log.h:490
Logger & error(const TT &... args)
Echoes.
Definition Log.h:417
Logger & debug2(const TT &... args)
Debug information.
Definition Log.h:677
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:235
Image with static geometry.
Definition ImageFrame.h:62
void put(size_t i, T x)
Sets the intensity in location i to x. See \address.
Definition ImageFrame.h:187
void putScaled(size_t i, size_t j, double x)
Put intensity using original physical value.
Definition ImageFrame.h:236
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:215
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition Window.h:55
bool resetAtEdges
To avoid accumulated numerical errors esp. with floats, reset the statistics at row/cols ends....
Definition Window.h:527
Point2D< int > location
Current location of this window.
Definition Window.h:521
size_t getSamplingArea()
Returns the area which has eventually been scaled (in a non-linear coordinate system)
Definition Window.h:490
void setLoopLimits()
Sets the actual traversal range inside the window. Sometimes applied dynamically by reset().
Definition Window.h:606
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition EncodingODIM.h:70
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Definition RadarWindows.h:341
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:401
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:389
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:395
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:383
Definition RadarWindows.h:75
RadarWindowConfig(int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:93
RadarWindowConfig(const FT &ftor, int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:122
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:83
bool relativeScale
If true, use speed up to -1.0...+1.0 instead of -Vnyq...+Vnyq.
Definition RadarWindows.h:86
double contributionThreshold
Minimum percentage of detected values in a window (not undetect and nodata)
Definition RadarWindows.h:80
Definition RadarWindows.h:147
double NI
Definition RadarWindows.h:162
RadarWindowCore()
Will act as base class: Window<RadarWindowCore> : public RadarWindowCore {...}, init currently not su...
Definition RadarWindows.h:155
Like pixel window, but width is metres and height is degrees.
Definition RadarWindows.h:56
Definition RadarWindows.h:527
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:572
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:558
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:564
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:552
Sliding window for computing standard deviation of scalar quantities.
Definition RadarWindows.h:588
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:630
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:612
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:620
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:604
Definition RadarWindows.h:419
virtual void addPixel(drain::Point2D< int > &p) final
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:455
virtual void removePixel(drain::Point2D< int > &p) final
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:468
virtual void write() final
Write the result in the target image.
Definition RadarWindows.h:481
virtual void clear() final
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:447
A two-dimensional image processing window that handles the special ODIM codes and scales the result....
Definition RadarWindows.h:175
void setImageLimits() const
Sets internal limits corresponding to image geometries. Typically using coordHandler.
Definition RadarWindows.h:238
void setSrcFrame(const drain::image::ImageFrame &src)
Sets input image and retrieves ODIM metadata from image Properties.
Definition RadarWindows.h:195
virtual void initialize() override
Sets class-specific initial values. Does not change general window state (e.g. location)....
Definition RadarWindows.h:223
virtual bool reset()
Returns false, if traversal should be ended.
Definition RadarWindows.h:271
void setRangeNorm()
To compensate polar geometry, set applicable range for pixel area scaling.
Definition RadarWindows.h:244
Definition RadarWindows.h:294
virtual void addPixel(drain::Point2D< int > &p)
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:316
virtual void removePixel(drain::Point2D< int > &p)
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:307
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:326
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:330
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:1277
Definition DataSelector.cpp:44