5#ifndef RADARELAB_CART_H
6#define RADARELAB_CART_H
55 void sample(
unsigned beam_count,
unsigned x,
unsigned y, std::function<
void(
unsigned,
unsigned)>& f)
const;
66 static const unsigned missing = 0xffffffff;
68 const unsigned height;
81 template<
typename SRC,
typename DST>
85 int dx = ((int)width - dst.cols()) / 2;
86 int dy = ((int)height - dst.rows()) / 2;
88 for (
unsigned y = 0; y < dst.rows(); ++y)
90 if (y + dy < 0 || y + dy >= height)
continue;
92 for (
unsigned x = 0; x < dst.cols(); ++x)
94 if (x + dx < 0 || x + dx >= width)
continue;
102 dst(y, x) = src(azimuth, range);
112 int dx = ((int)width - dst.cols()) / 2;
113 int dy = ((int)height - dst.rows()) / 2;
115 for (
unsigned y = 0; y < dst.rows(); ++y)
117 if (y + dy < 0 || y + dy >= height)
continue;
119 for (
unsigned x = 0; x < dst.cols(); ++x)
121 if (x + dx < 0 || x + dx >= width)
continue;
127 dst(y, x) = src(azimuth, range);
165 unsigned fullsize_pixels_per_scaled_pixel;
172 void sample(
unsigned beam_count,
unsigned x,
unsigned y, std::function<
void(
unsigned,
unsigned)>& f);
189 int dx = ((int)width - dst.cols()) / 2;
190 int dy = ((int)height - dst.rows()) / 2;
191 std::vector<double> samples;
193 for (
unsigned y = 0; y < dst.rows(); ++y)
195 if (y + dy < 0 || y + dy >= height)
continue;
197 for (
unsigned x = 0; x < dst.cols(); ++x)
199 if (x + dx < 0 || x + dx >= width)
continue;
202 std::function<void(
unsigned,
unsigned)> compute_average = [&samples, &src](
unsigned azimuth,
unsigned range) {
203 if (azimuth < 0 || azimuth > src.
beam_count)
return;
204 if (range < 0 || range > src.
beam_size)
return;
206 samples.push_back(src(azimuth, range));
209 for(
unsigned sy = 0; sy < fullsize_pixels_per_scaled_pixel; ++sy)
210 for(
unsigned sx = 0; sx < fullsize_pixels_per_scaled_pixel; ++sx)
212 int src_x = x * fullsize_pixels_per_scaled_pixel + sx +
image_offset;
213 int src_y = y * fullsize_pixels_per_scaled_pixel + sy +
image_offset;
214 if (src_x < 0 || src_x >= mapping.
beam_size * 2 || src_y < 0 || src_y >= mapping.
beam_size * 2)
219 if (!samples.empty())
220 dst(y + dy, x + dx) = convert(samples);
void to_cart(const std::function< T(unsigned, unsigned)> &src, Matrix2D< T > &dst) const
Fill the cartesian map dst with the output of the function src(azimuth, range)
static const unsigned missing
Missing value in the azimuth and range index mappings.
Matrix2D< unsigned > map_range
Range indices to use to lookup a map point in a volume -1 means no mapping.
void to_cart(const PolarScan< SRC > &src, Matrix2D< DST > &dst) const
Copy data from the polar scan src to the cartesian map dst.
Matrix2D< unsigned > map_azimuth
Azimuth indices to use to lookup a map point in a volume -1 means no mapping.
Mapping of cartesian coordinates to specific azimuth and range volume indices.
PolarScan - structure to describe a polarScan containing a matrix of data and conversion factors.
const unsigned beam_size
Beam size of the volume that we are mapping to cartesian coordinates.
Matrix2D< double > map_range
Range indices to use to lookup a map point in a volume.
void sample(unsigned beam_count, unsigned x, unsigned y, std::function< void(unsigned, unsigned)> &f) const
Generate all the (azimuth, range) indices corresponding to a map point.
Matrix2D< double > map_azimuth
Azimuth indices to use to lookup a map point in a volume.
Mapping of cartesian coordinates to raw azimuth angles and range distances.
void map_max_sample(const PolarScan< double > &scan)
Map cartesian cardinates to polar volume indices.
Index mapping where the pixel size corresponds to the radar cell size.
Base for all matrices we use, since we rely on row-major data.
unsigned beam_size
Number of samples in each beam.
unsigned beam_count
Count of beams in this scan.
void to_cart_average(const PolarScan< double > &src, std::function< T(const std::vector< double > &)> &convert, Matrix2D< T > &dst) const
Fill the cartesian map dst with the output of the function src(azimuth, range)
int image_offset
Image offset in full size pixels.
void map_max_sample(const PolarScan< double > &scan, const FullsizeIndexMapping &mapping)
Map cartesian cardinates to polar volume indices.
void sample(unsigned beam_count, unsigned x, unsigned y, std::function< void(unsigned, unsigned)> &f)
Generate all the (azimuth, range) indices corresponding to a map point.
Index mapping with arbitrary pixel size.
Definisce le principali strutture che contengono i dati.