Loading...
Searching...
No Matches
ProductFQD.h
1
22#ifndef POLARMAX_H_
23#define POLARMAX_H_
24
25#include "Geometry.h" // radar geometry
26
27#include <drain/image/Image.h>
28#include <drain/image/ImageView.h>
29#include <drain/image/ImageOp.h>
30
31//#include "geometry.h"
32
33namespace drain
34{
35
36namespace radar
37{
38
40
41
44template <class T = unsigned char,class T2 = unsigned char>
45class ProductFQD : public image::ImageOp<T,T2>
46{
47public:
48 ProductFQD(){
49 this->setInfo("Computes maximum altitude of echo.","","");
50 };
51 //virtual ~ProductFQD(){};
53};
54
55template <class T,class T2>
57{
58 const unsigned int srcWidth = src.getWidth();
59 const unsigned int srcHeight = src.getHeight();
60
61 const unsigned int width = this->parameters.get("width",src.getWidth());
62 const unsigned int height = srcHeight;
63 dst.setGeometry(width,height,1,1);
64
65 radar::Geometry radarGeometry;
66 float binDepth = src.properties.get("BINDEPTH",500.0);
67
68 Data elevations = src.properties.get("ELEVATIONS","0.123");
69 elevations.trim();
70 elevations.splitTo(radarGeometry.elevationAngles," ");
71
72 const unsigned int sweeps = radarGeometry.elevationAngles.size();
73
74 Data bins = src.properties.get("BINS");
75 bins.trim();
76 bins.splitTo(radarGeometry.bins," ");
77 if (radarGeometry.bins.size() != sweeps){
78 radarGeometry.bins.resize(sweeps,srcWidth);
79 }
80
81 for (unsigned int i = 0; i < sweeps; ++i) {
82 radarGeometry.elevationAngles[i] *= M_PI/180.0;
83 }
84
85
87 unsigned int bin;
88
90 unsigned int groundBin;
91
93 float eta;
94
96 float beta;
97
98
99 if (false){
100 std::cout << "Starting Max\n";
101 std::cout << "\nParams:\n";
102 std::cout << this->parameters << '\n';
103
104 std::cout << "\nGeometry:\n";
105 std::cout << src.getGeometry() << '\n';
106 std::cout << "\nProperties:\n";
107 std::cout << src.properties << '\n';
108 std::cout << "\nElevs: " << elevations << "\n";
109
110 for (unsigned int i=0; i< radarGeometry.elevationAngles.size(); i++){
111 std::cout << "'" << radarGeometry.elevationAngles[i] << "', ";
112 }
113 std::cout << "\n";
114 }
115
116 double groundDistance = 0.0;
117
118
119 // Main loop
120 for (unsigned int k=0; k<sweeps; k++){
121
122 const drain::image::Image<T> & srcSweep = src.getChannel(k);
123 const unsigned int srcWidth = srcSweep.getWidth();
124
125 eta = radarGeometry.elevationAngles[k];
126
127 for (unsigned int i=0; i<width; i++){
128
129 // Scale in width
130 groundBin = (i * srcWidth) / width;
131
132 groundDistance = groundBin*binDepth + binDepth/2.0;
133 beta = Geometry::betaFromGround(groundDistance);
134
135 bin = static_cast<unsigned int>(Geometry::beamFromEtaBeta(eta,beta) / binDepth);
136
137 if (bin < radarGeometry.bins[k]) {
138
139 for (unsigned int j=0; j<height; j++){
140 T2 s = static_cast<T2>(srcSweep.at(bin,j));
141 T2 &d = dst.at(bin,j);
142 if (s > d)
143 d = s;
144 }
145
146 }
147
148 }
149 //std::cerr << "Altitude at end ("<< groundDistance<<"m): " << altitude/scale << std::endl;
150 }
151
152
153 return dst;
154};
155
156
157} // ::image
158
159} // ::drain
160
161#endif /*POLARMAX_H_*/
std::string get(const std::string &key, const std::string &defaultValue) const
Retrieves a value, or default value if value is unset.
Definition SmartMap.h:127
FlexVariableMap properties
Container for user-defined KEY=VALUE metadata.
Definition ImageFrame.h:369
Base class for image processing functions.
Definition ImageOp.h:49
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:184
virtual void setGeometry(size_t width, size_t height, size_t imageChannels=1, size_t alphaChannels=0)
Resizes the image, keeps the current type.
Definition Image.h:95
Definition ProductFQD.h:46
image::Image< T > & filter(const image::Image< T > &src, image::Image< T2 > &dst) const
Definition ProductFQD.h:56
Definition DataSelector.cpp:1277