Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
void radarelab::ScaledIndexMapping::map_max_sample ( const PolarScan< double > &  scan,
const FullsizeIndexMapping mapping 
)

Map cartesian cardinates to polar volume indices.

When a cartesian coordinate maps to more than one polar value, take the one with the maximum data value.

It requires a FullsizeIndexMapping that has been initialized with map_max_sample().

Definizione alla linea 154 del file cart.cpp.

Referenzia radarelab::PolarScan< T >::get(), image_offset, radarelab::IndexMapping::map_azimuth, radarelab::IndexMapping::map_range, radarelab::IndexMapping::missing, e sample().

155 {
156  // ciclo sui punti della nuova matrice. per il primo prenderò il massimo tra i primi sedici etc..
157  for (unsigned y = 0; y < height; ++y)
158  for (unsigned x = 0; x < width; ++x)
159  {
160  bool first = true;
161  double maxval;
162  unsigned maxval_az = missing;
163  unsigned maxval_range = missing;
164 
165  // Load each sample with a value from a 4x4 window on the original image
166  for(unsigned sy = 0; sy < fullsize_pixels_per_scaled_pixel; ++sy)
167  for(unsigned sx = 0; sx < fullsize_pixels_per_scaled_pixel; ++sx)
168  {
169  // Use the full size mapping to get the volume value at this point
170  int src_x = x * fullsize_pixels_per_scaled_pixel + sx + image_offset;
171  int src_y = y * fullsize_pixels_per_scaled_pixel + sy + image_offset;
172  if (src_x < 0 || src_x >= mapping.width || src_y < 0 || src_y >= mapping.height) continue;
173  unsigned range = mapping.map_range(src_y, src_x);
174  if (range == missing) continue;
175  unsigned az = mapping.map_azimuth(src_y, src_x);
176  double sample = scan.get(az, range);
177 
178  // Find the source point with the maximum sample
179  if (first || sample > maxval)
180  {
181  maxval = sample;
182  maxval_az = az;
183  maxval_range = range;
184  first = false;
185  }
186  }
187 
188  // If nothing has been found, skip this sample
189  if (first) continue;
190 
191  // Store the indices for this mapping
192  map_azimuth(y, x) = maxval_az;
193  map_range(y, x) = maxval_range;
194  }
195 }
int image_offset
Image offset in full size pixels.
Definition: cart.h:167
Matrix2D< unsigned > map_range
Range indices to use to lookup a map point in a volume -1 means no mapping.
Definition: cart.h:76
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.
Definition: cart.cpp:134
static const unsigned missing
Missing value in the azimuth and range index mappings.
Definition: cart.h:66
Matrix2D< double > map_range
Range indices to use to lookup a map point in a volume.
Definition: cart.h:44
Matrix2D< unsigned > map_azimuth
Azimuth indices to use to lookup a map point in a volume -1 means no mapping.
Definition: cart.h:73
Matrix2D< double > map_azimuth
Azimuth indices to use to lookup a map point in a volume.
Definition: cart.h:34