Point Cloud Library (PCL)  1.7.0
color_gradient_dot_modality.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef PCL_FEATURES_COLOR_GRADIENT_DOT_MODALITY
39 #define PCL_FEATURES_COLOR_GRADIENT_DOT_MODALITY
40 
41 #include <pcl/pcl_base.h>
42 #include <pcl/point_cloud.h>
43 #include <pcl/point_types.h>
44 
45 #include <pcl/recognition/dot_modality.h>
46 #include <pcl/recognition/quantized_map.h>
47 
48 
49 namespace pcl
50 {
51 
52  /** \brief A point structure for representing RGB color
53  * \ingroup common
54  */
56  {
57  union
58  {
59  union
60  {
61  struct
62  {
63  uint8_t b;
64  uint8_t g;
65  uint8_t r;
66  uint8_t _unused;
67  };
68  float rgb;
69  };
70  uint32_t rgba;
71  };
72 
73  inline PointRGB ()
74  {}
75 
76  inline PointRGB (const uint8_t b, const uint8_t g, const uint8_t r)
77  : b (b), g (g), r (r), _unused (0)
78  {}
79 
80  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
81  };
82 
83 
84  /** \brief A point structure representing Euclidean xyz coordinates, and the intensity value.
85  * \ingroup common
86  */
88  {
89  union
90  {
91  struct
92  {
93  float x;
94  float y;
95  float angle;
96  float magnitude;
97  };
98  float data[4];
99  };
100  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
101 
102  inline bool operator< (const GradientXY & rhs)
103  {
104  return (magnitude > rhs.magnitude);
105  }
106  };
107  inline std::ostream & operator << (std::ostream & os, const GradientXY & p)
108  {
109  os << "(" << p.x << "," << p.y << " - " << p.magnitude << ")";
110  return (os);
111  }
112 
113  // --------------------------------------------------------------------------
114 
115  template <typename PointInT>
117  : public DOTModality, public PCLBase<PointInT>
118  {
119  protected:
121 
122  struct Candidate
123  {
125 
126  int x;
127  int y;
128 
129  bool operator< (const Candidate & rhs)
130  {
131  return (gradient.magnitude > rhs.gradient.magnitude);
132  }
133  };
134 
135  public:
137 
138  ColorGradientDOTModality (size_t bin_size);
139 
140  virtual ~ColorGradientDOTModality ();
141 
142  inline void
143  setGradientMagnitudeThreshold (const float threshold)
144  {
145  gradient_magnitude_threshold_ = threshold;
146  }
147 
148  //inline QuantizedMap &
149  //getDominantQuantizedMap ()
150  //{
151  // return (dominant_quantized_color_gradients_);
152  //}
153 
154  inline QuantizedMap &
156  {
157  return (dominant_quantized_color_gradients_);
158  }
159 
162  const RegionXY & region);
163 
164  /** \brief Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method)
165  * \param cloud the const boost shared pointer to a PointCloud message
166  */
167  virtual void
168  setInputCloud (const typename PointCloudIn::ConstPtr & cloud)
169  {
170  input_ = cloud;
171  //processInputData ();
172  }
173 
174  virtual void
175  processInputData ();
176 
177  protected:
178 
179  void
181 
182  void
184 
185  //void
186  //computeInvariantQuantizedGradients ();
187 
188  private:
189  size_t bin_size_;
190 
191  float gradient_magnitude_threshold_;
192  pcl::PointCloud<pcl::GradientXY> color_gradients_;
193 
194  pcl::QuantizedMap dominant_quantized_color_gradients_;
195  //pcl::QuantizedMap invariant_quantized_color_gradients_;
196 
197  };
198 
199 }
200 
201 //////////////////////////////////////////////////////////////////////////////////////////////
202 template <typename PointInT>
204 ColorGradientDOTModality (const size_t bin_size)
205  : bin_size_ (bin_size), gradient_magnitude_threshold_ (80.0f), color_gradients_ (), dominant_quantized_color_gradients_ ()
206 {
207 }
208 
209 //////////////////////////////////////////////////////////////////////////////////////////////
210 template <typename PointInT>
213 {
214 }
215 
216 //////////////////////////////////////////////////////////////////////////////////////////////
217 template <typename PointInT>
218 void
221 {
222  // extract color gradients
223  computeMaxColorGradients ();
224 
225  // compute dominant quantized gradient map
226  computeDominantQuantizedGradients ();
227 
228  // compute invariant quantized gradient map
229  //computeInvariantQuantizedGradients ();
230 }
231 
232 //////////////////////////////////////////////////////////////////////////////////////////////
233 template <typename PointInT>
234 void
237 {
238  const int width = input_->width;
239  const int height = input_->height;
240 
241  color_gradients_.points.resize (width*height);
242  color_gradients_.width = width;
243  color_gradients_.height = height;
244 
245  const float pi = tan(1.0f)*4;
246  for (int row_index = 0; row_index < height-2; ++row_index)
247  {
248  for (int col_index = 0; col_index < width-2; ++col_index)
249  {
250  const int index0 = row_index*width+col_index;
251  const int index_c = row_index*width+col_index+2;
252  const int index_r = (row_index+2)*width+col_index;
253 
254  //const int index_d = (row_index+1)*width+col_index+1;
255 
256  const unsigned char r0 = input_->points[index0].r;
257  const unsigned char g0 = input_->points[index0].g;
258  const unsigned char b0 = input_->points[index0].b;
259 
260  const unsigned char r_c = input_->points[index_c].r;
261  const unsigned char g_c = input_->points[index_c].g;
262  const unsigned char b_c = input_->points[index_c].b;
263 
264  const unsigned char r_r = input_->points[index_r].r;
265  const unsigned char g_r = input_->points[index_r].g;
266  const unsigned char b_r = input_->points[index_r].b;
267 
268  const float r_dx = static_cast<float> (r_c) - static_cast<float> (r0);
269  const float g_dx = static_cast<float> (g_c) - static_cast<float> (g0);
270  const float b_dx = static_cast<float> (b_c) - static_cast<float> (b0);
271 
272  const float r_dy = static_cast<float> (r_r) - static_cast<float> (r0);
273  const float g_dy = static_cast<float> (g_r) - static_cast<float> (g0);
274  const float b_dy = static_cast<float> (b_r) - static_cast<float> (b0);
275 
276  const float sqr_mag_r = r_dx*r_dx + r_dy*r_dy;
277  const float sqr_mag_g = g_dx*g_dx + g_dy*g_dy;
278  const float sqr_mag_b = b_dx*b_dx + b_dy*b_dy;
279 
280  GradientXY gradient;
281  gradient.x = col_index;
282  gradient.y = row_index;
283  if (sqr_mag_r > sqr_mag_g && sqr_mag_r > sqr_mag_b)
284  {
285  gradient.magnitude = sqrt (sqr_mag_r);
286  gradient.angle = atan2 (r_dy, r_dx) * 180.0f / pi;
287  }
288  else if (sqr_mag_g > sqr_mag_b)
289  {
290  //GradientXY gradient;
291  gradient.magnitude = sqrt (sqr_mag_g);
292  gradient.angle = atan2 (g_dy, g_dx) * 180.0f / pi;
293  //gradient.x = col_index;
294  //gradient.y = row_index;
295 
296  //color_gradients_ (col_index+1, row_index+1) = gradient;
297  }
298  else
299  {
300  //GradientXY gradient;
301  gradient.magnitude = sqrt (sqr_mag_b);
302  gradient.angle = atan2 (b_dy, b_dx) * 180.0f / pi;
303  //gradient.x = col_index;
304  //gradient.y = row_index;
305 
306  //color_gradients_ (col_index+1, row_index+1) = gradient;
307  }
308 
309  assert (color_gradients_ (col_index+1, row_index+1).angle >= -180 &&
310  color_gradients_ (col_index+1, row_index+1).angle <= 180);
311 
312  color_gradients_ (col_index+1, row_index+1) = gradient;
313  }
314  }
315 
316  return;
317 }
318 
319 //////////////////////////////////////////////////////////////////////////////////////////////
320 //template <typename PointInT>
321 //void
322 //pcl::ColorGradientDOTModality<PointInT>::
323 //computeInvariantQuantizedGradients ()
324 //{
325 // const size_t input_width = input_->width;
326 // const size_t input_height = input_->height;
327 //
328 // const size_t output_width = input_width / bin_size;
329 // const size_t output_height = input_height / bin_size;
330 //
331 // invariant_quantized_color_gradients_.resize (output_width, output_height);
332 //
333 // size_t offset_x = 0;
334 // size_t offset_y = 0;
335 //
336 // const size_t num_gradient_bins = 7;
337 // const size_t max_num_of_gradients = 7;
338 //
339 // const float divisor = 180.0f / (num_gradient_bins - 1.0f);
340 //
341 // float global_max_gradient = 0.0f;
342 // float local_max_gradient = 0.0f;
343 //
344 // unsigned char * peak_pointer = dominant_quantized_color_gradients_.getData ();
345 //
346 // //int tmpCounter = 0;
347 // for (size_t row_bin_index = 0; row_bin_index < output_height; ++row_bin_index)
348 // {
349 // for (size_t col_bin_index = 0; col_bin_index < output_width; ++col_bin_index)
350 // {
351 // std::vector<int> x_coordinates;
352 // std::vector<int> y_coordinates;
353 // std::vector<float> values;
354 //
355 // for (int row_pixel_index = -static_cast<int> (bin_size)/2;
356 // row_pixel_index <= static_cast<int> (bin_size)/2;
357 // row_pixel_index += static_cast<int> (bin_size)/2)
358 // {
359 // const size_t y_position = offset_y + row_pixel_index;
360 //
361 // if (y_position < 0 || y_position >= input_height) continue;
362 //
363 // for (int col_pixel_index = -static_cast<int> (bin_size)/2;
364 // col_pixel_index <= static_cast<int> (bin_size)/2;
365 // col_pixel_index += static_cast<int> (bin_size)/2)
366 // {
367 // const size_t x_position = offset_x + col_pixel_index;
368 // size_t counter = 0;
369 //
370 // if (x_position < 0 || x_position >= input_width) continue;
371 //
372 // // find maximum gradient magnitude in current bin
373 // {
374 // local_max_gradient = 0.0f;
375 // for (size_t row_sub_index = 0; row_sub_index < bin_size; ++row_sub_index)
376 // {
377 // for (size_t col_sub_index = 0; col_sub_index < bin_size; ++col_sub_index)
378 // {
379 // const float magnitude = color_gradients_ (col_sub_index + x_position, row_sub_index + y_position).magnitude;
380 //
381 // if (magnitude > local_max_gradient)
382 // local_max_gradient = magnitude;
383 // }
384 // }
385 // }
386 //
387 // //*stringPointer += localMaxGradient;
388 //
389 // if (local_max_gradient > global_max_gradient)
390 // {
391 // global_max_gradient = local_max_gradient;
392 // }
393 //
394 // // iteratively search for the largest gradients, set it to -1, search the next largest ... etc.
395 // while (true)
396 // {
397 // float max_gradient;
398 // size_t max_gradient_pos_x;
399 // size_t max_gradient_pos_y;
400 //
401 // // find next location and value of maximum gradient magnitude in current region
402 // {
403 // max_gradient = 0.0f;
404 // for (size_t row_sub_index = 0; row_sub_index < bin_size; ++row_sub_index)
405 // {
406 // for (size_t col_sub_index = 0; col_sub_index < bin_size; ++col_sub_index)
407 // {
408 // const float magnitude = color_gradients_ (col_sub_index + x_position, row_sub_index + y_position).magnitude;
409 //
410 // if (magnitude > max_gradient)
411 // {
412 // max_gradient = magnitude;
413 // max_gradient_pos_x = col_sub_index;
414 // max_gradient_pos_y = row_sub_index;
415 // }
416 // }
417 // }
418 // }
419 //
420 // // TODO: really localMaxGradient and not maxGradient???
421 // if (local_max_gradient < gradient_magnitude_threshold_)
422 // {
423 // //*peakPointer |= 1 << (numOfGradientBins-1);
424 // break;
425 // }
426 //
427 // // TODO: replace gradient_magnitude_threshold_ here by a fixed ratio?
428 // if (max_gradient < (local_max_gradient * gradient_magnitude_threshold_) ||
429 // counter >= max_num_of_gradients)
430 // {
431 // break;
432 // }
433 //
434 // ++counter;
435 //
436 // const size_t angle = static_cast<size_t> (180 + color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).angle + 0.5f);
437 // const size_t bin_index = static_cast<size_t> ((angle >= 180 ? angle-180 : angle)/divisor);
438 //
439 // *peak_pointer |= 1 << bin_index;
440 //
441 // x_coordinates.push_back (max_gradient_pos_x + x_position);
442 // y_coordinates.push_back (max_gradient_pos_y + y_position);
443 // values.push_back (max_gradient);
444 //
445 // color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).magnitude = -1.0f;
446 // }
447 //
448 // // reset values which have been set to -1
449 // for (size_t value_index = 0; value_index < values.size (); ++value_index)
450 // {
451 // color_gradients_ (x_coordinates[value_index], y_coordinates[value_index]).magnitude = values[value_index];
452 // }
453 //
454 // x_coordinates.clear ();
455 // y_coordinates.clear ();
456 // values.clear ();
457 // }
458 // }
459 //
460 // if (*peak_pointer == 0)
461 // {
462 // *peak_pointer |= 1 << 7;
463 // }
464 //
465 // //if (*peakPointer != 0)
466 // //{
467 // // ++tmpCounter;
468 // //}
469 //
470 // //++stringPointer;
471 // ++peak_pointer;
472 //
473 // offset_x += bin_size;
474 // }
475 //
476 // offset_y += bin_size;
477 // offset_x = bin_size/2+1;
478 // }
479 //}
480 
481 //////////////////////////////////////////////////////////////////////////////////////////////
482 template <typename PointInT>
483 void
486 {
487  const size_t input_width = input_->width;
488  const size_t input_height = input_->height;
489 
490  const size_t output_width = input_width / bin_size_;
491  const size_t output_height = input_height / bin_size_;
492 
493  dominant_quantized_color_gradients_.resize (output_width, output_height);
494 
495  //size_t offset_x = 0;
496  //size_t offset_y = 0;
497 
498  const size_t num_gradient_bins = 7;
499  const size_t max_num_of_gradients = 1;
500 
501  const float divisor = 180.0f / (num_gradient_bins - 1.0f);
502 
503  float global_max_gradient = 0.0f;
504  float local_max_gradient = 0.0f;
505 
506  unsigned char * peak_pointer = dominant_quantized_color_gradients_.getData ();
507  memset (peak_pointer, 0, output_width*output_height);
508 
509  //int tmpCounter = 0;
510  for (size_t row_bin_index = 0; row_bin_index < output_height; ++row_bin_index)
511  {
512  for (size_t col_bin_index = 0; col_bin_index < output_width; ++col_bin_index)
513  {
514  const size_t x_position = col_bin_index * bin_size_;
515  const size_t y_position = row_bin_index * bin_size_;
516 
517  //std::vector<int> x_coordinates;
518  //std::vector<int> y_coordinates;
519  //std::vector<float> values;
520 
521  // iteratively search for the largest gradients, set it to -1, search the next largest ... etc.
522  //while (counter < max_num_of_gradients)
523  {
524  float max_gradient;
525  size_t max_gradient_pos_x;
526  size_t max_gradient_pos_y;
527 
528  // find next location and value of maximum gradient magnitude in current region
529  {
530  max_gradient = 0.0f;
531  for (size_t row_sub_index = 0; row_sub_index < bin_size_; ++row_sub_index)
532  {
533  for (size_t col_sub_index = 0; col_sub_index < bin_size_; ++col_sub_index)
534  {
535  const float magnitude = color_gradients_ (col_sub_index + x_position, row_sub_index + y_position).magnitude;
536 
537  if (magnitude > max_gradient)
538  {
539  max_gradient = magnitude;
540  max_gradient_pos_x = col_sub_index;
541  max_gradient_pos_y = row_sub_index;
542  }
543  }
544  }
545  }
546 
547  if (max_gradient >= gradient_magnitude_threshold_)
548  {
549  const size_t angle = static_cast<size_t> (180 + color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).angle + 0.5f);
550  const size_t bin_index = static_cast<size_t> ((angle >= 180 ? angle-180 : angle)/divisor);
551 
552  *peak_pointer |= 1 << bin_index;
553  }
554 
555  //++counter;
556 
557  //x_coordinates.push_back (max_gradient_pos_x + x_position);
558  //y_coordinates.push_back (max_gradient_pos_y + y_position);
559  //values.push_back (max_gradient);
560 
561  //color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).magnitude = -1.0f;
562  }
563 
564  //// reset values which have been set to -1
565  //for (size_t value_index = 0; value_index < values.size (); ++value_index)
566  //{
567  // color_gradients_ (x_coordinates[value_index], y_coordinates[value_index]).magnitude = values[value_index];
568  //}
569 
570 
571  if (*peak_pointer == 0)
572  {
573  *peak_pointer |= 1 << 7;
574  }
575 
576  //if (*peakPointer != 0)
577  //{
578  // ++tmpCounter;
579  //}
580 
581  //++stringPointer;
582  ++peak_pointer;
583 
584  //offset_x += bin_size;
585  }
586 
587  //offset_y += bin_size;
588  //offset_x = bin_size/2+1;
589  }
590 }
591 
592 //////////////////////////////////////////////////////////////////////////////////////////////
593 template <typename PointInT>
597  const RegionXY & region)
598 {
599  const size_t input_width = input_->width;
600  const size_t input_height = input_->height;
601 
602  const size_t output_width = input_width / bin_size_;
603  const size_t output_height = input_height / bin_size_;
604 
605  const size_t sub_start_x = region.x / bin_size_;
606  const size_t sub_start_y = region.y / bin_size_;
607  const size_t sub_width = region.width / bin_size_;
608  const size_t sub_height = region.height / bin_size_;
609 
610  QuantizedMap map;
611  map.resize (sub_width, sub_height);
612 
613  //size_t offset_x = 0;
614  //size_t offset_y = 0;
615 
616  const size_t num_gradient_bins = 7;
617  const size_t max_num_of_gradients = 7;
618 
619  const float divisor = 180.0f / (num_gradient_bins - 1.0f);
620 
621  float global_max_gradient = 0.0f;
622  float local_max_gradient = 0.0f;
623 
624  unsigned char * peak_pointer = map.getData ();
625 
626  //int tmpCounter = 0;
627  for (size_t row_bin_index = 0; row_bin_index < sub_height; ++row_bin_index)
628  {
629  for (size_t col_bin_index = 0; col_bin_index < sub_width; ++col_bin_index)
630  {
631  std::vector<size_t> x_coordinates;
632  std::vector<size_t> y_coordinates;
633  std::vector<float> values;
634 
635  for (int row_pixel_index = -static_cast<int> (bin_size_)/2;
636  row_pixel_index <= static_cast<int> (bin_size_)/2;
637  row_pixel_index += static_cast<int> (bin_size_)/2)
638  {
639  const size_t y_position = /*offset_y +*/ row_pixel_index + (sub_start_y + row_bin_index)*bin_size_;
640 
641  if (y_position < 0 || y_position >= input_height)
642  continue;
643 
644  for (int col_pixel_index = -static_cast<int> (bin_size_)/2;
645  col_pixel_index <= static_cast<int> (bin_size_)/2;
646  col_pixel_index += static_cast<int> (bin_size_)/2)
647  {
648  const size_t x_position = /*offset_x +*/ col_pixel_index + (sub_start_x + col_bin_index)*bin_size_;
649  size_t counter = 0;
650 
651  if (x_position < 0 || x_position >= input_width)
652  continue;
653 
654  // find maximum gradient magnitude in current bin
655  {
656  local_max_gradient = 0.0f;
657  for (size_t row_sub_index = 0; row_sub_index < bin_size_; ++row_sub_index)
658  {
659  for (size_t col_sub_index = 0; col_sub_index < bin_size_; ++col_sub_index)
660  {
661  const float magnitude = color_gradients_ (col_sub_index + x_position, row_sub_index + y_position).magnitude;
662 
663  if (magnitude > local_max_gradient)
664  local_max_gradient = magnitude;
665  }
666  }
667  }
668 
669  //*stringPointer += localMaxGradient;
670 
671  if (local_max_gradient > global_max_gradient)
672  {
673  global_max_gradient = local_max_gradient;
674  }
675 
676  // iteratively search for the largest gradients, set it to -1, search the next largest ... etc.
677  while (true)
678  {
679  float max_gradient;
680  size_t max_gradient_pos_x;
681  size_t max_gradient_pos_y;
682 
683  // find next location and value of maximum gradient magnitude in current region
684  {
685  max_gradient = 0.0f;
686  for (size_t row_sub_index = 0; row_sub_index < bin_size_; ++row_sub_index)
687  {
688  for (size_t col_sub_index = 0; col_sub_index < bin_size_; ++col_sub_index)
689  {
690  const float magnitude = color_gradients_ (col_sub_index + x_position, row_sub_index + y_position).magnitude;
691 
692  if (magnitude > max_gradient)
693  {
694  max_gradient = magnitude;
695  max_gradient_pos_x = col_sub_index;
696  max_gradient_pos_y = row_sub_index;
697  }
698  }
699  }
700  }
701 
702  // TODO: really localMaxGradient and not maxGradient???
703  if (local_max_gradient < gradient_magnitude_threshold_)
704  {
705  //*peakPointer |= 1 << (numOfGradientBins-1);
706  break;
707  }
708 
709  // TODO: replace gradient_magnitude_threshold_ here by a fixed ratio?
710  if (/*max_gradient < (local_max_gradient * gradient_magnitude_threshold_) ||*/
711  counter >= max_num_of_gradients)
712  {
713  break;
714  }
715 
716  ++counter;
717 
718  const size_t angle = static_cast<size_t> (180 + color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).angle + 0.5f);
719  const size_t bin_index = static_cast<size_t> ((angle >= 180 ? angle-180 : angle)/divisor);
720 
721  *peak_pointer |= 1 << bin_index;
722 
723  x_coordinates.push_back (max_gradient_pos_x + x_position);
724  y_coordinates.push_back (max_gradient_pos_y + y_position);
725  values.push_back (max_gradient);
726 
727  color_gradients_ (max_gradient_pos_x + x_position, max_gradient_pos_y + y_position).magnitude = -1.0f;
728  }
729 
730  // reset values which have been set to -1
731  for (size_t value_index = 0; value_index < values.size (); ++value_index)
732  {
733  color_gradients_ (x_coordinates[value_index], y_coordinates[value_index]).magnitude = values[value_index];
734  }
735 
736  x_coordinates.clear ();
737  y_coordinates.clear ();
738  values.clear ();
739  }
740  }
741 
742  if (*peak_pointer == 0)
743  {
744  *peak_pointer |= 1 << 7;
745  }
746 
747  //if (*peakPointer != 0)
748  //{
749  // ++tmpCounter;
750  //}
751 
752  //++stringPointer;
753  ++peak_pointer;
754 
755  //offset_x += bin_size;
756  }
757 
758  //offset_y += bin_size;
759  //offset_x = bin_size/2+1;
760  }
761 
762  return map;
763 }
764 
765 #endif