Elaboradar 0.1
Caricamento in corso...
Ricerca in corso...
Nessun risultato

◆ to_cart_average()

template<typename T >
void radarelab::ScaledIndexMapping::to_cart_average ( const PolarScan< double > & src,
std::function< T(const std::vector< double > &)> & convert,
Matrix2D< T > & dst ) const
inline

Fill the cartesian map dst with the output of the function src(azimuth, range)

Definizione alla linea 186 del file cart.h.

187 {
188 // In case dst is not a square with side beam_size*2, center it
189 int dx = ((int)width - dst.cols()) / 2;
190 int dy = ((int)height - dst.rows()) / 2;
191 std::vector<double> samples;
192
193 for (unsigned y = 0; y < dst.rows(); ++y)
194 {
195 if (y + dy < 0 || y + dy >= height) continue;
196
197 for (unsigned x = 0; x < dst.cols(); ++x)
198 {
199 if (x + dx < 0 || x + dx >= width) continue;
200
201 samples.clear();
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;
205 //if(src(azimuth,range) == src.nodata) return
206 samples.push_back(src(azimuth, range));
207 };
208
209 for(unsigned sy = 0; sy < fullsize_pixels_per_scaled_pixel; ++sy)
210 for(unsigned sx = 0; sx < fullsize_pixels_per_scaled_pixel; ++sx)
211 {
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)
215 continue;
216 mapping.sample(src.beam_count, src_x, src_y, compute_average);
217 }
218
219 if (!samples.empty())
220 dst(y + dy, x + dx) = convert(samples);
221 }
222 }
223 }
const unsigned beam_size
Beam size of the volume that we are mapping to cartesian coordinates.
Definition cart.h:24
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.
Definition cart.cpp:44
int image_offset
Image offset in full size pixels.
Definition cart.h:167

Referenzia radarelab::PolarScanBase::beam_count, radarelab::CoordinateMapping::beam_size, radarelab::PolarScanBase::beam_size, image_offset, e radarelab::CoordinateMapping::sample().