C++ Bitmap Library  release
bitmap_image.hpp
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  * *
4  * Platform Independent *
5  * Bitmap Image Reader Writer Library *
6  * *
7  * Author: Arash Partow - 2002 *
8  * URL: http://partow.net/programming/bitmap/index.html *
9  * *
10  * Note: This library only supports 24-bits per pixel bitmap format files. *
11  * *
12  * Copyright notice: *
13  * Free use of the Platform Independent Bitmap Image Reader Writer Library *
14  * is permitted under the guidelines and in accordance with the most current *
15  * version of the MIT License. *
16  * http://www.opensource.org/licenses/MIT *
17  * *
18  *****************************************************************************
19 */
20 
21 
22 #ifndef INCLUDE_BITMAP_IMAGE_HPP
23 #define INCLUDE_BITMAP_IMAGE_HPP
24 
25 #include <algorithm>
26 #include <cmath>
27 #include <cstdlib>
28 #include <cstring>
29 #include <fstream>
30 #include <iostream>
31 #include <iterator>
32 #include <limits>
33 #include <string>
34 #include <vector>
35 
36 
38 {
39 public:
40 
41  enum channel_mode {
42  rgb_mode = 0,
44  };
45 
46  enum color_plane {
50  };
51 
53  : file_name_(""),
54  width_ (0),
55  height_ (0),
56  row_increment_ (0),
57  bytes_per_pixel_(3),
58  channel_mode_(bgr_mode)
59  {}
60 
61  bitmap_image(const std::string& filename)
62  : file_name_(filename),
63  width_ (0),
64  height_ (0),
65  row_increment_ (0),
66  bytes_per_pixel_(0),
67  channel_mode_(bgr_mode)
68  {
69  load_bitmap();
70  }
71 
72  bitmap_image(const unsigned int width, const unsigned int height)
73  : file_name_(""),
74  width_ (width ),
75  height_(height),
76  row_increment_ (0),
77  bytes_per_pixel_(3),
78  channel_mode_(bgr_mode)
79  {
80  create_bitmap();
81  }
82 
83  bitmap_image(const bitmap_image& image)
84  : file_name_(image.file_name_),
85  width_ (image.width_ ),
86  height_ (image.height_ ),
87  row_increment_ (0),
88  bytes_per_pixel_(3),
89  channel_mode_(bgr_mode)
90  {
91  create_bitmap();
92  data_ = image.data_;
93  }
94 
96  {
97  if (this != &image)
98  {
99  file_name_ = image.file_name_;
100  bytes_per_pixel_ = image.bytes_per_pixel_;
101  width_ = image.width_;
102  height_ = image.height_;
103  row_increment_ = 0;
104  channel_mode_ = image.channel_mode_;
105  create_bitmap();
106  data_ = image.data_;
107  }
108 
109  return *this;
110  }
111 
112  inline bool operator!()
113  {
114  return (data_.size() == 0) ||
115  (width_ == 0) ||
116  (height_ == 0) ||
117  (row_increment_ == 0);
118  }
119 
120  inline void clear(const unsigned char v = 0x00)
121  {
122  std::fill(data_.begin(),data_.end(),v);
123  }
124 
125  inline unsigned char red_channel(const unsigned int x, const unsigned int y) const
126  {
127  return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)];
128  }
129 
130  inline unsigned char green_channel(const unsigned int x, const unsigned int y) const
131  {
132  return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)];
133  }
134 
135  inline unsigned char blue_channel (const unsigned int x, const unsigned int y) const
136  {
137  return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)];
138  }
139 
140  inline void red_channel(const unsigned int x, const unsigned int y, const unsigned char value)
141  {
142  data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)] = value;
143  }
144 
145  inline void green_channel(const unsigned int x, const unsigned int y, const unsigned char value)
146  {
147  data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)] = value;
148  }
149 
150  inline void blue_channel (const unsigned int x, const unsigned int y, const unsigned char value)
151  {
152  data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)] = value;
153  }
154 
155  inline unsigned char* row(unsigned int row_index) const
156  {
157  return const_cast<unsigned char*>(&data_[(row_index * row_increment_)]);
158  }
159 
160  inline void get_pixel(const unsigned int x, const unsigned int y,
161  unsigned char& red,
162  unsigned char& green,
163  unsigned char& blue)
164  {
165  const unsigned int y_offset = y * row_increment_;
166  const unsigned int x_offset = x * bytes_per_pixel_;
167 
168  blue = data_[y_offset + x_offset + 0];
169  green = data_[y_offset + x_offset + 1];
170  red = data_[y_offset + x_offset + 2];
171  }
172 
173  template <typename RGB>
174  inline void get_pixel(const unsigned int x, const unsigned int y,
175  RGB& colour)
176  {
177  get_pixel(x, y, colour.red, colour.green, colour.blue);
178  }
179 
180  inline void set_pixel(const unsigned int x, const unsigned int y,
181  const unsigned char red,
182  const unsigned char green,
183  const unsigned char blue)
184  {
185  const unsigned int y_offset = y * row_increment_;
186  const unsigned int x_offset = x * bytes_per_pixel_;
187 
188  data_[y_offset + x_offset + 0] = blue;
189  data_[y_offset + x_offset + 1] = green;
190  data_[y_offset + x_offset + 2] = red;
191  }
192 
193  template <typename RGB>
194  inline void set_pixel(const unsigned int x, const unsigned int y, const RGB& colour)
195  {
196  set_pixel(x, y, colour.red, colour.green, colour.blue);
197  }
198 
199  inline bool copy_from(const bitmap_image& image)
200  {
201  if (
202  (image.height_ != height_) ||
203  (image.width_ != width_ )
204  )
205  {
206  return false;
207  }
208 
209  data_ = image.data_;
210 
211  return true;
212  }
213 
214  inline bool copy_from(const bitmap_image& source_image,
215  const unsigned int& x_offset,
216  const unsigned int& y_offset)
217  {
218  if ((x_offset + source_image.width_ ) > width_ ) { return false; }
219  if ((y_offset + source_image.height_) > height_) { return false; }
220 
221  for (unsigned int y = 0; y < source_image.height_; ++y)
222  {
223  unsigned char* itr1 = row(y + y_offset) + x_offset * bytes_per_pixel_;
224  const unsigned char* itr2 = source_image.row(y);
225  const unsigned char* itr2_end = itr2 + source_image.width_ * bytes_per_pixel_;
226 
227  std::copy(itr2,itr2_end,itr1);
228  }
229 
230  return true;
231  }
232 
233  inline bool region(const unsigned int& x ,
234  const unsigned int& y ,
235  const unsigned int& width ,
236  const unsigned int& height,
237  bitmap_image& dest_image )
238  {
239  if ((x + width ) > width_ ) { return false; }
240  if ((y + height) > height_) { return false; }
241 
242  if (
243  (dest_image.width_ < width_ ) ||
244  (dest_image.height_ < height_)
245  )
246  {
247  dest_image.setwidth_height(width,height);
248  }
249 
250  for (unsigned int r = 0; r < height; ++r)
251  {
252  unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
253  unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
254  unsigned char* itr2 = dest_image.row(r);
255 
256  std::copy(itr1,itr1_end,itr2);
257  }
258 
259  return true;
260  }
261 
262  inline bool roi_from_center(const unsigned int& cx ,
263  const unsigned int& cy ,
264  const unsigned int& width ,
265  const unsigned int& height,
266  bitmap_image& dest_image )
267  {
268  return region(cx - (width / 2), cy - (height / 2),
269  width, height,
270  dest_image);
271  }
272 
273  inline bool set_region(const unsigned int& x ,
274  const unsigned int& y ,
275  const unsigned int& width ,
276  const unsigned int& height,
277  const unsigned char& value )
278  {
279  if ((x + width ) > width_ ) { return false; }
280  if ((y + height) > height_) { return false; }
281 
282  for (unsigned int r = 0; r < height; ++r)
283  {
284  unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
285  unsigned char* itr_end = itr + (width * bytes_per_pixel_);
286 
287  std::fill(itr,itr_end,value);
288  }
289 
290  return true;
291  }
292 
293  inline bool set_region(const unsigned int& x ,
294  const unsigned int& y ,
295  const unsigned int& width ,
296  const unsigned int& height,
297  const color_plane color ,
298  const unsigned char& value )
299  {
300  if ((x + width ) > width_ ) { return false; }
301  if ((y + height) > height_) { return false; }
302 
303  const unsigned int color_plane_offset = offset(color);
304 
305  for (unsigned int r = 0; r < height; ++r)
306  {
307  unsigned char* itr = row(r + y) + x * bytes_per_pixel_ + color_plane_offset;
308  unsigned char* itr_end = itr + (width * bytes_per_pixel_);
309 
310  while (itr != itr_end)
311  {
312  *itr = value;
313  itr += bytes_per_pixel_;
314  }
315  }
316 
317  return true;
318  }
319 
320  inline bool set_region(const unsigned int& x ,
321  const unsigned int& y ,
322  const unsigned int& width ,
323  const unsigned int& height,
324  const unsigned char& red ,
325  const unsigned char& green ,
326  const unsigned char& blue )
327  {
328  if ((x + width ) > width_ ) { return false; }
329  if ((y + height) > height_) { return false; }
330 
331  for (unsigned int r = 0; r < height; ++r)
332  {
333  unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
334  unsigned char* itr_end = itr + (width * bytes_per_pixel_);
335 
336  while (itr != itr_end)
337  {
338  *(itr++) = blue;
339  *(itr++) = green;
340  *(itr++) = red;
341  }
342  }
343 
344  return true;
345  }
346 
347  void reflective_image(bitmap_image& image, const bool include_diagnols = false)
348  {
349  image.setwidth_height(3 * width_, 3 * height_, true);
350 
351  image.copy_from(*this, width_, height_);
352 
353  vertical_flip();
354 
355  image.copy_from(*this, width_, 0);
356  image.copy_from(*this, width_, 2 * height_);
357 
358  vertical_flip();
359  horizontal_flip();
360 
361  image.copy_from(*this, 0, height_);
362  image.copy_from(*this, 2 * width_, height_);
363 
364  horizontal_flip();
365 
366  if (include_diagnols)
367  {
368  bitmap_image tile = *this;
369 
370  tile.vertical_flip();
371  tile.horizontal_flip();
372 
373  image.copy_from(tile, 0, 0);
374  image.copy_from(tile, 2 * width_, 0);
375  image.copy_from(tile, 2 * width_, 2 * height_);
376  image.copy_from(tile, 0 , 2 * height_);
377  }
378  }
379 
380  inline unsigned int width() const
381  {
382  return width_;
383  }
384 
385  inline unsigned int height() const
386  {
387  return height_;
388  }
389 
390  inline unsigned int bytes_per_pixel() const
391  {
392  return bytes_per_pixel_;
393  }
394 
395  inline unsigned int pixel_count() const
396  {
397  return width_ * height_;
398  }
399 
400  inline void setwidth_height(const unsigned int width,
401  const unsigned int height,
402  const bool clear = false)
403  {
404  data_.clear();
405  width_ = width;
406  height_ = height;
407 
408  create_bitmap();
409 
410  if (clear)
411  {
412  std::fill(data_.begin(),data_.end(),0x00);
413  }
414  }
415 
416  void save_image(const std::string& file_name) const
417  {
418  std::ofstream stream(file_name.c_str(),std::ios::binary);
419 
420  if (!stream)
421  {
422  std::cerr << "bitmap_image::save_image(): Error - Could not open file " << file_name << " for writing!" << std::endl;
423  return;
424  }
425 
426  bitmap_information_header bih;
427 
428  bih.width = width_;
429  bih.height = height_;
430  bih.bit_count = static_cast<unsigned short>(bytes_per_pixel_ << 3);
431  bih.clr_important = 0;
432  bih.clr_used = 0;
433  bih.compression = 0;
434  bih.planes = 1;
435  bih.size = bih.struct_size();
436  bih.x_pels_per_meter = 0;
437  bih.y_pels_per_meter = 0;
438  bih.size_image = (((bih.width * bytes_per_pixel_) + 3) & 0x0000FFFC) * bih.height;
439 
440  bitmap_file_header bfh;
441 
442  bfh.type = 19778;
443  bfh.size = bfh.struct_size() + bih.struct_size() + bih.size_image;
444  bfh.reserved1 = 0;
445  bfh.reserved2 = 0;
446  bfh.off_bits = bih.struct_size() + bfh.struct_size();
447 
448  write_bfh(stream,bfh);
449  write_bih(stream,bih);
450 
451  unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
452  char padding_data[4] = { 0x00, 0x00, 0x00, 0x00 };
453 
454  for (unsigned int i = 0; i < height_; ++i)
455  {
456  const unsigned char* data_ptr = &data_[(row_increment_ * (height_ - i - 1))];
457 
458  stream.write(reinterpret_cast<const char*>(data_ptr), sizeof(unsigned char) * bytes_per_pixel_ * width_);
459  stream.write(padding_data,padding);
460  }
461 
462  stream.close();
463  }
464 
465  inline void set_all_ith_bits_low(const unsigned int bitr_index)
466  {
467  unsigned char mask = static_cast<unsigned char>(~(1 << bitr_index));
468 
469  for (unsigned char* itr = data(); itr != end(); ++itr)
470  {
471  *itr &= mask;
472  }
473  }
474 
475  inline void set_all_ith_bits_high(const unsigned int bitr_index)
476  {
477  unsigned char mask = static_cast<unsigned char>(1 << bitr_index);
478 
479  for (unsigned char* itr = data(); itr != end(); ++itr)
480  {
481  *itr |= mask;
482  }
483  }
484 
485  inline void set_all_ith_channels(const unsigned int& channel, const unsigned char& value)
486  {
487  for (unsigned char* itr = (data() + channel); itr < end(); itr += bytes_per_pixel_)
488  {
489  *itr = value;
490  }
491  }
492 
493  inline void set_channel(const color_plane color,const unsigned char& value)
494  {
495  for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
496  {
497  *itr = value;
498  }
499  }
500 
501  inline void ror_channel(const color_plane color, const unsigned int& ror)
502  {
503  for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
504  {
505  *itr = static_cast<unsigned char>(((*itr) >> ror) | ((*itr) << (8 - ror)));
506  }
507  }
508 
509  inline void set_all_channels(const unsigned char& value)
510  {
511  for (unsigned char* itr = data(); itr < end(); )
512  {
513  *(itr++) = value;
514  }
515  }
516 
517  inline void set_all_channels(const unsigned char& r_value,
518  const unsigned char& g_value,
519  const unsigned char& b_value)
520  {
521  for (unsigned char* itr = (data() + 0); itr < end(); itr += bytes_per_pixel_)
522  {
523  *(itr + 0) = b_value;
524  *(itr + 1) = g_value;
525  *(itr + 2) = r_value;
526  }
527  }
528 
529  inline void invert_color_planes()
530  {
531  for (unsigned char* itr = data(); itr < end(); *itr = ~(*itr), ++itr);
532  }
533 
534  inline void add_to_color_plane(const color_plane color, const unsigned char& value)
535  {
536  for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
537  {
538  (*itr) += value;
539  }
540  }
541 
542  inline void convert_to_grayscale()
543  {
544  double r_scaler = 0.299;
545  double g_scaler = 0.587;
546  double b_scaler = 0.114;
547 
548  if (rgb_mode == channel_mode_)
549  {
550  std::swap(r_scaler, b_scaler);
551  }
552 
553  for (unsigned char* itr = data(); itr < end(); )
554  {
555  unsigned char gray_value = static_cast<unsigned char>
556  (
557  (r_scaler * (*(itr + 2))) +
558  (g_scaler * (*(itr + 1))) +
559  (b_scaler * (*(itr + 0)))
560  );
561 
562  *(itr++) = gray_value;
563  *(itr++) = gray_value;
564  *(itr++) = gray_value;
565  }
566  }
567 
568  inline const unsigned char* data() const
569  {
570  return data_.data();
571  }
572 
573  inline unsigned char* data()
574  {
575  return const_cast<unsigned char*>(data_.data());
576  }
577 
578  inline void bgr_to_rgb()
579  {
580  if ((bgr_mode == channel_mode_) && (3 == bytes_per_pixel_))
581  {
583  channel_mode_ = rgb_mode;
584  }
585  }
586 
587  inline void rgb_to_bgr()
588  {
589  if ((rgb_mode == channel_mode_) && (3 == bytes_per_pixel_))
590  {
592  channel_mode_ = bgr_mode;
593  }
594  }
595 
596  inline void reverse()
597  {
598  unsigned char* itr1 = data();
599  unsigned char* itr2 = end() - bytes_per_pixel_;
600 
601  while (itr1 < itr2)
602  {
603  for (std::size_t i = 0; i < bytes_per_pixel_; ++i)
604  {
605  unsigned char* citr1 = itr1 + i;
606  unsigned char* citr2 = itr2 + i;
607 
608  std::swap(*citr1,*citr2);
609  }
610 
611  itr1 += bytes_per_pixel_;
612  itr2 -= bytes_per_pixel_;
613  }
614  }
615 
616  inline void horizontal_flip()
617  {
618  for (unsigned int y = 0; y < height_; ++y)
619  {
620  unsigned char* itr1 = row(y);
621  unsigned char* itr2 = itr1 + row_increment_ - bytes_per_pixel_;
622 
623  while (itr1 < itr2)
624  {
625  for (unsigned int i = 0; i < bytes_per_pixel_; ++i)
626  {
627  unsigned char* p1 = (itr1 + i);
628  unsigned char* p2 = (itr2 + i);
629 
630  std::swap(*p1,*p2);
631  }
632 
633  itr1 += bytes_per_pixel_;
634  itr2 -= bytes_per_pixel_;
635  }
636  }
637  }
638 
639  inline void vertical_flip()
640  {
641  for (unsigned int y = 0; y < (height_ / 2); ++y)
642  {
643  unsigned char* itr1 = row(y);
644  unsigned char* itr2 = row(height_ - y - 1);
645 
646  for (std::size_t x = 0; x < row_increment_; ++x)
647  {
648  std::swap(*(itr1 + x),*(itr2 + x));
649  }
650  }
651  }
652 
653  inline void export_color_plane(const color_plane color, unsigned char* image)
654  {
655  for (unsigned char* itr = (data() + offset(color)); itr < end(); ++image, itr += bytes_per_pixel_)
656  {
657  (*image) = (*itr);
658  }
659  }
660 
661  inline void export_color_plane(const color_plane color, bitmap_image& image)
662  {
663  if (
664  (width_ != image.width_ ) ||
665  (height_ != image.height_)
666  )
667  {
668  image.setwidth_height(width_,height_);
669  }
670 
671  image.clear();
672 
673  unsigned char* itr1 = (data() + offset(color));
674  unsigned char* itr1_end = end();
675  unsigned char* itr2 = (image.data() + offset(color));
676 
677  while (itr1 < itr1_end)
678  {
679  (*itr2) = (*itr1);
680 
681  itr1 += bytes_per_pixel_;
682  itr2 += bytes_per_pixel_;
683  }
684  }
685 
686  inline void export_response_image(const color_plane color, double* response_image)
687  {
688  double* resp_itr = response_image;
689 
690  for (unsigned char* itr = (data() + offset(color)); itr < end(); ++response_image, itr += bytes_per_pixel_)
691  {
692  *(resp_itr++) = (1.0 * (*itr)) / 256.0;
693  }
694  }
695 
697  {
698  double* resp_itr = response_image;
699 
700  for (const unsigned char* itr = data(); itr < end(); itr += bytes_per_pixel_)
701  {
702  unsigned char gray_value = static_cast<unsigned char>
703  (
704  (0.299 * (*(itr + 2))) +
705  (0.587 * (*(itr + 1))) +
706  (0.114 * (*(itr + 0)))
707  );
708 
709  *(resp_itr++) = (1.0 * gray_value) / 256.0;
710  }
711  }
712 
713  inline void export_rgb(double* red, double* green, double* blue) const
714  {
715  if (bgr_mode != channel_mode_)
716  return;
717 
718  for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
719  {
720  (*blue ) = (1.0 * (*(itr++))) / 256.0;
721  (*green) = (1.0 * (*(itr++))) / 256.0;
722  (*red ) = (1.0 * (*(itr++))) / 256.0;
723  }
724  }
725 
726  inline void export_rgb(float* red, float* green, float* blue) const
727  {
728  if (bgr_mode != channel_mode_)
729  return;
730 
731  for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
732  {
733  (*blue ) = (1.0f * (*(itr++))) / 256.0f;
734  (*green) = (1.0f * (*(itr++))) / 256.0f;
735  (*red ) = (1.0f * (*(itr++))) / 256.0f;
736  }
737  }
738 
739  inline void export_rgb(unsigned char* red, unsigned char* green, unsigned char* blue) const
740  {
741  if (bgr_mode != channel_mode_)
742  return;
743 
744  for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
745  {
746  (*blue ) = *(itr++);
747  (*green) = *(itr++);
748  (*red ) = *(itr++);
749  }
750  }
751 
752  inline void export_ycbcr(double* y, double* cb, double* cr)
753  {
754  if (bgr_mode != channel_mode_)
755  return;
756 
757  for (const unsigned char* itr = data(); itr < end(); ++y, ++cb, ++cr)
758  {
759  const double blue = (1.0 * (*(itr++)));
760  const double green = (1.0 * (*(itr++)));
761  const double red = (1.0 * (*(itr++)));
762 
763  ( *y) = clamp<double>( 16.0 + (1.0/256.0) * ( 65.738 * red + 129.057 * green + 25.064 * blue),1.0,254);
764  (*cb) = clamp<double>(128.0 + (1.0/256.0) * (- 37.945 * red - 74.494 * green + 112.439 * blue),1.0,254);
765  (*cr) = clamp<double>(128.0 + (1.0/256.0) * ( 112.439 * red - 94.154 * green - 18.285 * blue),1.0,254);
766  }
767  }
768 
769  inline void export_rgb_normal(double* red, double* green, double* blue) const
770  {
771  if (bgr_mode != channel_mode_)
772  return;
773 
774  for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
775  {
776  (*blue ) = (1.0 * (*(itr++)));
777  (*green) = (1.0 * (*(itr++)));
778  (*red ) = (1.0 * (*(itr++)));
779  }
780  }
781 
782  inline void export_rgb_normal(float* red, float* green, float* blue) const
783  {
784  if (bgr_mode != channel_mode_)
785  return;
786 
787  for (const unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
788  {
789  (*blue ) = (1.0f * (*(itr++)));
790  (*green) = (1.0f * (*(itr++)));
791  (*red ) = (1.0f * (*(itr++)));
792  }
793  }
794 
795  inline void import_rgb(double* red, double* green, double* blue)
796  {
797  if (bgr_mode != channel_mode_)
798  return;
799 
800  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
801  {
802  *(itr++) = static_cast<unsigned char>(256.0 * (*blue ));
803  *(itr++) = static_cast<unsigned char>(256.0 * (*green));
804  *(itr++) = static_cast<unsigned char>(256.0 * (*red ));
805  }
806  }
807 
808  inline void import_rgb(float* red, float* green, float* blue)
809  {
810  if (bgr_mode != channel_mode_)
811  return;
812 
813  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
814  {
815  *(itr++) = static_cast<unsigned char>(256.0f * (*blue ));
816  *(itr++) = static_cast<unsigned char>(256.0f * (*green));
817  *(itr++) = static_cast<unsigned char>(256.0f * (*red ));
818  }
819  }
820 
821  inline void import_rgb(unsigned char* red, unsigned char* green, unsigned char* blue)
822  {
823  if (bgr_mode != channel_mode_)
824  return;
825 
826  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
827  {
828  *(itr++) = (*blue );
829  *(itr++) = (*green);
830  *(itr++) = (*red );
831  }
832  }
833 
834  inline void import_ycbcr(double* y, double* cb, double* cr)
835  {
836  if (bgr_mode != channel_mode_)
837  return;
838 
839  for (unsigned char* itr = data(); itr < end(); ++y, ++cb, ++cr)
840  {
841  double y_ = (*y);
842  double cb_ = (*cb);
843  double cr_ = (*cr);
844 
845  *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ + 516.412 * cb_ ) / 256.0 - 276.836,0.0,255.0));
846  *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ - 100.291 * cb_ - 208.120 * cr_ ) / 256.0 + 135.576,0.0,255.0));
847  *(itr++) = static_cast<unsigned char>(clamp((298.082 * y_ + 408.583 * cr_ ) / 256.0 - 222.921,0.0,255.0));
848  }
849  }
850 
851  inline void import_gray_scale_clamped(double* gray)
852  {
853  if (bgr_mode != channel_mode_)
854  return;
855 
856  for (unsigned char* itr = data(); itr < end(); ++gray)
857  {
858  unsigned char c = static_cast<unsigned char>(clamp<double>(256.0 * (*gray),0.0,255.0));
859 
860  *(itr + 0) = c;
861  *(itr + 1) = c;
862  *(itr + 2) = c;
863 
864  itr += 3;
865  }
866  }
867 
868  inline void import_rgb_clamped(double* red, double* green, double* blue)
869  {
870  if (bgr_mode != channel_mode_)
871  return;
872 
873  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
874  {
875  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*blue ),0.0,255.0));
876  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*green),0.0,255.0));
877  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0 * (*red ),0.0,255.0));
878  }
879  }
880 
881  inline void import_rgb_clamped(float* red, float* green, float* blue)
882  {
883  if (bgr_mode != channel_mode_)
884  return;
885 
886  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
887  {
888  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*blue ),0.0,255.0));
889  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*green),0.0,255.0));
890  *(itr++) = static_cast<unsigned char>(clamp<double>(256.0f * (*red ),0.0,255.0));
891  }
892  }
893 
894  inline void import_rgb_normal(double* red, double* green, double* blue)
895  {
896  if (bgr_mode != channel_mode_)
897  return;
898 
899  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
900  {
901  *(itr++) = static_cast<unsigned char>(*blue );
902  *(itr++) = static_cast<unsigned char>(*green);
903  *(itr++) = static_cast<unsigned char>(*red );
904  }
905  }
906 
907  inline void import_rgb_normal(float* red, float* green, float* blue)
908  {
909  if (bgr_mode != channel_mode_)
910  return;
911 
912  for (unsigned char* itr = data(); itr < end(); ++red, ++green, ++blue)
913  {
914  *(itr++) = static_cast<unsigned char>(*blue );
915  *(itr++) = static_cast<unsigned char>(*green);
916  *(itr++) = static_cast<unsigned char>(*red );
917  }
918  }
919 
920  inline void subsample(bitmap_image& dest)
921  {
922  /*
923  Half sub-sample of original image.
924  */
925  unsigned int w = 0;
926  unsigned int h = 0;
927 
928  bool odd_width = false;
929  bool odd_height = false;
930 
931  if (0 == (width_ % 2))
932  w = width_ / 2;
933  else
934  {
935  w = 1 + (width_ / 2);
936  odd_width = true;
937  }
938 
939  if (0 == (height_ % 2))
940  h = height_ / 2;
941  else
942  {
943  h = 1 + (height_ / 2);
944  odd_height = true;
945  }
946 
947  unsigned int horizontal_upper = (odd_width) ? (w - 1) : w;
948  unsigned int vertical_upper = (odd_height) ? (h - 1) : h;
949 
950  dest.setwidth_height(w,h);
951  dest.clear();
952 
953  unsigned char* s_itr[3];
954  const unsigned char* itr1[3];
955  const unsigned char* itr2[3];
956 
957  s_itr[0] = dest.data() + 0;
958  s_itr[1] = dest.data() + 1;
959  s_itr[2] = dest.data() + 2;
960 
961  itr1[0] = data() + 0;
962  itr1[1] = data() + 1;
963  itr1[2] = data() + 2;
964 
965  itr2[0] = data() + row_increment_ + 0;
966  itr2[1] = data() + row_increment_ + 1;
967  itr2[2] = data() + row_increment_ + 2;
968 
969  unsigned int total = 0;
970 
971  for (unsigned int j = 0; j < vertical_upper; ++j)
972  {
973  for (unsigned int i = 0; i < horizontal_upper; ++i)
974  {
975  for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
976  {
977  total = 0;
978  total += *(itr1[k]);
979  total += *(itr1[k]);
980  total += *(itr2[k]);
981  total += *(itr2[k]);
982 
983  itr1[k] += bytes_per_pixel_;
984  itr1[k] += bytes_per_pixel_;
985  itr2[k] += bytes_per_pixel_;
986  itr2[k] += bytes_per_pixel_;
987 
988  *(s_itr[k]) = static_cast<unsigned char>(total >> 2);
989  }
990  }
991 
992  if (odd_width)
993  {
994  for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
995  {
996  total = 0;
997  total += *(itr1[k]);
998  total += *(itr2[k]);
999 
1000  itr1[k] += bytes_per_pixel_;
1001  itr2[k] += bytes_per_pixel_;
1002 
1003  *(s_itr[k]) = static_cast<unsigned char>(total >> 1);
1004  }
1005  }
1006 
1007  for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
1008  {
1009  itr1[k] += row_increment_;
1010  }
1011 
1012  if (j != (vertical_upper - 1))
1013  {
1014  for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
1015  {
1016  itr2[k] += row_increment_;
1017  }
1018  }
1019  }
1020 
1021  if (odd_height)
1022  {
1023  for (unsigned int i = 0; i < horizontal_upper; ++i)
1024  {
1025  for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
1026  {
1027  total = 0;
1028  total += *(itr1[k]);
1029  total += *(itr2[k]);
1030 
1031  itr1[k] += bytes_per_pixel_;
1032  itr2[k] += bytes_per_pixel_;
1033 
1034  *(s_itr[k]) = static_cast<unsigned char>(total >> 1);
1035  }
1036  }
1037 
1038  if (odd_width)
1039  {
1040  for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
1041  {
1042  (*(s_itr[k])) = *(itr1[k]);
1043  }
1044  }
1045  }
1046  }
1047 
1048  inline void upsample(bitmap_image& dest)
1049  {
1050  /*
1051  2x up-sample of original image.
1052  */
1053 
1054  dest.setwidth_height(2 * width_ ,2 * height_);
1055  dest.clear();
1056 
1057  const unsigned char* s_itr[3];
1058  unsigned char* itr1[3];
1059  unsigned char* itr2[3];
1060 
1061  s_itr[0] = data() + 0;
1062  s_itr[1] = data() + 1;
1063  s_itr[2] = data() + 2;
1064 
1065  itr1[0] = dest.data() + 0;
1066  itr1[1] = dest.data() + 1;
1067  itr1[2] = dest.data() + 2;
1068 
1069  itr2[0] = dest.data() + dest.row_increment_ + 0;
1070  itr2[1] = dest.data() + dest.row_increment_ + 1;
1071  itr2[2] = dest.data() + dest.row_increment_ + 2;
1072 
1073  for (unsigned int j = 0; j < height_; ++j)
1074  {
1075  for (unsigned int i = 0; i < width_; ++i)
1076  {
1077  for (unsigned int k = 0; k < bytes_per_pixel_; s_itr[k] += bytes_per_pixel_, ++k)
1078  {
1079  *(itr1[k]) = *(s_itr[k]); itr1[k] += bytes_per_pixel_;
1080  *(itr1[k]) = *(s_itr[k]); itr1[k] += bytes_per_pixel_;
1081 
1082  *(itr2[k]) = *(s_itr[k]); itr2[k] += bytes_per_pixel_;
1083  *(itr2[k]) = *(s_itr[k]); itr2[k] += bytes_per_pixel_;
1084  }
1085  }
1086 
1087  for (unsigned int k = 0; k < bytes_per_pixel_; ++k)
1088  {
1089  itr1[k] += dest.row_increment_;
1090  itr2[k] += dest.row_increment_;
1091  }
1092  }
1093  }
1094 
1095  inline void alpha_blend(const double& alpha, const bitmap_image& image)
1096  {
1097  if (
1098  (image.width_ != width_ ) ||
1099  (image.height_ != height_)
1100  )
1101  {
1102  return;
1103  }
1104 
1105  if ((alpha < 0.0) || (alpha > 1.0))
1106  {
1107  return;
1108  }
1109 
1110  unsigned char* itr1 = data();
1111  unsigned char* itr1_end = end();
1112  const unsigned char* itr2 = image.data();
1113 
1114  double alpha_compliment = 1.0 - alpha;
1115 
1116  while (itr1 != itr1_end)
1117  {
1118  *(itr1) = static_cast<unsigned char>((alpha * (*itr2)) + (alpha_compliment * (*itr1)));
1119  ++itr1;
1120  ++itr2;
1121  }
1122  }
1123 
1124  inline double psnr(const bitmap_image& image)
1125  {
1126  if (
1127  (image.width_ != width_ ) ||
1128  (image.height_ != height_)
1129  )
1130  {
1131  return 0.0;
1132  }
1133 
1134  unsigned char* itr1 = data();
1135  const unsigned char* itr2 = image.data();
1136 
1137  double mse = 0.0;
1138 
1139  while (itr1 != end())
1140  {
1141  const double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
1142 
1143  mse += v * v;
1144  ++itr1;
1145  ++itr2;
1146  }
1147 
1148  if (mse <= 0.0000001)
1149  {
1150  return 1000000.0;
1151  }
1152  else
1153  {
1154  mse /= (3.0 * width_ * height_);
1155 
1156  return 20.0 * std::log10(255.0 / std::sqrt(mse));
1157  }
1158  }
1159 
1160  inline double psnr(const unsigned int& x,
1161  const unsigned int& y,
1162  const bitmap_image& image)
1163  {
1164  if ((x + image.width() ) > width_ ) { return 0.0; }
1165  if ((y + image.height()) > height_) { return 0.0; }
1166 
1167  double mse = 0.0;
1168 
1169  const unsigned int height = image.height();
1170  const unsigned int width = image.width();
1171 
1172  for (unsigned int r = 0; r < height; ++r)
1173  {
1174  unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
1175  unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
1176  const unsigned char* itr2 = image.row(r);
1177 
1178  while (itr1 != itr1_end)
1179  {
1180  double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
1181  mse += v * v;
1182  ++itr1;
1183  ++itr2;
1184  }
1185  }
1186 
1187  if (mse <= 0.0000001)
1188  {
1189  return 1000000.0;
1190  }
1191  else
1192  {
1193  mse /= (3.0 * image.width() * image.height());
1194  return 20.0 * std::log10(255.0 / std::sqrt(mse));
1195  }
1196  }
1197 
1198  inline void histogram(const color_plane color, double hist[256])
1199  {
1200  std::fill(hist,hist + 256,0.0);
1201 
1202  for (unsigned char* itr = (data() + offset(color)); itr < end(); itr += bytes_per_pixel_)
1203  {
1204  ++hist[(*itr)];
1205  }
1206  }
1207 
1208  inline void histogram_normalized(const color_plane color, double hist[256])
1209  {
1210  histogram(color,hist);
1211 
1212  double* h_itr = hist;
1213  const double* h_end = hist + 256;
1214  const double pixel_count = static_cast<double>(width_ * height_);
1215 
1216  while (h_end != h_itr)
1217  {
1218  *(h_itr++) /= pixel_count;
1219  }
1220  }
1221 
1222  inline unsigned int offset(const color_plane color)
1223  {
1224  switch (channel_mode_)
1225  {
1226  case rgb_mode : {
1227  switch (color)
1228  {
1229  case red_plane : return 0;
1230  case green_plane : return 1;
1231  case blue_plane : return 2;
1232  default : return std::numeric_limits<unsigned int>::max();
1233  }
1234  }
1235 
1236  case bgr_mode : {
1237  switch (color)
1238  {
1239  case red_plane : return 2;
1240  case green_plane : return 1;
1241  case blue_plane : return 0;
1242  default : return std::numeric_limits<unsigned int>::max();
1243  }
1244  }
1245 
1246  default : return std::numeric_limits<unsigned int>::max();
1247  }
1248  }
1249 
1250  inline void incremental()
1251  {
1252  unsigned char current_color = 0;
1253 
1254  for (unsigned char* itr = data(); itr < end();)
1255  {
1256  (*itr++) = (current_color);
1257  (*itr++) = (current_color);
1258  (*itr++) = (current_color);
1259 
1260  ++current_color;
1261  }
1262  }
1263 
1264  inline void reverse_channels()
1265  {
1266  if (3 != bytes_per_pixel_)
1267  return;
1268 
1269  for (unsigned char* itr = data(); itr < end(); itr += bytes_per_pixel_)
1270  {
1271  std::swap(*(itr + 0),*(itr + 2));
1272  }
1273  }
1274 
1275 private:
1276 
1277  inline const unsigned char* end() const
1278  {
1279  return data_.data() + data_.size();
1280  }
1281 
1282  inline unsigned char* end()
1283  {
1284  return const_cast<unsigned char*>(data() + data_.size());
1285  }
1286 
1287  struct bitmap_file_header
1288  {
1289  unsigned short type;
1290  unsigned int size;
1291  unsigned short reserved1;
1292  unsigned short reserved2;
1293  unsigned int off_bits;
1294 
1295  unsigned int struct_size() const
1296  {
1297  return sizeof(type ) +
1298  sizeof(size ) +
1299  sizeof(reserved1) +
1300  sizeof(reserved2) +
1301  sizeof(off_bits ) ;
1302  }
1303 
1304  void clear()
1305  {
1306  std::memset(this,0x00,sizeof(bitmap_file_header));
1307  }
1308  };
1309 
1310  struct bitmap_information_header
1311  {
1312  unsigned int size;
1313  unsigned int width;
1314  unsigned int height;
1315  unsigned short planes;
1316  unsigned short bit_count;
1317  unsigned int compression;
1318  unsigned int size_image;
1319  unsigned int x_pels_per_meter;
1320  unsigned int y_pels_per_meter;
1321  unsigned int clr_used;
1322  unsigned int clr_important;
1323 
1324  unsigned int struct_size() const
1325  {
1326  return sizeof(size ) +
1327  sizeof(width ) +
1328  sizeof(height ) +
1329  sizeof(planes ) +
1330  sizeof(bit_count ) +
1331  sizeof(compression ) +
1332  sizeof(size_image ) +
1333  sizeof(x_pels_per_meter) +
1334  sizeof(y_pels_per_meter) +
1335  sizeof(clr_used ) +
1336  sizeof(clr_important ) ;
1337  }
1338 
1339  void clear()
1340  {
1341  std::memset(this,0x00,sizeof(bitmap_information_header));
1342  }
1343  };
1344 
1345  inline bool big_endian() const
1346  {
1347  unsigned int v = 0x01;
1348 
1349  return (1 != reinterpret_cast<char*>(&v)[0]);
1350  }
1351 
1352  inline unsigned short flip(const unsigned short& v) const
1353  {
1354  return ((v >> 8) | (v << 8));
1355  }
1356 
1357  inline unsigned int flip(const unsigned int& v) const
1358  {
1359  return (
1360  ((v & 0xFF000000) >> 0x18) |
1361  ((v & 0x000000FF) << 0x18) |
1362  ((v & 0x00FF0000) >> 0x08) |
1363  ((v & 0x0000FF00) << 0x08)
1364  );
1365  }
1366 
1367  template <typename T>
1368  inline void read_from_stream(std::ifstream& stream,T& t)
1369  {
1370  stream.read(reinterpret_cast<char*>(&t),sizeof(T));
1371  }
1372 
1373  template <typename T>
1374  inline void write_to_stream(std::ofstream& stream,const T& t) const
1375  {
1376  stream.write(reinterpret_cast<const char*>(&t),sizeof(T));
1377  }
1378 
1379  inline void read_bfh(std::ifstream& stream, bitmap_file_header& bfh)
1380  {
1381  read_from_stream(stream,bfh.type );
1382  read_from_stream(stream,bfh.size );
1383  read_from_stream(stream,bfh.reserved1);
1384  read_from_stream(stream,bfh.reserved2);
1385  read_from_stream(stream,bfh.off_bits );
1386 
1387  if (big_endian())
1388  {
1389  bfh.type = flip(bfh.type );
1390  bfh.size = flip(bfh.size );
1391  bfh.reserved1 = flip(bfh.reserved1);
1392  bfh.reserved2 = flip(bfh.reserved2);
1393  bfh.off_bits = flip(bfh.off_bits );
1394  }
1395  }
1396 
1397  inline void write_bfh(std::ofstream& stream, const bitmap_file_header& bfh) const
1398  {
1399  if (big_endian())
1400  {
1401  write_to_stream(stream,flip(bfh.type ));
1402  write_to_stream(stream,flip(bfh.size ));
1403  write_to_stream(stream,flip(bfh.reserved1));
1404  write_to_stream(stream,flip(bfh.reserved2));
1405  write_to_stream(stream,flip(bfh.off_bits ));
1406  }
1407  else
1408  {
1409  write_to_stream(stream,bfh.type );
1410  write_to_stream(stream,bfh.size );
1411  write_to_stream(stream,bfh.reserved1);
1412  write_to_stream(stream,bfh.reserved2);
1413  write_to_stream(stream,bfh.off_bits );
1414  }
1415  }
1416 
1417  inline void read_bih(std::ifstream& stream,bitmap_information_header& bih)
1418  {
1419  read_from_stream(stream,bih.size );
1420  read_from_stream(stream,bih.width );
1421  read_from_stream(stream,bih.height );
1422  read_from_stream(stream,bih.planes );
1423  read_from_stream(stream,bih.bit_count );
1424  read_from_stream(stream,bih.compression );
1425  read_from_stream(stream,bih.size_image );
1426  read_from_stream(stream,bih.x_pels_per_meter);
1427  read_from_stream(stream,bih.y_pels_per_meter);
1428  read_from_stream(stream,bih.clr_used );
1429  read_from_stream(stream,bih.clr_important );
1430 
1431  if (big_endian())
1432  {
1433  bih.size = flip(bih.size );
1434  bih.width = flip(bih.width );
1435  bih.height = flip(bih.height );
1436  bih.planes = flip(bih.planes );
1437  bih.bit_count = flip(bih.bit_count );
1438  bih.compression = flip(bih.compression );
1439  bih.size_image = flip(bih.size_image );
1440  bih.x_pels_per_meter = flip(bih.x_pels_per_meter);
1441  bih.y_pels_per_meter = flip(bih.y_pels_per_meter);
1442  bih.clr_used = flip(bih.clr_used );
1443  bih.clr_important = flip(bih.clr_important );
1444  }
1445  }
1446 
1447  inline void write_bih(std::ofstream& stream, const bitmap_information_header& bih) const
1448  {
1449  if (big_endian())
1450  {
1451  write_to_stream(stream,flip(bih.size ));
1452  write_to_stream(stream,flip(bih.width ));
1453  write_to_stream(stream,flip(bih.height ));
1454  write_to_stream(stream,flip(bih.planes ));
1455  write_to_stream(stream,flip(bih.bit_count ));
1456  write_to_stream(stream,flip(bih.compression ));
1457  write_to_stream(stream,flip(bih.size_image ));
1458  write_to_stream(stream,flip(bih.x_pels_per_meter));
1459  write_to_stream(stream,flip(bih.y_pels_per_meter));
1460  write_to_stream(stream,flip(bih.clr_used ));
1461  write_to_stream(stream,flip(bih.clr_important ));
1462  }
1463  else
1464  {
1465  write_to_stream(stream,bih.size );
1466  write_to_stream(stream,bih.width );
1467  write_to_stream(stream,bih.height );
1468  write_to_stream(stream,bih.planes );
1469  write_to_stream(stream,bih.bit_count );
1470  write_to_stream(stream,bih.compression );
1471  write_to_stream(stream,bih.size_image );
1472  write_to_stream(stream,bih.x_pels_per_meter);
1473  write_to_stream(stream,bih.y_pels_per_meter);
1474  write_to_stream(stream,bih.clr_used );
1475  write_to_stream(stream,bih.clr_important );
1476  }
1477  }
1478 
1479  inline std::size_t file_size(const std::string& file_name)
1480  {
1481  std::ifstream file(file_name.c_str(),std::ios::in | std::ios::binary);
1482  if (!file) return 0;
1483  file.seekg (0, std::ios::end);
1484  return static_cast<std::size_t>(file.tellg());
1485  }
1486 
1487  void create_bitmap()
1488  {
1489  row_increment_ = width_ * bytes_per_pixel_;
1490  data_.resize(height_ * row_increment_);
1491  }
1492 
1493  void load_bitmap()
1494  {
1495  std::ifstream stream(file_name_.c_str(),std::ios::binary);
1496 
1497  if (!stream)
1498  {
1499  std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - file " << file_name_ << " not found!" << std::endl;
1500  return;
1501  }
1502 
1503  width_ = 0;
1504  height_ = 0;
1505 
1506  bitmap_file_header bfh;
1507  bitmap_information_header bih;
1508 
1509  bfh.clear();
1510  bih.clear();
1511 
1512  read_bfh(stream,bfh);
1513  read_bih(stream,bih);
1514 
1515  if (bfh.type != 19778)
1516  {
1517  bfh.clear();
1518  bih.clear();
1519 
1520  stream.close();
1521 
1522  std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid type value " << bfh.type << " expected 19778." << std::endl;
1523  return;
1524  }
1525 
1526  if (bih.bit_count != 24)
1527  {
1528  bfh.clear();
1529  bih.clear();
1530 
1531  stream.close();
1532 
1533  std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid bit depth " << bih.bit_count << " expected 24." << std::endl;
1534 
1535  return;
1536  }
1537 
1538  if (bih.size != bih.struct_size())
1539  {
1540  bfh.clear();
1541  bih.clear();
1542 
1543  stream.close();
1544 
1545  std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid BIH size " << bih.size << " expected " << bih.struct_size() << std::endl;
1546 
1547  return;
1548  }
1549 
1550  width_ = bih.width;
1551  height_ = bih.height;
1552 
1553  bytes_per_pixel_ = bih.bit_count >> 3;
1554 
1555  unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
1556  char padding_data[4] = {0,0,0,0};
1557 
1558  std::size_t bitmap_file_size = file_size(file_name_);
1559 
1560  std::size_t bitmap_logical_size = (height_ * width_ * bytes_per_pixel_) +
1561  (height_ * padding) +
1562  bih.struct_size() +
1563  bfh.struct_size() ;
1564 
1565  if (bitmap_file_size != bitmap_logical_size)
1566  {
1567  bfh.clear();
1568  bih.clear();
1569 
1570  stream.close();
1571 
1572  std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Mismatch between logical and physical sizes of bitmap. " <<
1573  "Logical: " << bitmap_logical_size << " " <<
1574  "Physical: " << bitmap_file_size << std::endl;
1575 
1576  return;
1577  }
1578 
1579  create_bitmap();
1580 
1581  for (unsigned int i = 0; i < height_; ++i)
1582  {
1583  unsigned char* data_ptr = row(height_ - i - 1); // read in inverted row order
1584 
1585  stream.read(reinterpret_cast<char*>(data_ptr), sizeof(char) * bytes_per_pixel_ * width_);
1586  stream.read(padding_data,padding);
1587  }
1588  }
1589 
1590  template <typename T>
1591  inline T clamp(const T& v, const T& lower_range, const T& upper_range)
1592  {
1593  if (v < lower_range)
1594  return lower_range;
1595  else if (v > upper_range)
1596  return upper_range;
1597  else
1598  return v;
1599  }
1600 
1601  std::string file_name_;
1602  unsigned int width_;
1603  unsigned int height_;
1604  unsigned int row_increment_;
1605  unsigned int bytes_per_pixel_;
1606  channel_mode channel_mode_;
1607  std::vector<unsigned char> data_;
1608 };
1609 
1610 struct rgb_t
1611 {
1612  unsigned char red;
1613  unsigned char green;
1614  unsigned char blue;
1615 };
1616 
1617 inline bool operator==(const rgb_t& c0, const rgb_t& c1)
1618 {
1619  return (c0.red == c1 .red) &&
1620  (c0.green == c1.green) &&
1621  (c0.blue == c1 .blue);
1622 }
1623 
1624 inline bool operator!=(const rgb_t& c0, const rgb_t& c1)
1625 {
1626  return (c0.red != c1 .red) ||
1627  (c0.green != c1.green) ||
1628  (c0.blue != c1 .blue);
1629 }
1630 
1631 inline std::size_t hamming_distance(const rgb_t& c0, const rgb_t& c1)
1632 {
1633  std::size_t result = 0;
1634 
1635  if (c0.red != c1 .red) ++result;
1636  if (c0.green != c1.green) ++result;
1637  if (c0.blue != c1 .blue) ++result;
1638 
1639  return result;
1640 }
1641 
1642 inline rgb_t make_colour(const unsigned int& red, const unsigned int& green, const unsigned int& blue)
1643 {
1644  rgb_t result;
1645 
1646  result.red = static_cast<unsigned char>(red );
1647  result.green = static_cast<unsigned char>(green);
1648  result.blue = static_cast<unsigned char>(blue );
1649 
1650  return result;
1651 }
1652 
1653 template <typename OutputIterator>
1654 inline void generate_colours(const std::size_t& steps, const rgb_t c0, const rgb_t& c1, OutputIterator out)
1655 {
1656  double dr = ((double)c1.red - (double)c0.red ) / steps;
1657  double dg = ((double)c1.green - (double)c0.green ) / steps;
1658  double db = ((double)c1.blue - (double)c0.blue ) / steps;
1659 
1660  for (std::size_t i = 0; i < steps; ++i)
1661  {
1662  rgb_t c;
1663 
1664  c.red = static_cast<unsigned char>(c0.red + (i * dr));
1665  c.green = static_cast<unsigned char>(c0.green + (i * dg));
1666  c.blue = static_cast<unsigned char>(c0.blue + (i * db));
1667 
1668  *(out++) = c;
1669  }
1670 }
1671 
1672 template <typename ResponseImage, typename Palette>
1673 inline std::size_t convert_rsp_to_image(const ResponseImage& resp_image, const Palette& palette, bitmap_image& image)
1674 {
1675  if (
1676  (resp_image.width () > image.width ()) ||
1677  (resp_image.height() > image.height())
1678  )
1679  return 0;
1680 
1681  for (std::size_t y = 0; y < resp_image.height(); ++y)
1682  {
1683  for (std::size_t x = 0; x < resp_image.width(); ++x)
1684  {
1685  const double v = resp_image(x,y);
1686 
1687  unsigned int index = static_cast<unsigned int>((v < 0) ? 0 : v > (palette.size()) ? (palette.size() - 1) : v);
1688 
1689  image.set_pixel(x,y,palette[index]);
1690  }
1691  }
1692 
1693  return (resp_image.width() * resp_image.height());
1694 }
1695 
1696 inline void rgb_to_ycbcr(const unsigned int& length, double* red, double* green, double* blue,
1697  double* y, double* cb, double* cr)
1698 {
1699  unsigned int i = 0;
1700 
1701  while (i < length)
1702  {
1703  ( *y) = 16.0 + ( 65.481 * (*red) + 128.553 * (*green) + 24.966 * (*blue));
1704  (*cb) = 128.0 + ( -37.797 * (*red) + -74.203 * (*green) + 112.000 * (*blue));
1705  (*cr) = 128.0 + ( 112.000 * (*red) + -93.786 * (*green) - 18.214 * (*blue));
1706 
1707  ++i;
1708  ++red; ++green; ++blue;
1709  ++y; ++cb; ++cr;
1710  }
1711 }
1712 
1713 inline void ycbcr_to_rgb(const unsigned int& length, double* y, double* cb, double* cr,
1714  double* red, double* green, double* blue)
1715 {
1716  unsigned int i = 0;
1717 
1718  while (i < length)
1719  {
1720  double y_ = (*y) - 16.0;
1721  double cb_ = (*cb) - 128.0;
1722  double cr_ = (*cr) - 128.0;
1723 
1724  (*red) = 0.000456621 * y_ + 0.00625893 * cr_;
1725  (*green) = 0.000456621 * y_ - 0.00153632 * cb_ - 0.00318811 * cr_;
1726  (*blue) = 0.000456621 * y_ + 0.00791071 * cb_;
1727 
1728  ++i;
1729  ++red; ++green; ++blue;
1730  ++y; ++cb; ++cr;
1731  }
1732 }
1733 
1734 inline void subsample(const unsigned int& width,
1735  const unsigned int& height,
1736  const double* source,
1737  unsigned int& w,
1738  unsigned int& h,
1739  double*& dest)
1740 {
1741  /* Single channel. */
1742 
1743  w = 0;
1744  h = 0;
1745 
1746  bool odd_width = false;
1747  bool odd_height = false;
1748 
1749  if (0 == (width % 2))
1750  w = width / 2;
1751  else
1752  {
1753  w = 1 + (width / 2);
1754  odd_width = true;
1755  }
1756 
1757  if (0 == (height % 2))
1758  h = height / 2;
1759  else
1760  {
1761  h = 1 + (height / 2);
1762  odd_height = true;
1763  }
1764 
1765  unsigned int horizontal_upper = (odd_width) ? w - 1 : w;
1766  unsigned int vertical_upper = (odd_height) ? h - 1 : h;
1767 
1768  dest = new double[w * h];
1769 
1770  double* s_itr = dest;
1771  const double* itr1 = source;
1772  const double* itr2 = source + width;
1773 
1774  for (unsigned int j = 0; j < vertical_upper; ++j)
1775  {
1776  for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr)
1777  {
1778  (*s_itr) = *(itr1++);
1779  (*s_itr) += *(itr1++);
1780  (*s_itr) += *(itr2++);
1781  (*s_itr) += *(itr2++);
1782  (*s_itr) /= 4.0;
1783  }
1784 
1785  if (odd_width)
1786  {
1787  (*(s_itr++)) = ((*itr1++) + (*itr2++)) / 2.0;
1788  }
1789 
1790  itr1 += width;
1791 
1792  if (j != (vertical_upper -1))
1793  {
1794  itr2 += width;
1795  }
1796  }
1797 
1798  if (odd_height)
1799  {
1800  for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr)
1801  {
1802  (*s_itr) += (*(itr1++));
1803  (*s_itr) += (*(itr1++));
1804  (*s_itr) /= 2.0;
1805  }
1806 
1807  if (odd_width)
1808  {
1809  (*(s_itr++)) = (*itr1);
1810  }
1811  }
1812 }
1813 
1814 inline void upsample(const unsigned int& width,
1815  const unsigned int& height,
1816  const double* source,
1817  unsigned int& w,
1818  unsigned int& h,
1819  double*& dest)
1820 {
1821  /* Single channel. */
1822 
1823  w = 2 * width;
1824  h = 2 * height;
1825 
1826  dest = new double[w * h];
1827 
1828  const double* s_itr = source;
1829  double* itr1 = dest;
1830  double* itr2 = dest + w;
1831 
1832  for (unsigned int j = 0; j < height; ++j)
1833  {
1834  for (unsigned int i = 0; i < width; ++i, ++s_itr)
1835  {
1836  *(itr1++) = (*s_itr);
1837  *(itr1++) = (*s_itr);
1838  *(itr2++) = (*s_itr);
1839  *(itr2++) = (*s_itr);
1840  }
1841 
1842  itr1 += w;
1843  itr2 += w;
1844  }
1845 }
1846 
1847 inline void checkered_pattern(const unsigned int x_width,
1848  const unsigned int y_width,
1849  const unsigned char value,
1850  const bitmap_image::color_plane color,
1851  bitmap_image& image)
1852 {
1853  if (
1854  (x_width >= image.width ()) ||
1855  (y_width >= image.height())
1856  )
1857  {
1858  return;
1859  }
1860 
1861  bool setter_x = false;
1862  bool setter_y = true;
1863 
1864  const unsigned int color_plane_offset = image.offset(color);
1865  const unsigned int height = image.height();
1866  const unsigned int width = image.width();
1867 
1868  for (unsigned int y = 0; y < height; ++y)
1869  {
1870  if (0 == (y % y_width))
1871  {
1872  setter_y = !setter_y;
1873  }
1874 
1875  unsigned char* row = image.row(y) + color_plane_offset;
1876 
1877  for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel())
1878  {
1879  if (0 == (x % x_width))
1880  {
1881  setter_x = !setter_x;
1882  }
1883 
1884  if (setter_x ^ setter_y)
1885  {
1886  *row = value;
1887  }
1888  }
1889  }
1890 }
1891 
1892 inline void checkered_pattern(const unsigned int x_width,
1893  const unsigned int y_width,
1894  const unsigned char red,
1895  const unsigned char green,
1896  const unsigned char blue,
1897  bitmap_image& image)
1898 {
1899  if (
1900  (x_width >= image.width ()) ||
1901  (y_width >= image.height())
1902  )
1903  {
1904  return;
1905  }
1906 
1907  bool setter_x = false;
1908  bool setter_y = true;
1909 
1910  const unsigned int height = image.height();
1911  const unsigned int width = image.width();
1912 
1913  for (unsigned int y = 0; y < height; ++y)
1914  {
1915  if (0 == (y % y_width))
1916  {
1917  setter_y = !setter_y;
1918  }
1919 
1920  unsigned char* row = image.row(y);
1921 
1922  for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel())
1923  {
1924  if (0 == (x % x_width))
1925  {
1926  setter_x = !setter_x;
1927  }
1928 
1929  if (setter_x ^ setter_y)
1930  {
1931  *(row + 0) = blue;
1932  *(row + 1) = green;
1933  *(row + 2) = red;
1934  }
1935  }
1936  }
1937 }
1938 
1939 inline void plasma(bitmap_image& image,
1940  const double& x, const double& y,
1941  const double& width, const double& height,
1942  const double& c1, const double& c2,
1943  const double& c3, const double& c4,
1944  const double& roughness = 3.0,
1945  const rgb_t colormap[] = 0)
1946 {
1947  // Note: c1,c2,c3,c4 -> [0.0,1.0]
1948 
1949  double half_width = ( width / 2.0);
1950  double half_height = (height / 2.0);
1951 
1952  if ((width >= 1.0) || (height >= 1.0))
1953  {
1954  double corner1 = (c1 + c2) / 2.0;
1955  double corner2 = (c2 + c3) / 2.0;
1956  double corner3 = (c3 + c4) / 2.0;
1957  double corner4 = (c4 + c1) / 2.0;
1958  double center = (c1 + c2 + c3 + c4) / 4.0 +
1959  ((1.0 * ::rand() /(1.0 * RAND_MAX)) - 0.5) * // should use a better rng
1960  ((1.0 * half_width + half_height) / (image.width() + image.height()) * roughness);
1961 
1962  center = std::min<double>(std::max<double>(0.0,center),1.0);
1963 
1964  plasma(image, x, y, half_width, half_height, c1, corner1, center, corner4,roughness,colormap);
1965  plasma(image, x + half_width, y, half_width, half_height, corner1, c2, corner2, center,roughness,colormap);
1966  plasma(image, x + half_width, y + half_height, half_width, half_height, center, corner2, c3, corner3,roughness,colormap);
1967  plasma(image, x, y + half_height, half_width, half_height, corner4, center, corner3, c4,roughness,colormap);
1968  }
1969  else
1970  {
1971  rgb_t color = colormap[static_cast<unsigned int>(1000.0 * ((c1 + c2 + c3 + c4) / 4.0)) % 1000];
1972 
1973  image.set_pixel(static_cast<unsigned int>(x),static_cast<unsigned int>(y),color);
1974  }
1975 }
1976 
1977 inline void plasma(bitmap_image& image,
1978  const double& c1, const double& c2,
1979  const double& c3, const double& c4,
1980  const double& roughness = 3.0,
1981  const rgb_t colormap[] = 0)
1982 {
1983  plasma
1984  (
1985  image, 0, 0, image.width(), image.height(),
1986  c1, c2, c3, c4,
1987  roughness, colormap
1988  );
1989 }
1990 
1991 inline double psnr_region(const unsigned int& x, const unsigned int& y,
1992  const unsigned int& width, const unsigned int& height,
1993  const bitmap_image& image1, const bitmap_image& image2)
1994 {
1995  if (
1996  (image1.width() != image2.width ()) ||
1997  (image1.height() != image2.height())
1998  )
1999  {
2000  return 0.0;
2001  }
2002 
2003  if ((x + width ) > image1.width() ) { return 0.0; }
2004  if ((y + height) > image1.height()) { return 0.0; }
2005 
2006  double mse = 0.0;
2007 
2008  for (unsigned int r = 0; r < height; ++r)
2009  {
2010  const unsigned char* itr1 = image1.row(r + y) + x * image1.bytes_per_pixel();
2011  const unsigned char* itr1_end = itr1 + (width * image1.bytes_per_pixel());
2012  const unsigned char* itr2 = image2.row(r + y) + x * image2.bytes_per_pixel();
2013 
2014  while (itr1 != itr1_end)
2015  {
2016  double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
2017  mse += v * v;
2018  ++itr1;
2019  ++itr2;
2020  }
2021  }
2022 
2023  if (mse <= 0.0000001)
2024  {
2025  return 1000000.0;
2026  }
2027  else
2028  {
2029  mse /= (3.0 * width * height);
2030  return 20.0 * std::log10(255.0 / std::sqrt(mse));
2031  }
2032 }
2033 
2034 inline void hierarchical_psnr_r(const double& x, const double& y,
2035  const double& width, const double& height,
2036  const bitmap_image& image1,
2037  bitmap_image& image2,
2038  const double& threshold,
2039  const rgb_t colormap[])
2040 {
2041  if ((width <= 4.0) || (height <= 4.0))
2042  {
2043  double psnr = psnr_region(
2044  static_cast<unsigned int>(x),
2045  static_cast<unsigned int>(y),
2046  static_cast<unsigned int>(width),
2047  static_cast<unsigned int>(height),
2048  image1, image2
2049  );
2050 
2051  if (psnr < threshold)
2052  {
2053  rgb_t c = colormap[static_cast<unsigned int>(1000.0 * (1.0 - (psnr / threshold)))];
2054 
2055  image2.set_region(
2056  static_cast<unsigned int>(x),
2057  static_cast<unsigned int>(y),
2058  static_cast<unsigned int>(width + 1),
2059  static_cast<unsigned int>(height + 1),
2060  c.red, c.green, c.blue
2061  );
2062  }
2063  }
2064  else
2065  {
2066  double half_width = ( width / 2.0);
2067  double half_height = (height / 2.0);
2068 
2069  hierarchical_psnr_r(x , y , half_width, half_height, image1, image2, threshold, colormap);
2070  hierarchical_psnr_r(x + half_width, y , half_width, half_height, image1, image2, threshold, colormap);
2071  hierarchical_psnr_r(x + half_width, y + half_height, half_width, half_height, image1, image2, threshold, colormap);
2072  hierarchical_psnr_r(x , y + half_height, half_width, half_height, image1, image2, threshold, colormap);
2073  }
2074 }
2075 
2076 inline void hierarchical_psnr(bitmap_image& image1, bitmap_image& image2, const double threshold, const rgb_t colormap[])
2077 {
2078  if (
2079  (image1.width() != image2.width ()) ||
2080  (image1.height() != image2.height())
2081  )
2082  {
2083  return;
2084  }
2085 
2086  double psnr = psnr_region(0,0,image1.width(),image1.height(),image1,image2);
2087 
2088  if (psnr < threshold)
2089  {
2090  hierarchical_psnr_r(0, 0, image1.width(), image1.height(),
2091  image1, image2,
2092  threshold, colormap);
2093  }
2094 }
2095 
2097 {
2098 public:
2099 
2101  : image_(image),
2102  pen_width_(1),
2103  pen_color_red_ (0),
2104  pen_color_green_(0),
2105  pen_color_blue_ (0)
2106  {}
2107 
2108  void rectangle(int x1, int y1, int x2, int y2)
2109  {
2110  line_segment(x1,y1,x2,y1);
2111  line_segment(x2,y1,x2,y2);
2112  line_segment(x2,y2,x1,y2);
2113  line_segment(x1,y2,x1,y1);
2114  }
2115 
2116  void triangle(int x1, int y1, int x2, int y2,int x3, int y3)
2117  {
2118  line_segment(x1,y1,x2,y2);
2119  line_segment(x2,y2,x3,y3);
2120  line_segment(x3,y3,x1,y1);
2121  }
2122 
2123  void quadix(int x1, int y1, int x2, int y2,int x3, int y3, int x4, int y4)
2124  {
2125  line_segment(x1,y1,x2,y2);
2126  line_segment(x2,y2,x3,y3);
2127  line_segment(x3,y3,x4,y4);
2128  line_segment(x4,y4,x1,y1);
2129  }
2130 
2131  void line_segment(int x1, int y1, int x2, int y2)
2132  {
2133  int steep = 0;
2134  int sx = ((x2 - x1) > 0) ? 1 : -1;
2135  int sy = ((y2 - y1) > 0) ? 1 : -1;
2136  int dx = abs(x2 - x1);
2137  int dy = abs(y2 - y1);
2138 
2139  if (dy > dx)
2140  {
2141  std::swap(x1,y1);
2142  std::swap(dx,dy);
2143  std::swap(sx,sy);
2144 
2145  steep = 1;
2146  }
2147 
2148  int e = 2 * dy - dx;
2149 
2150  for (int i = 0; i < dx; ++i)
2151  {
2152  if (steep)
2153  plot_pen_pixel(y1,x1);
2154  else
2155  plot_pen_pixel(x1,y1);
2156 
2157  while (e >= 0)
2158  {
2159  y1 += sy;
2160  e -= (dx << 1);
2161  }
2162 
2163  x1 += sx;
2164  e += (dy << 1);
2165  }
2166 
2167  plot_pen_pixel(x2,y2);
2168  }
2169 
2170  void horiztonal_line_segment(int x1, int x2, int y)
2171  {
2172  if (x1 > x2)
2173  {
2174  std::swap(x1,x2);
2175  }
2176 
2177  for (int i = 0; i < (x2 - x1); ++i)
2178  {
2179  plot_pen_pixel(x1 + i,y);
2180  }
2181  }
2182 
2183  void vertical_line_segment(int y1, int y2, int x)
2184  {
2185  if (y1 > y2)
2186  {
2187  std::swap(y1,y2);
2188  }
2189 
2190  for (int i = 0; i < (y2 - y1); ++i)
2191  {
2192  plot_pen_pixel(x, y1 + i);
2193  }
2194  }
2195 
2196  void ellipse(int centerx, int centery, int a, int b)
2197  {
2198  int t1 = a * a;
2199  int t2 = t1 << 1;
2200  int t3 = t2 << 1;
2201  int t4 = b * b;
2202  int t5 = t4 << 1;
2203  int t6 = t5 << 1;
2204  int t7 = a * t5;
2205  int t8 = t7 << 1;
2206  int t9 = 0;
2207 
2208  int d1 = t2 - t7 + (t4 >> 1);
2209  int d2 = (t1 >> 1) - t8 + t5;
2210  int x = a;
2211  int y = 0;
2212 
2213  int negative_tx = centerx - x;
2214  int positive_tx = centerx + x;
2215  int negative_ty = centery - y;
2216  int positive_ty = centery + y;
2217 
2218  while (d2 < 0)
2219  {
2220  plot_pen_pixel(positive_tx, positive_ty);
2221  plot_pen_pixel(positive_tx, negative_ty);
2222  plot_pen_pixel(negative_tx, positive_ty);
2223  plot_pen_pixel(negative_tx, negative_ty);
2224 
2225  ++y;
2226 
2227  t9 = t9 + t3;
2228 
2229  if (d1 < 0)
2230  {
2231  d1 = d1 + t9 + t2;
2232  d2 = d2 + t9;
2233  }
2234  else
2235  {
2236  x--;
2237  t8 = t8 - t6;
2238  d1 = d1 + (t9 + t2 - t8);
2239  d2 = d2 + (t9 + t5 - t8);
2240  negative_tx = centerx - x;
2241  positive_tx = centerx + x;
2242  }
2243 
2244  negative_ty = centery - y;
2245  positive_ty = centery + y;
2246  }
2247 
2248  do
2249  {
2250  plot_pen_pixel(positive_tx, positive_ty);
2251  plot_pen_pixel(positive_tx, negative_ty);
2252  plot_pen_pixel(negative_tx, positive_ty);
2253  plot_pen_pixel(negative_tx, negative_ty);
2254 
2255  x--;
2256  t8 = t8 - t6;
2257 
2258  if (d2 < 0)
2259  {
2260  ++y;
2261  t9 = t9 + t3;
2262  d2 = d2 + (t9 + t5 - t8);
2263  negative_ty = centery - y;
2264  positive_ty = centery + y;
2265  }
2266  else
2267  d2 = d2 + (t5 - t8);
2268 
2269  negative_tx = centerx - x;
2270  positive_tx = centerx + x;
2271  }
2272  while (x >= 0);
2273  }
2274 
2275  void circle(int centerx, int centery, int radius)
2276  {
2277  int x = 0;
2278  int d = (1 - radius) << 1;
2279 
2280  while (radius >= 0)
2281  {
2282  plot_pen_pixel(centerx + x, centery + radius);
2283  plot_pen_pixel(centerx + x, centery - radius);
2284  plot_pen_pixel(centerx - x, centery + radius);
2285  plot_pen_pixel(centerx - x, centery - radius);
2286 
2287  if ((d + radius) > 0)
2288  d -= ((--radius) << 1) - 1;
2289  if (x > d)
2290  d += ((++x) << 1) + 1;
2291  }
2292  }
2293 
2294  void plot_pen_pixel(int x, int y)
2295  {
2296  switch (pen_width_)
2297  {
2298  case 1 : plot_pixel(x,y);
2299  break;
2300 
2301  case 2 : {
2302  plot_pixel(x , y );
2303  plot_pixel(x + 1, y );
2304  plot_pixel(x + 1, y + 1);
2305  plot_pixel(x , y + 1);
2306  }
2307  break;
2308 
2309  case 3 : {
2310  plot_pixel(x , y - 1);
2311  plot_pixel(x - 1, y - 1);
2312  plot_pixel(x + 1, y - 1);
2313 
2314  plot_pixel(x , y );
2315  plot_pixel(x - 1, y );
2316  plot_pixel(x + 1, y );
2317 
2318  plot_pixel(x , y + 1);
2319  plot_pixel(x - 1, y + 1);
2320  plot_pixel(x + 1, y + 1);
2321  }
2322  break;
2323 
2324  default : plot_pixel(x,y);
2325  break;
2326  }
2327  }
2328 
2329  void plot_pixel(int x, int y)
2330  {
2331  if (
2332  (x < 0) ||
2333  (y < 0) ||
2334  (x >= static_cast<int>(image_.width ())) ||
2335  (y >= static_cast<int>(image_.height()))
2336  )
2337  return;
2338 
2339  image_.set_pixel(x,y,pen_color_red_,pen_color_green_,pen_color_blue_);
2340  }
2341 
2342  void pen_width(const unsigned int& width)
2343  {
2344  if ((width > 0) && (width < 4))
2345  {
2346  pen_width_ = width;
2347  }
2348  }
2349 
2350  void pen_color(const unsigned char& red,
2351  const unsigned char& green,
2352  const unsigned char& blue)
2353  {
2354  pen_color_red_ = red;
2355  pen_color_green_ = green;
2356  pen_color_blue_ = blue;
2357  }
2358 
2359  template <typename RGB>
2360  void pen_color(const RGB colour)
2361  {
2362  pen_color_red_ = colour.red;
2363  pen_color_green_ = colour.green;
2364  pen_color_blue_ = colour.blue;
2365  }
2366 
2367 private:
2368 
2369  image_drawer(const image_drawer& id);
2370  image_drawer& operator =(const image_drawer& id);
2371 
2372  bitmap_image& image_;
2373  unsigned int pen_width_;
2374  unsigned char pen_color_red_;
2375  unsigned char pen_color_green_;
2376  unsigned char pen_color_blue_;
2377 };
2378 
2380 {
2381 public:
2382 
2383  cartesian_canvas(const double x_length, const double y_length)
2384  : width_div2_ (0.0),
2385  height_div2_(0.0),
2386  min_x_ (0.0),
2387  min_y_ (0.0),
2388  max_x_ (0.0),
2389  max_y_ (0.0),
2390  draw_ (image_)
2391  {
2392  setup_canvas(x_length,y_length);
2393  }
2394 
2395  inline bool operator!()
2396  {
2397  return !image_;
2398  }
2399 
2400  void rectangle(double x1, double y1, double x2, double y2)
2401  {
2402  line_segment(x1, y1, x2, y1);
2403  line_segment(x2, y1, x2, y2);
2404  line_segment(x2, y2, x1, y2);
2405  line_segment(x1, y2, x1, y1);
2406  }
2407 
2408  void triangle(double x1, double y1, double x2, double y2, double x3, double y3)
2409  {
2410  line_segment(x1, y1, x2, y2);
2411  line_segment(x2, y2, x3, y3);
2412  line_segment(x3, y3, x1, y1);
2413  }
2414 
2415  void quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
2416  {
2417  line_segment(x1, y1, x2, y2);
2418  line_segment(x2, y2, x3, y3);
2419  line_segment(x3, y3, x4, y4);
2420  line_segment(x4, y4, x1, y1);
2421  }
2422 
2423  void line_segment(double x1, double y1, double x2, double y2)
2424  {
2425  if (clip(x1, y1, x2, y2))
2426  {
2427  const int sc_x1 = static_cast<int>(cart_to_screen_x(x1));
2428  const int sc_x2 = static_cast<int>(cart_to_screen_x(x2));
2429  const int sc_y1 = static_cast<int>(cart_to_screen_y(y1));
2430  const int sc_y2 = static_cast<int>(cart_to_screen_y(y2));
2431 
2432  draw_.line_segment(sc_x1, sc_y1, sc_x2, sc_y2);
2433  }
2434  }
2435 
2436  void horiztonal_line_segment(double x1, double x2, double y)
2437  {
2438  x1 = clamp_x(x1);
2439  x2 = clamp_x(x2);
2440  y = clamp_y( y);
2441 
2442  const int sc_x1 = static_cast<int>(cart_to_screen_x(x1));
2443  const int sc_x2 = static_cast<int>(cart_to_screen_x(x2));
2444  const int sc_y = static_cast<int>(cart_to_screen_y(y ));
2445 
2446  draw_.horiztonal_line_segment(sc_x1, sc_x2, sc_y);
2447  }
2448 
2449  void vertical_line_segment(double y1, double y2, double x)
2450  {
2451  y1 = clamp_y(y1);
2452  y2 = clamp_y(y2);
2453  x = clamp_x( x);
2454 
2455  const int sc_y1 = static_cast<int>(cart_to_screen_y(y1));
2456  const int sc_y2 = static_cast<int>(cart_to_screen_y(y2));
2457  const int sc_x = static_cast<int>(cart_to_screen_x(x ));
2458 
2459  draw_.vertical_line_segment(sc_y1, sc_y2, sc_x);
2460  }
2461 
2462  void ellipse(double centerx, double centery, double a, double b)
2463  {
2464 
2465  const int sc_cx = static_cast<int>(cart_to_screen_x(centerx));
2466  const int sc_cy = static_cast<int>(cart_to_screen_y(centery));
2467 
2468  draw_.ellipse(sc_cx, sc_cy, static_cast<int>(a), static_cast<int>(b));
2469  }
2470 
2471  void circle(double centerx, double centery, double radius)
2472  {
2473  const int sc_cx = static_cast<int>(cart_to_screen_x(centerx));
2474  const int sc_cy = static_cast<int>(cart_to_screen_y(centery));
2475 
2476  draw_.circle(sc_cx, sc_cy, static_cast<int>(radius));
2477  }
2478 
2479  void fill_rectangle(double x1, double y1, double x2, double y2)
2480  {
2481  if (y1 > y2)
2482  std::swap(y1, y2);
2483 
2484  for (double y = y1; y <= y2; y += 0.5)
2485  {
2486  line_segment(x1, y, x2, y);
2487  }
2488  }
2489 
2490  void fill_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
2491  {
2492  typedef std::pair<double,double> point_t;
2493 
2494  std::vector<point_t> p;
2495 
2496  p.push_back(std::make_pair(x1,y1));
2497  p.push_back(std::make_pair(x2,y2));
2498  p.push_back(std::make_pair(x3,y3));
2499 
2500  if (p[0].second > p[1].second)
2501  std::swap(p[0],p[1]);
2502  if (p[0].second > p[2].second)
2503  std::swap(p[0],p[2]);
2504  if (p[1].second > p[2].second)
2505  std::swap(p[1],p[2]);
2506 
2507  class draw_modes
2508  {
2509  private:
2510 
2511  cartesian_canvas& canvas;
2512 
2513  // Needed for incompetent and broken msvc compiler versions
2514  #ifdef _MSC_VER
2515  #pragma warning(push)
2516  #pragma warning(disable: 4822)
2517  #endif
2518  draw_modes& operator=(const draw_modes&);
2519  #ifdef _MSC_VER
2520  #pragma warning(pop)
2521  #endif
2522 
2523  public:
2524 
2525  draw_modes(cartesian_canvas& c)
2526  : canvas(c)
2527  {}
2528 
2529  void bottom(const point_t& p0, const point_t& p1, const point_t& p2)
2530  {
2531  double m0 = (p1.first - p0.first) / (2.0 * (p1.second - p0.second));
2532  double m1 = (p2.first - p0.first) / (2.0 * (p2.second - p0.second));
2533 
2534  double x0 = p0.first;
2535  double x1 = p0.first;
2536 
2537  for (double y = p0.second; y <= p1.second; y += 0.5)
2538  {
2539  canvas.horiztonal_line_segment(x0, x1, y);
2540 
2541  x0 += m0;
2542  x1 += m1;
2543  }
2544  }
2545 
2546  void top(const point_t& p0, const point_t& p1, const point_t& p2)
2547  {
2548  double m0 = (p2.first - p0.first) / (2.0 * (p2.second - p0.second));
2549  double m1 = (p2.first - p1.first) / (2.0 * (p2.second - p1.second));
2550 
2551  double x0 = p2.first;
2552  double x1 = p2.first;
2553 
2554  for (double y = p2.second; y >= p0.second; y -= 0.5)
2555  {
2556  canvas.horiztonal_line_segment(x0, x1, y);
2557 
2558  x0 -= m0;
2559  x1 -= m1;
2560  }
2561  }
2562  };
2563 
2564  draw_modes dm(*this);
2565 
2566  const double eps = 0.00001;
2567 
2568  if (std::abs(p[1].second - p[2].second) < eps)
2569  dm.bottom(p[0], p[1], p[2]);
2570  else if (std::abs(p[0].second - p[1].second) < eps)
2571  dm.top(p[0], p[1], p[2]);
2572  else
2573  {
2574  point_t p3;
2575 
2576  p3.first = (p[0].first + ((p[1].second - p[0].second) / (p[2].second - p[0].second)) * (p[2].first - p[0].first));
2577  p3.second = p[1].second;
2578 
2579  dm.bottom(p[0], p[1], p3);
2580  dm.top (p[1], p3, p[2]);
2581  }
2582  }
2583 
2584  void fill_quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
2585  {
2586  fill_triangle(x1, y1, x2, y2, x3, y3);
2587  fill_triangle(x1, y1, x3, y3, x4, y4);
2588  }
2589 
2590  void fill_circle(double cx, double cy, double radius)
2591  {
2592  const double delta = 1.0;
2593  double x = radius;
2594  double y = 0.0;
2595  double dx = delta - (2.0 * delta * radius);
2596  double dy = 0.0;
2597  double dr = 0.0;
2598 
2599  while (x >= y)
2600  {
2601  for (double i = cx - x; i <= cx + x; i += delta)
2602  {
2603  horiztonal_line_segment(cx - x, cx + x, cy + y);
2604  horiztonal_line_segment(cx - x, cx + x, cy - y);
2605  }
2606 
2607  for (double i = cx - y; i <= cx + y; i += delta)
2608  {
2609  horiztonal_line_segment(cx - y, cx + y, cy + x);
2610  horiztonal_line_segment(cx - y, cx + y, cy - x);
2611  }
2612 
2613  y += delta;
2614 
2615  dr += dy;
2616  dy += 2.0 * delta;
2617 
2618  if ((2.0 * delta * dr + dx) > 0)
2619  {
2620  x -= delta;
2621  dr += dx;
2622  dx += 2.0 * delta;
2623  }
2624  }
2625  }
2626 
2627  void plot_pen_pixel(double x, double y)
2628  {
2629  if ((x < min_x_) || (x > max_x_)) return;
2630  if ((y < min_y_) || (y > max_y_)) return;
2631 
2632  const int sc_x = static_cast<int>(cart_to_screen_x(x));
2633  const int sc_y = static_cast<int>(cart_to_screen_y(y));
2634 
2635  draw_.plot_pen_pixel(sc_x, sc_y);
2636  }
2637 
2638  void plot_pixel(double x, double y)
2639  {
2640  if ((x < min_x_) || (x > max_x_)) return;
2641  if ((y < min_y_) || (y > max_y_)) return;
2642 
2643  const int sc_x = static_cast<int>(cart_to_screen_x(x));
2644  const int sc_y = static_cast<int>(cart_to_screen_y(y));
2645 
2646  draw_.plot_pixel(sc_x, sc_y);
2647  }
2648 
2649  void pen_width(const unsigned int& width)
2650  {
2651  draw_.pen_width(width);
2652  }
2653 
2654  void pen_color(const unsigned char& red,
2655  const unsigned char& green,
2656  const unsigned char& blue)
2657  {
2658  draw_.pen_color(red,green,blue);
2659  }
2660 
2661  template <typename RGB>
2662  void pen_color(const RGB colour)
2663  {
2664  draw_.pen_color(colour);
2665  }
2666 
2667  const bitmap_image& image() const
2668  {
2669  return image_;
2670  }
2671 
2673  {
2674  return image_;
2675  }
2676 
2677  void set_widthheight(const double x_length, const double y_length)
2678  {
2679  setup_canvas(x_length, y_length);
2680  }
2681 
2682  double min_x() const { return min_x_; }
2683  double min_y() const { return min_y_; }
2684  double max_x() const { return max_x_; }
2685  double max_y() const { return max_y_; }
2686 
2687 private:
2688 
2689  void setup_canvas(const double x_length, const double y_length)
2690  {
2691  if ((x_length < 2.0) || (y_length < 2.0))
2692  return;
2693 
2694  width_div2_ = x_length / 2.0;
2695  height_div2_ = y_length / 2.0;
2696 
2697  min_x_ = -width_div2_ ;
2698  min_y_ = -height_div2_;
2699  max_x_ = width_div2_ ;
2700  max_y_ = height_div2_;
2701 
2702  image_.setwidth_height(static_cast<unsigned int>(x_length) + 1, static_cast<unsigned int>(y_length) + 1);
2703 
2704  image_.clear(0xFF);
2705  }
2706 
2707  double clamp_x(const double& x)
2708  {
2709  if (x < min_x_) return min_x_;
2710  else if (x > max_x_) return max_x_;
2711  else return x;
2712  }
2713 
2714  double clamp_y(const double& y)
2715  {
2716  if (y < min_y_) return min_y_;
2717  else if (y > max_y_) return max_y_;
2718  else return y;
2719  }
2720 
2721  double cart_to_screen_x(const double& x)
2722  {
2723  return x + width_div2_;
2724  }
2725 
2726  double cart_to_screen_y(const double& y)
2727  {
2728  return height_div2_ - y;
2729  }
2730 
2731  enum clip_code
2732  {
2733  e_clip_bottom = 1,
2734  e_clip_top = 2,
2735  e_clip_left = 4,
2736  e_clip_right = 8
2737  };
2738 
2739  int out_code(
2740  const double& x, const double& y,
2741  const double& x1, const double& y1,
2742  const double& x2, const double& y2
2743  )
2744  {
2745  int result = 0;
2746  if (y < y1) result |= e_clip_bottom;
2747  else if (y > y2) result |= e_clip_top;
2748 
2749  if (x < x1) result |= e_clip_left;
2750  else if (x > x2) result |= e_clip_right;
2751 
2752  return result;
2753  }
2754 
2755  bool clip(double& x1, double& y1, double& x2, double& y2)
2756  {
2757  bool result = false;
2758  double x = 0.0;
2759  double y = 0.0;
2760 
2761  int outcode0 = out_code(x1, y1, min_x_, min_y_, max_x_, max_y_);
2762  int outcode1 = out_code(x2, y2, min_x_, min_y_, max_x_, max_y_);
2763  int outcodeout = 0;
2764 
2765  while ((outcode0 != 0) || (outcode1 != 0))
2766  {
2767  if ((outcode0 & outcode1) != 0)
2768  return result;
2769  else
2770  {
2771  if (outcode0 != 0)
2772  outcodeout = outcode0;
2773  else
2774  outcodeout = outcode1;
2775 
2776  double dx = (x2 - x1);
2777  double dy = (y2 - y1);
2778 
2779  if ((outcodeout & e_clip_bottom) == e_clip_bottom)
2780  {
2781  x = x1 + dx * (min_y_ - y1) / dy;
2782  y = min_y_;
2783  }
2784  else if ((outcodeout & e_clip_top) == e_clip_top)
2785  {
2786  x = x1 + dx * (max_y_ - y1) / dy;
2787  y = max_y_;
2788  }
2789  else if ((outcodeout & e_clip_right) == e_clip_right)
2790  {
2791  y = y1 + dy * (max_x_ - x1) / dx;
2792  x = max_x_;
2793  }
2794  else if ((outcodeout & e_clip_left) == e_clip_left)
2795  {
2796  y = y1 + dy * (min_x_ - x1) / dx;
2797  x = min_x_;
2798  }
2799 
2800  if (outcodeout == outcode0)
2801  {
2802  x1 = x;
2803  y1 = y;
2804  outcode0 = out_code(x1, y1, min_x_, min_y_, max_x_, max_y_);
2805  }
2806  else
2807  {
2808  x2 = x;
2809  y2 = y;
2810  outcode1 = out_code(x2, y2, min_x_, min_y_, max_x_, max_y_);
2811  }
2812  }
2813  }
2814 
2815  return true;
2816  }
2817 
2820 
2821  double width_div2_;
2822  double height_div2_;
2823  double min_x_;
2824  double min_y_;
2825  double max_x_;
2826  double max_y_;
2827  bitmap_image image_;
2828  image_drawer draw_;
2829 };
2830 
2831 inline rgb_t convert_wave_length_nm_to_rgb(const double wave_length_nm)
2832 {
2833  // Credits: Dan Bruton http://www.physics.sfasu.edu/astro/color.html
2834  double red = 0.0;
2835  double green = 0.0;
2836  double blue = 0.0;
2837 
2838  if ((380.0 <= wave_length_nm) && (wave_length_nm <= 439.0))
2839  {
2840  red = -(wave_length_nm - 440.0) / (440.0 - 380.0);
2841  green = 0.0;
2842  blue = 1.0;
2843  }
2844  else if ((440.0 <= wave_length_nm) && (wave_length_nm <= 489.0))
2845  {
2846  red = 0.0;
2847  green = (wave_length_nm - 440.0) / (490.0 - 440.0);
2848  blue = 1.0;
2849  }
2850  else if ((490.0 <= wave_length_nm) && (wave_length_nm <= 509.0))
2851  {
2852  red = 0.0;
2853  green = 1.0;
2854  blue = -(wave_length_nm - 510.0) / (510.0 - 490.0);
2855  }
2856  else if ((510.0 <= wave_length_nm) && (wave_length_nm <= 579.0))
2857  {
2858  red = (wave_length_nm - 510.0) / (580.0 - 510.0);
2859  green = 1.0;
2860  blue = 0.0;
2861  }
2862  else if ((580.0 <= wave_length_nm) && (wave_length_nm <= 644.0))
2863  {
2864  red = 1.0;
2865  green = -(wave_length_nm - 645.0) / (645.0 - 580.0);
2866  blue = 0.0;
2867  }
2868  else if ((645.0 <= wave_length_nm) && (wave_length_nm <= 780.0))
2869  {
2870  red = 1.0;
2871  green = 0.0;
2872  blue = 0.0;
2873  }
2874 
2875  double factor = 0.0;
2876 
2877  if ((380.0 <= wave_length_nm) && (wave_length_nm <= 419.0))
2878  factor = 0.3 + 0.7 * (wave_length_nm - 380.0) / (420.0 - 380.0);
2879  else if ((420.0 <= wave_length_nm) && (wave_length_nm <= 700.0))
2880  factor = 1.0;
2881  else if ((701.0 <= wave_length_nm) && (wave_length_nm <= 780.0))
2882  factor = 0.3 + 0.7 * (780.0 - wave_length_nm) / (780.0 - 700.0);
2883  else
2884  factor = 0.0;
2885 
2886  rgb_t result;
2887 
2888  const double gamma = 0.8;
2889  const double intensity_max = 255.0;
2890 
2891  #define round(d) std::floor(d + 0.5)
2892 
2893  result.red = static_cast<unsigned char>((red == 0.0) ? red : round(intensity_max * std::pow(red * factor, gamma)));
2894  result.green = static_cast<unsigned char>((green == 0.0) ? green : round(intensity_max * std::pow(green * factor, gamma)));
2895  result.blue = static_cast<unsigned char>((blue == 0.0) ? blue : round(intensity_max * std::pow(blue * factor, gamma)));
2896 
2897  #undef round
2898 
2899  return result;
2900 }
2901 
2902 inline double weighted_distance(const unsigned char r0, const unsigned char g0, const unsigned char b0,
2903  const unsigned char r1, const unsigned char g1, const unsigned char b1)
2904 {
2905  const double diff_r = /*0.30 */ (r0 - r1);
2906  const double diff_g = /*0.59 */ (g0 - g1);
2907  const double diff_b = /*0.11 */ (b0 - b1);
2908 
2909  return std::sqrt((diff_r * diff_r) + (diff_g * diff_g) + (diff_b * diff_b));
2910 }
2911 
2912 inline double weighted_distance(const rgb_t c0, const rgb_t c1)
2913 {
2914  return weighted_distance(c0.red, c0.green, c0.blue,
2915  c1.red, c1.green, c1.blue);
2916 }
2917 
2918 template <typename Iterator>
2919 inline rgb_t find_nearest_color(const rgb_t& c, const Iterator begin, const Iterator end)
2920 {
2921  if (0 == std::distance(begin,end))
2922  return c;
2923 
2924  double min_d = std::numeric_limits<double>::max();
2925  rgb_t result = *begin;
2926 
2927  for (Iterator itr = begin; itr != end; ++itr)
2928  {
2929  if (c == (*itr))
2930  {
2931  return (*itr);
2932  }
2933 
2934  double curr_d = weighted_distance(c,*itr);
2935 
2936  if (curr_d < min_d)
2937  {
2938  min_d = curr_d;
2939  result = *itr;
2940  }
2941  }
2942 
2943  return result;
2944 }
2945 
2946 template <template <typename,typename> class Sequence,
2947  typename Allocator>
2948 inline rgb_t find_nearest_color(const rgb_t& c, const Sequence<rgb_t,Allocator>& seq)
2949 {
2950  return find_nearest_color(c, seq.begin(),seq.end());
2951 }
2952 
2953 template <std::size_t N>
2954 inline rgb_t find_nearest_color(const rgb_t& c, const rgb_t (&colors)[N])
2955 {
2956  return find_nearest_color(c, colors, colors + N);
2957 }
2958 
2959 inline double find_nearest_wave_length(const rgb_t& c, const double increment = 0.001)
2960 {
2961  const double max_wave_length = 800.0; //800nm
2962 
2963  double min_wave_length = 0.0;
2964  double min_d = std::numeric_limits<double>::max();
2965 
2966  for (double i = 0.0; i < max_wave_length; i += increment)
2967  {
2968  rgb_t curr_rgb = convert_wave_length_nm_to_rgb(i);
2969 
2970  if (c == curr_rgb)
2971  {
2972  return i;
2973  }
2974 
2975  const double curr_d = weighted_distance(c, curr_rgb);
2976 
2977  if (curr_d <= min_d)
2978  {
2979  min_wave_length = i;
2980  min_d = curr_d;
2981  }
2982  }
2983 
2984  return min_wave_length;
2985 }
2986 
2987 template <typename T>
2989 {
2990 public:
2991 
2992  response_image(const std::size_t& width, const std::size_t& height, const T null = T(0))
2993  : width_ (width ),
2994  height_(height),
2995  null_ (null )
2996  {
2997  data_.resize(width_ * height_);
2998  }
2999 
3000  std::size_t width () const { return width_; }
3001  std::size_t height() const { return height_; }
3002 
3003  void set_all(const T& t)
3004  {
3005  std::fill_n(data_.begin(), data_.size(), t);
3006  }
3007 
3008  const T& operator()(const std::size_t& x, const std::size_t& y) const
3009  {
3010  if (y >= height_) return null_;
3011  if (x >= width_ ) return null_;
3012 
3013  return data_[width_ * y + x];
3014  }
3015 
3016  T& operator()(const std::size_t& x, const std::size_t& y)
3017  {
3018  if (y >= height_) return null_;
3019  if (x >= width_ ) return null_;
3020 
3021  return data_[width_ * y + x];
3022  }
3023 
3024  bool valid(const std::size_t& x, const std::size_t& y)
3025  {
3026  return ((x < width_ ) || (y < height_));
3027  }
3028 
3029  void inc_all(const T& v)
3030  {
3031  for (std::size_t i = 0; i < data_.size(); ++i)
3032  {
3033  data_[i] += v;
3034  }
3035  }
3036 
3037  void mul_all(const T& v)
3038  {
3039  for (std::size_t i = 0; i < data_.size(); ++i)
3040  {
3041  data_[i] *= v;
3042  }
3043  }
3044 
3045  T* row (const std::size_t& row_index)
3046  {
3047  if (row_index < height_)
3048  return &data_[width_ * row_index];
3049  else
3050  return reinterpret_cast<T*>(0);
3051  }
3052 
3053  const T* row (const std::size_t& row_index) const
3054  {
3055  if (row_index < height_)
3056  return data_[width_ * row_index];
3057  else
3058  return reinterpret_cast<T*>(0);
3059  }
3060 
3061 private:
3062 
3063  std::size_t width_;
3064  std::size_t height_;
3065  std::vector<T> data_;
3066  T null_;
3067 };
3068 
3069 inline void sobel_operator(const bitmap_image& src_image,
3070  bitmap_image& dst_image,
3071  const double threshold = 0.0)
3072 {
3073  typedef double T;
3074 
3075  response_image<T> im0(src_image.width(), src_image.height(), 0.0);
3076  response_image<T> im1(src_image.width(), src_image.height(), 0.0);
3077 
3078  src_image.export_gray_scale_response_image(&im0(0,0));
3079 
3080  for (std::size_t y = 1; y < im0.height() - 1; ++y)
3081  {
3082  const T* itr0 = im0.row(y - 1);
3083  const T* itr1 = im0.row(y );
3084  const T* itr2 = im0.row(y + 1);
3085  T* out = im1.row(y ) + 1;
3086 
3087  for (std::size_t x = 1; x < im0.width() - 1; ++x)
3088  {
3089  const T c0 = *(itr0 + x - 1); const T c1 = *(itr0 + x); const T c2 = *(itr0 + x + 1);
3090  const T c3 = *(itr1 + x - 1); /*const T c4 = *(itr1 + x);*/ const T c5 = *(itr1 + x + 1);
3091  const T c6 = *(itr2 + x - 1); const T c7 = *(itr2 + x); const T c8 = *(itr2 + x + 1);
3092 
3093  const T gx = (2.0 * (c5 - c3)) + (c2 - c0) + (c8 - c6);
3094  const T gy = (2.0 * (c1 - c7)) + (c0 - c6) + (c2 - c8);
3095 
3096  *(out++) = std::sqrt((gx * gx) + (gy * gy));
3097  }
3098  }
3099 
3100  if (threshold > 0.0)
3101  {
3102  const T* end = im1.row(0) + (im1.width() * im1.height());
3103 
3104  for (T* itr = im1.row(0); itr != end; ++itr)
3105  {
3106  T& v = *itr;
3107  if (v <= threshold) v = 0;
3108  }
3109  }
3110 
3111  dst_image.setwidth_height(im1.width(), im1.height());
3112  dst_image.import_gray_scale_clamped(&im1(0,0));
3113 }
3114 
3116 {
3127 };
3128 
3130  {255, 0, 0}, {255, 31, 0}, {255, 63, 0}, {255, 95, 0}, {255, 127, 0},
3131  {255, 159, 0}, {255, 191, 0}, {255, 223, 0}, {255, 255, 0}, {223, 255, 0},
3132  {191, 255, 0}, {159, 255, 0}, {127, 255, 0}, { 95, 255, 0}, { 63, 255, 0},
3133  { 31, 255, 0}, { 0, 255, 0}, { 0, 255, 31}, { 0, 255, 63}, { 0, 255, 95},
3134  { 0, 255, 127}, { 0, 255, 159}, { 0, 255, 191}, { 0, 255, 223}, { 0, 255, 255},
3135  { 0, 223, 255}, { 0, 191, 255}, { 0, 159, 255}, { 0, 127, 255}, { 0, 95, 255},
3136  { 0, 63, 255}, { 0, 31, 255}, { 0, 0, 255}, { 31, 0, 255}, { 63, 0, 255},
3137  { 95, 0, 255}, {127, 0, 255}, {159, 0, 255}, {191, 0, 255}, {223, 0, 255},
3138  {255, 0, 255}, {255, 0, 223}, {255, 0, 191}, {255, 0, 159}, {255, 0, 127},
3139  {255, 0, 95}, {255, 0, 63}, {255, 0, 31}, {255, 255, 255}, { 0, 0, 0}
3140 };
3141 
3142 const rgb_t autumn_colormap[1000] = {
3143  {255, 0, 0}, {255, 0, 0}, {255, 1, 0}, {255, 1, 0}, {255, 1, 0},
3144  {255, 1, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0},
3145  {255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 4, 0},
3146  {255, 4, 0}, {255, 4, 0}, {255, 4, 0}, {255, 5, 0}, {255, 5, 0},
3147  {255, 5, 0}, {255, 5, 0}, {255, 6, 0}, {255, 6, 0}, {255, 6, 0},
3148  {255, 6, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0},
3149  {255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 9, 0},
3150  {255, 9, 0}, {255, 9, 0}, {255, 9, 0}, {255, 10, 0}, {255, 10, 0},
3151  {255, 10, 0}, {255, 10, 0}, {255, 11, 0}, {255, 11, 0}, {255, 11, 0},
3152  {255, 11, 0}, {255, 12, 0}, {255, 12, 0}, {255, 12, 0}, {255, 13, 0},
3153  {255, 13, 0}, {255, 13, 0}, {255, 13, 0}, {255, 14, 0}, {255, 14, 0},
3154  {255, 14, 0}, {255, 14, 0}, {255, 15, 0}, {255, 15, 0}, {255, 15, 0},
3155  {255, 15, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0},
3156  {255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 18, 0},
3157  {255, 18, 0}, {255, 18, 0}, {255, 18, 0}, {255, 19, 0}, {255, 19, 0},
3158  {255, 19, 0}, {255, 19, 0}, {255, 20, 0}, {255, 20, 0}, {255, 20, 0},
3159  {255, 20, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0},
3160  {255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
3161  {255, 23, 0}, {255, 23, 0}, {255, 23, 0}, {255, 24, 0}, {255, 24, 0},
3162  {255, 24, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0},
3163  {255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 27, 0},
3164  {255, 27, 0}, {255, 27, 0}, {255, 27, 0}, {255, 28, 0}, {255, 28, 0},
3165  {255, 28, 0}, {255, 28, 0}, {255, 29, 0}, {255, 29, 0}, {255, 29, 0},
3166  {255, 29, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0},
3167  {255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 32, 0},
3168  {255, 32, 0}, {255, 32, 0}, {255, 32, 0}, {255, 33, 0}, {255, 33, 0},
3169  {255, 33, 0}, {255, 33, 0}, {255, 34, 0}, {255, 34, 0}, {255, 34, 0},
3170  {255, 34, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0},
3171  {255, 36, 0}, {255, 36, 0}, {255, 36, 0}, {255, 37, 0}, {255, 37, 0},
3172  {255, 37, 0}, {255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 38, 0},
3173  {255, 38, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0},
3174  {255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 41, 0},
3175  {255, 41, 0}, {255, 41, 0}, {255, 41, 0}, {255, 42, 0}, {255, 42, 0},
3176  {255, 42, 0}, {255, 42, 0}, {255, 43, 0}, {255, 43, 0}, {255, 43, 0},
3177  {255, 43, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0},
3178  {255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 46, 0},
3179  {255, 46, 0}, {255, 46, 0}, {255, 46, 0}, {255, 47, 0}, {255, 47, 0},
3180  {255, 47, 0}, {255, 47, 0}, {255, 48, 0}, {255, 48, 0}, {255, 48, 0},
3181  {255, 48, 0}, {255, 49, 0}, {255, 49, 0}, {255, 49, 0}, {255, 50, 0},
3182  {255, 50, 0}, {255, 50, 0}, {255, 50, 0}, {255, 51, 0}, {255, 51, 0},
3183  {255, 51, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0}, {255, 52, 0},
3184  {255, 52, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0},
3185  {255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 55, 0},
3186  {255, 55, 0}, {255, 55, 0}, {255, 55, 0}, {255, 56, 0}, {255, 56, 0},
3187  {255, 56, 0}, {255, 56, 0}, {255, 57, 0}, {255, 57, 0}, {255, 57, 0},
3188  {255, 57, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0},
3189  {255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 60, 0},
3190  {255, 60, 0}, {255, 60, 0}, {255, 60, 0}, {255, 61, 0}, {255, 61, 0},
3191  {255, 61, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0},
3192  {255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 64, 0},
3193  {255, 64, 0}, {255, 64, 0}, {255, 64, 0}, {255, 65, 0}, {255, 65, 0},
3194  {255, 65, 0}, {255, 65, 0}, {255, 66, 0}, {255, 66, 0}, {255, 66, 0},
3195  {255, 66, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0},
3196  {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 69, 0},
3197  {255, 69, 0}, {255, 69, 0}, {255, 69, 0}, {255, 70, 0}, {255, 70, 0},
3198  {255, 70, 0}, {255, 70, 0}, {255, 71, 0}, {255, 71, 0}, {255, 71, 0},
3199  {255, 71, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0},
3200  {255, 73, 0}, {255, 73, 0}, {255, 73, 0}, {255, 74, 0}, {255, 74, 0},
3201  {255, 74, 0}, {255, 74, 0}, {255, 75, 0}, {255, 75, 0}, {255, 75, 0},
3202  {255, 75, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0},
3203  {255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 78, 0},
3204  {255, 78, 0}, {255, 78, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0},
3205  {255, 79, 0}, {255, 79, 0}, {255, 80, 0}, {255, 80, 0}, {255, 80, 0},
3206  {255, 80, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0},
3207  {255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 83, 0},
3208  {255, 83, 0}, {255, 83, 0}, {255, 83, 0}, {255, 84, 0}, {255, 84, 0},
3209  {255, 84, 0}, {255, 84, 0}, {255, 85, 0}, {255, 85, 0}, {255, 85, 0},
3210  {255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 87, 0},
3211  {255, 87, 0}, {255, 87, 0}, {255, 87, 0}, {255, 88, 0}, {255, 88, 0},
3212  {255, 88, 0}, {255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 89, 0},
3213  {255, 89, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0},
3214  {255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 92, 0},
3215  {255, 92, 0}, {255, 92, 0}, {255, 92, 0}, {255, 93, 0}, {255, 93, 0},
3216  {255, 93, 0}, {255, 93, 0}, {255, 94, 0}, {255, 94, 0}, {255, 94, 0},
3217  {255, 94, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0},
3218  {255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 97, 0},
3219  {255, 97, 0}, {255, 97, 0}, {255, 98, 0}, {255, 98, 0}, {255, 98, 0},
3220  {255, 98, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0},
3221  {255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 101, 0},
3222  {255, 101, 0}, {255, 101, 0}, {255, 101, 0}, {255, 102, 0}, {255, 102, 0},
3223  {255, 102, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0}, {255, 103, 0},
3224  {255, 103, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0},
3225  {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0},
3226  {255, 106, 0}, {255, 106, 0}, {255, 106, 0}, {255, 107, 0}, {255, 107, 0},
3227  {255, 107, 0}, {255, 107, 0}, {255, 108, 0}, {255, 108, 0}, {255, 108, 0},
3228  {255, 108, 0}, {255, 109, 0}, {255, 109, 0}, {255, 109, 0}, {255, 110, 0},
3229  {255, 110, 0}, {255, 110, 0}, {255, 110, 0}, {255, 111, 0}, {255, 111, 0},
3230  {255, 111, 0}, {255, 111, 0}, {255, 112, 0}, {255, 112, 0}, {255, 112, 0},
3231  {255, 112, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0},
3232  {255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 115, 0},
3233  {255, 115, 0}, {255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 116, 0},
3234  {255, 116, 0}, {255, 116, 0}, {255, 117, 0}, {255, 117, 0}, {255, 117, 0},
3235  {255, 117, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0},
3236  {255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 120, 0},
3237  {255, 120, 0}, {255, 120, 0}, {255, 120, 0}, {255, 121, 0}, {255, 121, 0},
3238  {255, 121, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0},
3239  {255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 124, 0},
3240  {255, 124, 0}, {255, 124, 0}, {255, 124, 0}, {255, 125, 0}, {255, 125, 0},
3241  {255, 125, 0}, {255, 125, 0}, {255, 126, 0}, {255, 126, 0}, {255, 126, 0},
3242  {255, 126, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0},
3243  {255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 129, 0},
3244  {255, 129, 0}, {255, 129, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
3245  {255, 130, 0}, {255, 130, 0}, {255, 131, 0}, {255, 131, 0}, {255, 131, 0},
3246  {255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0},
3247  {255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 134, 0},
3248  {255, 134, 0}, {255, 134, 0}, {255, 135, 0}, {255, 135, 0}, {255, 135, 0},
3249  {255, 135, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0},
3250  {255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 138, 0},
3251  {255, 138, 0}, {255, 138, 0}, {255, 138, 0}, {255, 139, 0}, {255, 139, 0},
3252  {255, 139, 0}, {255, 139, 0}, {255, 140, 0}, {255, 140, 0}, {255, 140, 0},
3253  {255, 140, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0},
3254  {255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 143, 0},
3255  {255, 143, 0}, {255, 143, 0}, {255, 143, 0}, {255, 144, 0}, {255, 144, 0},
3256  {255, 144, 0}, {255, 144, 0}, {255, 145, 0}, {255, 145, 0}, {255, 145, 0},
3257  {255, 145, 0}, {255, 146, 0}, {255, 146, 0}, {255, 146, 0}, {255, 147, 0},
3258  {255, 147, 0}, {255, 147, 0}, {255, 147, 0}, {255, 148, 0}, {255, 148, 0},
3259  {255, 148, 0}, {255, 148, 0}, {255, 149, 0}, {255, 149, 0}, {255, 149, 0},
3260  {255, 149, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0},
3261  {255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 152, 0},
3262  {255, 152, 0}, {255, 152, 0}, {255, 152, 0}, {255, 153, 0}, {255, 153, 0},
3263  {255, 153, 0}, {255, 153, 0}, {255, 154, 0}, {255, 154, 0}, {255, 154, 0},
3264  {255, 154, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0},
3265  {255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
3266  {255, 157, 0}, {255, 157, 0}, {255, 157, 0}, {255, 158, 0}, {255, 158, 0},
3267  {255, 158, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0},
3268  {255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 161, 0},
3269  {255, 161, 0}, {255, 161, 0}, {255, 161, 0}, {255, 162, 0}, {255, 162, 0},
3270  {255, 162, 0}, {255, 162, 0}, {255, 163, 0}, {255, 163, 0}, {255, 163, 0},
3271  {255, 163, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0},
3272  {255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 166, 0},
3273  {255, 166, 0}, {255, 166, 0}, {255, 166, 0}, {255, 167, 0}, {255, 167, 0},
3274  {255, 167, 0}, {255, 167, 0}, {255, 168, 0}, {255, 168, 0}, {255, 168, 0},
3275  {255, 168, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0},
3276  {255, 170, 0}, {255, 170, 0}, {255, 170, 0}, {255, 171, 0}, {255, 171, 0},
3277  {255, 171, 0}, {255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 172, 0},
3278  {255, 172, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0},
3279  {255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 175, 0},
3280  {255, 175, 0}, {255, 175, 0}, {255, 175, 0}, {255, 176, 0}, {255, 176, 0},
3281  {255, 176, 0}, {255, 176, 0}, {255, 177, 0}, {255, 177, 0}, {255, 177, 0},
3282  {255, 177, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0},
3283  {255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 180, 0},
3284  {255, 180, 0}, {255, 180, 0}, {255, 180, 0}, {255, 181, 0}, {255, 181, 0},
3285  {255, 181, 0}, {255, 181, 0}, {255, 182, 0}, {255, 182, 0}, {255, 182, 0},
3286  {255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 184, 0},
3287  {255, 184, 0}, {255, 184, 0}, {255, 184, 0}, {255, 185, 0}, {255, 185, 0},
3288  {255, 185, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0}, {255, 186, 0},
3289  {255, 186, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0},
3290  {255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 189, 0},
3291  {255, 189, 0}, {255, 189, 0}, {255, 189, 0}, {255, 190, 0}, {255, 190, 0},
3292  {255, 190, 0}, {255, 190, 0}, {255, 191, 0}, {255, 191, 0}, {255, 191, 0},
3293  {255, 191, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0},
3294  {255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 194, 0},
3295  {255, 194, 0}, {255, 194, 0}, {255, 195, 0}, {255, 195, 0}, {255, 195, 0},
3296  {255, 195, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0},
3297  {255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 198, 0},
3298  {255, 198, 0}, {255, 198, 0}, {255, 198, 0}, {255, 199, 0}, {255, 199, 0},
3299  {255, 199, 0}, {255, 199, 0}, {255, 200, 0}, {255, 200, 0}, {255, 200, 0},
3300  {255, 200, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0},
3301  {255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 203, 0},
3302  {255, 203, 0}, {255, 203, 0}, {255, 203, 0}, {255, 204, 0}, {255, 204, 0},
3303  {255, 204, 0}, {255, 204, 0}, {255, 205, 0}, {255, 205, 0}, {255, 205, 0},
3304  {255, 205, 0}, {255, 206, 0}, {255, 206, 0}, {255, 206, 0}, {255, 207, 0},
3305  {255, 207, 0}, {255, 207, 0}, {255, 207, 0}, {255, 208, 0}, {255, 208, 0},
3306  {255, 208, 0}, {255, 208, 0}, {255, 209, 0}, {255, 209, 0}, {255, 209, 0},
3307  {255, 209, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0},
3308  {255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 212, 0},
3309  {255, 212, 0}, {255, 212, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0},
3310  {255, 213, 0}, {255, 213, 0}, {255, 214, 0}, {255, 214, 0}, {255, 214, 0},
3311  {255, 214, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0},
3312  {255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 217, 0},
3313  {255, 217, 0}, {255, 217, 0}, {255, 217, 0}, {255, 218, 0}, {255, 218, 0},
3314  {255, 218, 0}, {255, 218, 0}, {255, 219, 0}, {255, 219, 0}, {255, 219, 0},
3315  {255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 221, 0},
3316  {255, 221, 0}, {255, 221, 0}, {255, 221, 0}, {255, 222, 0}, {255, 222, 0},
3317  {255, 222, 0}, {255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 223, 0},
3318  {255, 223, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0},
3319  {255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 226, 0},
3320  {255, 226, 0}, {255, 226, 0}, {255, 226, 0}, {255, 227, 0}, {255, 227, 0},
3321  {255, 227, 0}, {255, 227, 0}, {255, 228, 0}, {255, 228, 0}, {255, 228, 0},
3322  {255, 228, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0},
3323  {255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 231, 0},
3324  {255, 231, 0}, {255, 231, 0}, {255, 232, 0}, {255, 232, 0}, {255, 232, 0},
3325  {255, 232, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0},
3326  {255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 235, 0},
3327  {255, 235, 0}, {255, 235, 0}, {255, 235, 0}, {255, 236, 0}, {255, 236, 0},
3328  {255, 236, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0}, {255, 237, 0},
3329  {255, 237, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0},
3330  {255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0},
3331  {255, 240, 0}, {255, 240, 0}, {255, 240, 0}, {255, 241, 0}, {255, 241, 0},
3332  {255, 241, 0}, {255, 241, 0}, {255, 242, 0}, {255, 242, 0}, {255, 242, 0},
3333  {255, 242, 0}, {255, 243, 0}, {255, 243, 0}, {255, 243, 0}, {255, 244, 0},
3334  {255, 244, 0}, {255, 244, 0}, {255, 244, 0}, {255, 245, 0}, {255, 245, 0},
3335  {255, 245, 0}, {255, 245, 0}, {255, 246, 0}, {255, 246, 0}, {255, 246, 0},
3336  {255, 246, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0},
3337  {255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 249, 0},
3338  {255, 249, 0}, {255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 250, 0},
3339  {255, 250, 0}, {255, 250, 0}, {255, 251, 0}, {255, 251, 0}, {255, 251, 0},
3340  {255, 251, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0},
3341  {255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 254, 0},
3342  {255, 254, 0}, {255, 254, 0}, {255, 254, 0}, {255, 255, 0}, {255, 255, 0}
3343 };
3344 
3345 const rgb_t copper_colormap[1000] = {
3346  { 0, 0, 0}, { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 1, 1, 1},
3347  { 2, 1, 1}, { 2, 1, 1}, { 2, 1, 1}, { 3, 2, 1}, { 3, 2, 1},
3348  { 3, 2, 1}, { 4, 2, 1}, { 4, 2, 2}, { 4, 3, 2}, { 4, 3, 2},
3349  { 5, 3, 2}, { 5, 3, 2}, { 5, 3, 2}, { 6, 4, 2}, { 6, 4, 2},
3350  { 6, 4, 3}, { 7, 4, 3}, { 7, 4, 3}, { 7, 5, 3}, { 8, 5, 3},
3351  { 8, 5, 3}, { 8, 5, 3}, { 9, 5, 3}, { 9, 6, 4}, { 9, 6, 4},
3352  { 10, 6, 4}, { 10, 6, 4}, { 10, 6, 4}, { 11, 7, 4}, { 11, 7, 4},
3353  { 11, 7, 4}, { 11, 7, 5}, { 12, 7, 5}, { 12, 8, 5}, { 12, 8, 5},
3354  { 13, 8, 5}, { 13, 8, 5}, { 13, 8, 5}, { 14, 9, 5}, { 14, 9, 6},
3355  { 14, 9, 6}, { 15, 9, 6}, { 15, 9, 6}, { 15, 10, 6}, { 16, 10, 6},
3356  { 16, 10, 6}, { 16, 10, 6}, { 17, 10, 7}, { 17, 11, 7}, { 17, 11, 7},
3357  { 18, 11, 7}, { 18, 11, 7}, { 18, 11, 7}, { 19, 12, 7}, { 19, 12, 7},
3358  { 19, 12, 8}, { 19, 12, 8}, { 20, 12, 8}, { 20, 13, 8}, { 20, 13, 8},
3359  { 21, 13, 8}, { 21, 13, 8}, { 21, 13, 9}, { 22, 14, 9}, { 22, 14, 9},
3360  { 22, 14, 9}, { 23, 14, 9}, { 23, 14, 9}, { 23, 15, 9}, { 24, 15, 9},
3361  { 24, 15, 10}, { 24, 15, 10}, { 25, 15, 10}, { 25, 16, 10}, { 25, 16, 10},
3362  { 26, 16, 10}, { 26, 16, 10}, { 26, 16, 10}, { 26, 17, 11}, { 27, 17, 11},
3363  { 27, 17, 11}, { 27, 17, 11}, { 28, 17, 11}, { 28, 18, 11}, { 28, 18, 11},
3364  { 29, 18, 11}, { 29, 18, 12}, { 29, 18, 12}, { 30, 19, 12}, { 30, 19, 12},
3365  { 30, 19, 12}, { 31, 19, 12}, { 31, 19, 12}, { 31, 20, 12}, { 32, 20, 13},
3366  { 32, 20, 13}, { 32, 20, 13}, { 33, 20, 13}, { 33, 21, 13}, { 33, 21, 13},
3367  { 34, 21, 13}, { 34, 21, 13}, { 34, 21, 14}, { 34, 22, 14}, { 35, 22, 14},
3368  { 35, 22, 14}, { 35, 22, 14}, { 36, 22, 14}, { 36, 23, 14}, { 36, 23, 14},
3369  { 37, 23, 15}, { 37, 23, 15}, { 37, 23, 15}, { 38, 24, 15}, { 38, 24, 15},
3370  { 38, 24, 15}, { 39, 24, 15}, { 39, 24, 15}, { 39, 25, 16}, { 40, 25, 16},
3371  { 40, 25, 16}, { 40, 25, 16}, { 41, 25, 16}, { 41, 26, 16}, { 41, 26, 16},
3372  { 41, 26, 17}, { 42, 26, 17}, { 42, 26, 17}, { 42, 27, 17}, { 43, 27, 17},
3373  { 43, 27, 17}, { 43, 27, 17}, { 44, 27, 17}, { 44, 28, 18}, { 44, 28, 18},
3374  { 45, 28, 18}, { 45, 28, 18}, { 45, 28, 18}, { 46, 29, 18}, { 46, 29, 18},
3375  { 46, 29, 18}, { 47, 29, 19}, { 47, 29, 19}, { 47, 30, 19}, { 48, 30, 19},
3376  { 48, 30, 19}, { 48, 30, 19}, { 48, 30, 19}, { 49, 31, 19}, { 49, 31, 20},
3377  { 49, 31, 20}, { 50, 31, 20}, { 50, 31, 20}, { 50, 32, 20}, { 51, 32, 20},
3378  { 51, 32, 20}, { 51, 32, 20}, { 52, 32, 21}, { 52, 33, 21}, { 52, 33, 21},
3379  { 53, 33, 21}, { 53, 33, 21}, { 53, 33, 21}, { 54, 34, 21}, { 54, 34, 21},
3380  { 54, 34, 22}, { 55, 34, 22}, { 55, 34, 22}, { 55, 34, 22}, { 56, 35, 22},
3381  { 56, 35, 22}, { 56, 35, 22}, { 56, 35, 22}, { 57, 35, 23}, { 57, 36, 23},
3382  { 57, 36, 23}, { 58, 36, 23}, { 58, 36, 23}, { 58, 36, 23}, { 59, 37, 23},
3383  { 59, 37, 23}, { 59, 37, 24}, { 60, 37, 24}, { 60, 37, 24}, { 60, 38, 24},
3384  { 61, 38, 24}, { 61, 38, 24}, { 61, 38, 24}, { 62, 38, 25}, { 62, 39, 25},
3385  { 62, 39, 25}, { 63, 39, 25}, { 63, 39, 25}, { 63, 39, 25}, { 63, 40, 25},
3386  { 64, 40, 25}, { 64, 40, 26}, { 64, 40, 26}, { 65, 40, 26}, { 65, 41, 26},
3387  { 65, 41, 26}, { 66, 41, 26}, { 66, 41, 26}, { 66, 41, 26}, { 67, 42, 27},
3388  { 67, 42, 27}, { 67, 42, 27}, { 68, 42, 27}, { 68, 42, 27}, { 68, 43, 27},
3389  { 69, 43, 27}, { 69, 43, 27}, { 69, 43, 28}, { 70, 43, 28}, { 70, 44, 28},
3390  { 70, 44, 28}, { 71, 44, 28}, { 71, 44, 28}, { 71, 44, 28}, { 71, 45, 28},
3391  { 72, 45, 29}, { 72, 45, 29}, { 72, 45, 29}, { 73, 45, 29}, { 73, 46, 29},
3392  { 73, 46, 29}, { 74, 46, 29}, { 74, 46, 29}, { 74, 46, 30}, { 75, 47, 30},
3393  { 75, 47, 30}, { 75, 47, 30}, { 76, 47, 30}, { 76, 47, 30}, { 76, 48, 30},
3394  { 77, 48, 30}, { 77, 48, 31}, { 77, 48, 31}, { 78, 48, 31}, { 78, 49, 31},
3395  { 78, 49, 31}, { 78, 49, 31}, { 79, 49, 31}, { 79, 49, 31}, { 79, 50, 32},
3396  { 80, 50, 32}, { 80, 50, 32}, { 80, 50, 32}, { 81, 50, 32}, { 81, 51, 32},
3397  { 81, 51, 32}, { 82, 51, 33}, { 82, 51, 33}, { 82, 51, 33}, { 83, 52, 33},
3398  { 83, 52, 33}, { 83, 52, 33}, { 84, 52, 33}, { 84, 52, 33}, { 84, 53, 34},
3399  { 85, 53, 34}, { 85, 53, 34}, { 85, 53, 34}, { 86, 53, 34}, { 86, 54, 34},
3400  { 86, 54, 34}, { 86, 54, 34}, { 87, 54, 35}, { 87, 54, 35}, { 87, 55, 35},
3401  { 88, 55, 35}, { 88, 55, 35}, { 88, 55, 35}, { 89, 55, 35}, { 89, 56, 35},
3402  { 89, 56, 36}, { 90, 56, 36}, { 90, 56, 36}, { 90, 56, 36}, { 91, 57, 36},
3403  { 91, 57, 36}, { 91, 57, 36}, { 92, 57, 36}, { 92, 57, 37}, { 92, 58, 37},
3404  { 93, 58, 37}, { 93, 58, 37}, { 93, 58, 37}, { 93, 58, 37}, { 94, 59, 37},
3405  { 94, 59, 37}, { 94, 59, 38}, { 95, 59, 38}, { 95, 59, 38}, { 95, 60, 38},
3406  { 96, 60, 38}, { 96, 60, 38}, { 96, 60, 38}, { 97, 60, 38}, { 97, 61, 39},
3407  { 97, 61, 39}, { 98, 61, 39}, { 98, 61, 39}, { 98, 61, 39}, { 99, 62, 39},
3408  { 99, 62, 39}, { 99, 62, 39}, {100, 62, 40}, {100, 62, 40}, {100, 63, 40},
3409  {101, 63, 40}, {101, 63, 40}, {101, 63, 40}, {101, 63, 40}, {102, 64, 41},
3410  {102, 64, 41}, {102, 64, 41}, {103, 64, 41}, {103, 64, 41}, {103, 65, 41},
3411  {104, 65, 41}, {104, 65, 41}, {104, 65, 42}, {105, 65, 42}, {105, 66, 42},
3412  {105, 66, 42}, {106, 66, 42}, {106, 66, 42}, {106, 66, 42}, {107, 67, 42},
3413  {107, 67, 43}, {107, 67, 43}, {108, 67, 43}, {108, 67, 43}, {108, 68, 43},
3414  {108, 68, 43}, {109, 68, 43}, {109, 68, 43}, {109, 68, 44}, {110, 69, 44},
3415  {110, 69, 44}, {110, 69, 44}, {111, 69, 44}, {111, 69, 44}, {111, 70, 44},
3416  {112, 70, 44}, {112, 70, 45}, {112, 70, 45}, {113, 70, 45}, {113, 71, 45},
3417  {113, 71, 45}, {114, 71, 45}, {114, 71, 45}, {114, 71, 45}, {115, 72, 46},
3418  {115, 72, 46}, {115, 72, 46}, {116, 72, 46}, {116, 72, 46}, {116, 73, 46},
3419  {116, 73, 46}, {117, 73, 46}, {117, 73, 47}, {117, 73, 47}, {118, 74, 47},
3420  {118, 74, 47}, {118, 74, 47}, {119, 74, 47}, {119, 74, 47}, {119, 75, 47},
3421  {120, 75, 48}, {120, 75, 48}, {120, 75, 48}, {121, 75, 48}, {121, 76, 48},
3422  {121, 76, 48}, {122, 76, 48}, {122, 76, 49}, {122, 76, 49}, {123, 77, 49},
3423  {123, 77, 49}, {123, 77, 49}, {123, 77, 49}, {124, 77, 49}, {124, 78, 49},
3424  {124, 78, 50}, {125, 78, 50}, {125, 78, 50}, {125, 78, 50}, {126, 79, 50},
3425  {126, 79, 50}, {126, 79, 50}, {127, 79, 50}, {127, 79, 51}, {127, 80, 51},
3426  {128, 80, 51}, {128, 80, 51}, {128, 80, 51}, {129, 80, 51}, {129, 81, 51},
3427  {129, 81, 51}, {130, 81, 52}, {130, 81, 52}, {130, 81, 52}, {130, 82, 52},
3428  {131, 82, 52}, {131, 82, 52}, {131, 82, 52}, {132, 82, 52}, {132, 83, 53},
3429  {132, 83, 53}, {133, 83, 53}, {133, 83, 53}, {133, 83, 53}, {134, 84, 53},
3430  {134, 84, 53}, {134, 84, 53}, {135, 84, 54}, {135, 84, 54}, {135, 85, 54},
3431  {136, 85, 54}, {136, 85, 54}, {136, 85, 54}, {137, 85, 54}, {137, 86, 54},
3432  {137, 86, 55}, {138, 86, 55}, {138, 86, 55}, {138, 86, 55}, {138, 87, 55},
3433  {139, 87, 55}, {139, 87, 55}, {139, 87, 55}, {140, 87, 56}, {140, 88, 56},
3434  {140, 88, 56}, {141, 88, 56}, {141, 88, 56}, {141, 88, 56}, {142, 89, 56},
3435  {142, 89, 57}, {142, 89, 57}, {143, 89, 57}, {143, 89, 57}, {143, 90, 57},
3436  {144, 90, 57}, {144, 90, 57}, {144, 90, 57}, {145, 90, 58}, {145, 91, 58},
3437  {145, 91, 58}, {145, 91, 58}, {146, 91, 58}, {146, 91, 58}, {146, 92, 58},
3438  {147, 92, 58}, {147, 92, 59}, {147, 92, 59}, {148, 92, 59}, {148, 93, 59},
3439  {148, 93, 59}, {149, 93, 59}, {149, 93, 59}, {149, 93, 59}, {150, 94, 60},
3440  {150, 94, 60}, {150, 94, 60}, {151, 94, 60}, {151, 94, 60}, {151, 95, 60},
3441  {152, 95, 60}, {152, 95, 60}, {152, 95, 61}, {153, 95, 61}, {153, 96, 61},
3442  {153, 96, 61}, {153, 96, 61}, {154, 96, 61}, {154, 96, 61}, {154, 97, 61},
3443  {155, 97, 62}, {155, 97, 62}, {155, 97, 62}, {156, 97, 62}, {156, 98, 62},
3444  {156, 98, 62}, {157, 98, 62}, {157, 98, 62}, {157, 98, 63}, {158, 99, 63},
3445  {158, 99, 63}, {158, 99, 63}, {159, 99, 63}, {159, 99, 63}, {159, 100, 63},
3446  {160, 100, 63}, {160, 100, 64}, {160, 100, 64}, {160, 100, 64}, {161, 101, 64},
3447  {161, 101, 64}, {161, 101, 64}, {162, 101, 64}, {162, 101, 65}, {162, 101, 65},
3448  {163, 102, 65}, {163, 102, 65}, {163, 102, 65}, {164, 102, 65}, {164, 102, 65},
3449  {164, 103, 65}, {165, 103, 66}, {165, 103, 66}, {165, 103, 66}, {166, 103, 66},
3450  {166, 104, 66}, {166, 104, 66}, {167, 104, 66}, {167, 104, 66}, {167, 104, 67},
3451  {168, 105, 67}, {168, 105, 67}, {168, 105, 67}, {168, 105, 67}, {169, 105, 67},
3452  {169, 106, 67}, {169, 106, 67}, {170, 106, 68}, {170, 106, 68}, {170, 106, 68},
3453  {171, 107, 68}, {171, 107, 68}, {171, 107, 68}, {172, 107, 68}, {172, 107, 68},
3454  {172, 108, 69}, {173, 108, 69}, {173, 108, 69}, {173, 108, 69}, {174, 108, 69},
3455  {174, 109, 69}, {174, 109, 69}, {175, 109, 69}, {175, 109, 70}, {175, 109, 70},
3456  {175, 110, 70}, {176, 110, 70}, {176, 110, 70}, {176, 110, 70}, {177, 110, 70},
3457  {177, 111, 70}, {177, 111, 71}, {178, 111, 71}, {178, 111, 71}, {178, 111, 71},
3458  {179, 112, 71}, {179, 112, 71}, {179, 112, 71}, {180, 112, 71}, {180, 112, 72},
3459  {180, 113, 72}, {181, 113, 72}, {181, 113, 72}, {181, 113, 72}, {182, 113, 72},
3460  {182, 114, 72}, {182, 114, 73}, {183, 114, 73}, {183, 114, 73}, {183, 114, 73},
3461  {183, 115, 73}, {184, 115, 73}, {184, 115, 73}, {184, 115, 73}, {185, 115, 74},
3462  {185, 116, 74}, {185, 116, 74}, {186, 116, 74}, {186, 116, 74}, {186, 116, 74},
3463  {187, 117, 74}, {187, 117, 74}, {187, 117, 75}, {188, 117, 75}, {188, 117, 75},
3464  {188, 118, 75}, {189, 118, 75}, {189, 118, 75}, {189, 118, 75}, {190, 118, 75},
3465  {190, 119, 76}, {190, 119, 76}, {190, 119, 76}, {191, 119, 76}, {191, 119, 76},
3466  {191, 120, 76}, {192, 120, 76}, {192, 120, 76}, {192, 120, 77}, {193, 120, 77},
3467  {193, 121, 77}, {193, 121, 77}, {194, 121, 77}, {194, 121, 77}, {194, 121, 77},
3468  {195, 122, 77}, {195, 122, 78}, {195, 122, 78}, {196, 122, 78}, {196, 122, 78},
3469  {196, 123, 78}, {197, 123, 78}, {197, 123, 78}, {197, 123, 78}, {198, 123, 79},
3470  {198, 124, 79}, {198, 124, 79}, {198, 124, 79}, {199, 124, 79}, {199, 124, 79},
3471  {199, 125, 79}, {200, 125, 79}, {200, 125, 80}, {200, 125, 80}, {201, 125, 80},
3472  {201, 126, 80}, {201, 126, 80}, {202, 126, 80}, {202, 126, 80}, {202, 126, 81},
3473  {203, 127, 81}, {203, 127, 81}, {203, 127, 81}, {204, 127, 81}, {204, 127, 81},
3474  {204, 128, 81}, {205, 128, 81}, {205, 128, 82}, {205, 128, 82}, {205, 128, 82},
3475  {206, 129, 82}, {206, 129, 82}, {206, 129, 82}, {207, 129, 82}, {207, 129, 82},
3476  {207, 130, 83}, {208, 130, 83}, {208, 130, 83}, {208, 130, 83}, {209, 130, 83},
3477  {209, 131, 83}, {209, 131, 83}, {210, 131, 83}, {210, 131, 84}, {210, 131, 84},
3478  {211, 132, 84}, {211, 132, 84}, {211, 132, 84}, {212, 132, 84}, {212, 132, 84},
3479  {212, 133, 84}, {212, 133, 85}, {213, 133, 85}, {213, 133, 85}, {213, 133, 85},
3480  {214, 134, 85}, {214, 134, 85}, {214, 134, 85}, {215, 134, 85}, {215, 134, 86},
3481  {215, 135, 86}, {216, 135, 86}, {216, 135, 86}, {216, 135, 86}, {217, 135, 86},
3482  {217, 136, 86}, {217, 136, 86}, {218, 136, 87}, {218, 136, 87}, {218, 136, 87},
3483  {219, 137, 87}, {219, 137, 87}, {219, 137, 87}, {220, 137, 87}, {220, 137, 87},
3484  {220, 138, 88}, {220, 138, 88}, {221, 138, 88}, {221, 138, 88}, {221, 138, 88},
3485  {222, 139, 88}, {222, 139, 88}, {222, 139, 89}, {223, 139, 89}, {223, 139, 89},
3486  {223, 140, 89}, {224, 140, 89}, {224, 140, 89}, {224, 140, 89}, {225, 140, 89},
3487  {225, 141, 90}, {225, 141, 90}, {226, 141, 90}, {226, 141, 90}, {226, 141, 90},
3488  {227, 142, 90}, {227, 142, 90}, {227, 142, 90}, {227, 142, 91}, {228, 142, 91},
3489  {228, 143, 91}, {228, 143, 91}, {229, 143, 91}, {229, 143, 91}, {229, 143, 91},
3490  {230, 144, 91}, {230, 144, 92}, {230, 144, 92}, {231, 144, 92}, {231, 144, 92},
3491  {231, 145, 92}, {232, 145, 92}, {232, 145, 92}, {232, 145, 92}, {233, 145, 93},
3492  {233, 146, 93}, {233, 146, 93}, {234, 146, 93}, {234, 146, 93}, {234, 146, 93},
3493  {235, 147, 93}, {235, 147, 93}, {235, 147, 94}, {235, 147, 94}, {236, 147, 94},
3494  {236, 148, 94}, {236, 148, 94}, {237, 148, 94}, {237, 148, 94}, {237, 148, 94},
3495  {238, 149, 95}, {238, 149, 95}, {238, 149, 95}, {239, 149, 95}, {239, 149, 95},
3496  {239, 150, 95}, {240, 150, 95}, {240, 150, 95}, {240, 150, 96}, {241, 150, 96},
3497  {241, 151, 96}, {241, 151, 96}, {242, 151, 96}, {242, 151, 96}, {242, 151, 96},
3498  {242, 152, 97}, {243, 152, 97}, {243, 152, 97}, {243, 152, 97}, {244, 152, 97},
3499  {244, 153, 97}, {244, 153, 97}, {245, 153, 97}, {245, 153, 98}, {245, 153, 98},
3500  {246, 154, 98}, {246, 154, 98}, {246, 154, 98}, {247, 154, 98}, {247, 154, 98},
3501  {247, 155, 98}, {248, 155, 99}, {248, 155, 99}, {248, 155, 99}, {249, 155, 99},
3502  {249, 156, 99}, {249, 156, 99}, {250, 156, 99}, {250, 156, 99}, {250, 156, 100},
3503  {250, 157, 100}, {251, 157, 100}, {251, 157, 100}, {251, 157, 100}, {252, 157, 100},
3504  {252, 158, 100}, {252, 158, 100}, {253, 158, 101}, {253, 158, 101}, {253, 158, 101},
3505  {253, 159, 101}, {253, 159, 101}, {254, 159, 101}, {254, 159, 101}, {254, 159, 101},
3506  {254, 160, 102}, {254, 160, 102}, {254, 160, 102}, {254, 160, 102}, {254, 160, 102},
3507  {255, 161, 102}, {255, 161, 102}, {255, 161, 102}, {255, 161, 103}, {255, 161, 103},
3508  {255, 162, 103}, {255, 162, 103}, {255, 162, 103}, {255, 162, 103}, {255, 162, 103},
3509  {255, 163, 103}, {255, 163, 104}, {255, 163, 104}, {255, 163, 104}, {255, 163, 104},
3510  {255, 164, 104}, {255, 164, 104}, {255, 164, 104}, {255, 164, 105}, {255, 164, 105},
3511  {255, 165, 105}, {255, 165, 105}, {255, 165, 105}, {255, 165, 105}, {255, 165, 105},
3512  {255, 166, 105}, {255, 166, 106}, {255, 166, 106}, {255, 166, 106}, {255, 166, 106},
3513  {255, 167, 106}, {255, 167, 106}, {255, 167, 106}, {255, 167, 106}, {255, 167, 107},
3514  {255, 168, 107}, {255, 168, 107}, {255, 168, 107}, {255, 168, 107}, {255, 168, 107},
3515  {255, 168, 107}, {255, 169, 107}, {255, 169, 108}, {255, 169, 108}, {255, 169, 108},
3516  {255, 169, 108}, {255, 170, 108}, {255, 170, 108}, {255, 170, 108}, {255, 170, 108},
3517  {255, 170, 109}, {255, 171, 109}, {255, 171, 109}, {255, 171, 109}, {255, 171, 109},
3518  {255, 171, 109}, {255, 172, 109}, {255, 172, 109}, {255, 172, 110}, {255, 172, 110},
3519  {255, 172, 110}, {255, 173, 110}, {255, 173, 110}, {255, 173, 110}, {255, 173, 110},
3520  {255, 173, 110}, {255, 174, 111}, {255, 174, 111}, {255, 174, 111}, {255, 174, 111},
3521  {255, 174, 111}, {255, 175, 111}, {255, 175, 111}, {255, 175, 111}, {255, 175, 112},
3522  {255, 175, 112}, {255, 176, 112}, {255, 176, 112}, {255, 176, 112}, {255, 176, 112},
3523  {255, 176, 112}, {255, 177, 113}, {255, 177, 113}, {255, 177, 113}, {255, 177, 113},
3524  {255, 177, 113}, {255, 178, 113}, {255, 178, 113}, {255, 178, 113}, {255, 178, 114},
3525  {255, 178, 114}, {255, 179, 114}, {255, 179, 114}, {255, 179, 114}, {255, 179, 114},
3526  {255, 179, 114}, {255, 180, 114}, {255, 180, 115}, {255, 180, 115}, {255, 180, 115},
3527  {255, 180, 115}, {255, 181, 115}, {255, 181, 115}, {255, 181, 115}, {255, 181, 115},
3528  {255, 181, 116}, {255, 182, 116}, {255, 182, 116}, {255, 182, 116}, {255, 182, 116},
3529  {255, 182, 116}, {255, 183, 116}, {255, 183, 116}, {255, 183, 117}, {255, 183, 117},
3530  {255, 183, 117}, {255, 184, 117}, {255, 184, 117}, {255, 184, 117}, {255, 184, 117},
3531  {255, 184, 117}, {255, 185, 118}, {255, 185, 118}, {255, 185, 118}, {255, 185, 118},
3532  {255, 185, 118}, {255, 186, 118}, {255, 186, 118}, {255, 186, 118}, {255, 186, 119},
3533  {255, 186, 119}, {255, 187, 119}, {255, 187, 119}, {255, 187, 119}, {255, 187, 119},
3534  {255, 187, 119}, {255, 188, 119}, {255, 188, 120}, {255, 188, 120}, {255, 188, 120},
3535  {255, 188, 120}, {255, 189, 120}, {255, 189, 120}, {255, 189, 120}, {255, 189, 121},
3536  {255, 189, 121}, {255, 190, 121}, {255, 190, 121}, {255, 190, 121}, {255, 190, 121},
3537  {255, 190, 121}, {255, 191, 121}, {255, 191, 122}, {255, 191, 122}, {255, 191, 122},
3538  {255, 191, 122}, {255, 192, 122}, {255, 192, 122}, {255, 192, 122}, {255, 192, 122},
3539  {255, 192, 123}, {255, 193, 123}, {255, 193, 123}, {255, 193, 123}, {255, 193, 123},
3540  {255, 193, 123}, {255, 194, 123}, {255, 194, 123}, {255, 194, 124}, {255, 194, 124},
3541  {255, 194, 124}, {255, 195, 124}, {255, 195, 124}, {255, 195, 124}, {255, 195, 124},
3542  {255, 195, 124}, {255, 196, 125}, {255, 196, 125}, {255, 196, 125}, {255, 196, 125},
3543  {255, 196, 125}, {255, 197, 125}, {255, 197, 125}, {255, 197, 125}, {255, 197, 126},
3544  {255, 197, 126}, {255, 198, 126}, {255, 198, 126}, {255, 198, 126}, {255, 198, 126},
3545  {255, 198, 126}, {255, 199, 126}, {255, 199, 127}, {255, 199, 127}, {255, 199, 127}
3546 };
3547 
3548 const rgb_t gray_colormap[1000] = {
3549  {255, 255, 255}, {255, 255, 255}, {254, 254, 254}, {254, 254, 254}, {254, 254, 254},
3550  {254, 254, 254}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253},
3551  {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {251, 251, 251},
3552  {251, 251, 251}, {251, 251, 251}, {251, 251, 251}, {250, 250, 250}, {250, 250, 250},
3553  {250, 250, 250}, {250, 250, 250}, {249, 249, 249}, {249, 249, 249}, {249, 249, 249},
3554  {249, 249, 249}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248},
3555  {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {246, 246, 246},
3556  {246, 246, 246}, {246, 246, 246}, {246, 246, 246}, {245, 245, 245}, {245, 245, 245},
3557  {245, 245, 245}, {245, 245, 245}, {244, 244, 244}, {244, 244, 244}, {244, 244, 244},
3558  {244, 244, 244}, {243, 243, 243}, {243, 243, 243}, {243, 243, 243}, {242, 242, 242},
3559  {242, 242, 242}, {242, 242, 242}, {242, 242, 242}, {241, 241, 241}, {241, 241, 241},
3560  {241, 241, 241}, {241, 241, 241}, {240, 240, 240}, {240, 240, 240}, {240, 240, 240},
3561  {240, 240, 240}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239},
3562  {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {237, 237, 237},
3563  {237, 237, 237}, {237, 237, 237}, {237, 237, 237}, {236, 236, 236}, {236, 236, 236},
3564  {236, 236, 236}, {236, 236, 236}, {235, 235, 235}, {235, 235, 235}, {235, 235, 235},
3565  {235, 235, 235}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234},
3566  {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {232, 232, 232},
3567  {232, 232, 232}, {232, 232, 232}, {232, 232, 232}, {231, 231, 231}, {231, 231, 231},
3568  {231, 231, 231}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230},
3569  {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {228, 228, 228},
3570  {228, 228, 228}, {228, 228, 228}, {228, 228, 228}, {227, 227, 227}, {227, 227, 227},
3571  {227, 227, 227}, {227, 227, 227}, {226, 226, 226}, {226, 226, 226}, {226, 226, 226},
3572  {226, 226, 226}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225},
3573  {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {223, 223, 223},
3574  {223, 223, 223}, {223, 223, 223}, {223, 223, 223}, {222, 222, 222}, {222, 222, 222},
3575  {222, 222, 222}, {222, 222, 222}, {221, 221, 221}, {221, 221, 221}, {221, 221, 221},
3576  {221, 221, 221}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220},
3577  {219, 219, 219}, {219, 219, 219}, {219, 219, 219}, {218, 218, 218}, {218, 218, 218},
3578  {218, 218, 218}, {218, 218, 218}, {217, 217, 217}, {217, 217, 217}, {217, 217, 217},
3579  {217, 217, 217}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216},
3580  {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {214, 214, 214},
3581  {214, 214, 214}, {214, 214, 214}, {214, 214, 214}, {213, 213, 213}, {213, 213, 213},
3582  {213, 213, 213}, {213, 213, 213}, {212, 212, 212}, {212, 212, 212}, {212, 212, 212},
3583  {212, 212, 212}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211},
3584  {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {209, 209, 209},
3585  {209, 209, 209}, {209, 209, 209}, {209, 209, 209}, {208, 208, 208}, {208, 208, 208},
3586  {208, 208, 208}, {208, 208, 208}, {207, 207, 207}, {207, 207, 207}, {207, 207, 207},
3587  {207, 207, 207}, {206, 206, 206}, {206, 206, 206}, {206, 206, 206}, {205, 205, 205},
3588  {205, 205, 205}, {205, 205, 205}, {205, 205, 205}, {204, 204, 204}, {204, 204, 204},
3589  {204, 204, 204}, {204, 204, 204}, {203, 203, 203}, {203, 203, 203}, {203, 203, 203},
3590  {203, 203, 203}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202},
3591  {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {200, 200, 200},
3592  {200, 200, 200}, {200, 200, 200}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
3593  {199, 199, 199}, {199, 199, 199}, {198, 198, 198}, {198, 198, 198}, {198, 198, 198},
3594  {198, 198, 198}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197},
3595  {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {195, 195, 195},
3596  {195, 195, 195}, {195, 195, 195}, {195, 195, 195}, {194, 194, 194}, {194, 194, 194},
3597  {194, 194, 194}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193},
3598  {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {191, 191, 191},
3599  {191, 191, 191}, {191, 191, 191}, {191, 191, 191}, {190, 190, 190}, {190, 190, 190},
3600  {190, 190, 190}, {190, 190, 190}, {189, 189, 189}, {189, 189, 189}, {189, 189, 189},
3601  {189, 189, 189}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188},
3602  {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {186, 186, 186},
3603  {186, 186, 186}, {186, 186, 186}, {186, 186, 186}, {185, 185, 185}, {185, 185, 185},
3604  {185, 185, 185}, {185, 185, 185}, {184, 184, 184}, {184, 184, 184}, {184, 184, 184},
3605  {184, 184, 184}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183},
3606  {182, 182, 182}, {182, 182, 182}, {182, 182, 182}, {181, 181, 181}, {181, 181, 181},
3607  {181, 181, 181}, {181, 181, 181}, {180, 180, 180}, {180, 180, 180}, {180, 180, 180},
3608  {180, 180, 180}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179},
3609  {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {177, 177, 177},
3610  {177, 177, 177}, {177, 177, 177}, {177, 177, 177}, {176, 176, 176}, {176, 176, 176},
3611  {176, 176, 176}, {176, 176, 176}, {175, 175, 175}, {175, 175, 175}, {175, 175, 175},
3612  {175, 175, 175}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174},
3613  {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {172, 172, 172},
3614  {172, 172, 172}, {172, 172, 172}, {172, 172, 172}, {171, 171, 171}, {171, 171, 171},
3615  {171, 171, 171}, {171, 171, 171}, {170, 170, 170}, {170, 170, 170}, {170, 170, 170},
3616  {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {168, 168, 168},
3617  {168, 168, 168}, {168, 168, 168}, {168, 168, 168}, {167, 167, 167}, {167, 167, 167},
3618  {167, 167, 167}, {167, 167, 167}, {166, 166, 166}, {166, 166, 166}, {166, 166, 166},
3619  {166, 166, 166}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165},
3620  {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {163, 163, 163},
3621  {163, 163, 163}, {163, 163, 163}, {163, 163, 163}, {162, 162, 162}, {162, 162, 162},
3622  {162, 162, 162}, {162, 162, 162}, {161, 161, 161}, {161, 161, 161}, {161, 161, 161},
3623  {161, 161, 161}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160},
3624  {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {158, 158, 158},
3625  {158, 158, 158}, {158, 158, 158}, {157, 157, 157}, {157, 157, 157}, {157, 157, 157},
3626  {157, 157, 157}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156},
3627  {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {154, 154, 154},
3628  {154, 154, 154}, {154, 154, 154}, {154, 154, 154}, {153, 153, 153}, {153, 153, 153},
3629  {153, 153, 153}, {153, 153, 153}, {152, 152, 152}, {152, 152, 152}, {152, 152, 152},
3630  {152, 152, 152}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151},
3631  {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {149, 149, 149},
3632  {149, 149, 149}, {149, 149, 149}, {149, 149, 149}, {148, 148, 148}, {148, 148, 148},
3633  {148, 148, 148}, {148, 148, 148}, {147, 147, 147}, {147, 147, 147}, {147, 147, 147},
3634  {147, 147, 147}, {146, 146, 146}, {146, 146, 146}, {146, 146, 146}, {145, 145, 145},
3635  {145, 145, 145}, {145, 145, 145}, {145, 145, 145}, {144, 144, 144}, {144, 144, 144},
3636  {144, 144, 144}, {144, 144, 144}, {143, 143, 143}, {143, 143, 143}, {143, 143, 143},
3637  {143, 143, 143}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142},
3638  {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {140, 140, 140},
3639  {140, 140, 140}, {140, 140, 140}, {140, 140, 140}, {139, 139, 139}, {139, 139, 139},
3640  {139, 139, 139}, {139, 139, 139}, {138, 138, 138}, {138, 138, 138}, {138, 138, 138},
3641  {138, 138, 138}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137},
3642  {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {135, 135, 135},
3643  {135, 135, 135}, {135, 135, 135}, {135, 135, 135}, {134, 134, 134}, {134, 134, 134},
3644  {134, 134, 134}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133},
3645  {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {131, 131, 131},
3646  {131, 131, 131}, {131, 131, 131}, {131, 131, 131}, {130, 130, 130}, {130, 130, 130},
3647  {130, 130, 130}, {130, 130, 130}, {129, 129, 129}, {129, 129, 129}, {129, 129, 129},
3648  {129, 129, 129}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
3649  {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {126, 126, 126},
3650  {126, 126, 126}, {126, 126, 126}, {126, 126, 126}, {125, 125, 125}, {125, 125, 125},
3651  {125, 125, 125}, {125, 125, 125}, {124, 124, 124}, {124, 124, 124}, {124, 124, 124},
3652  {124, 124, 124}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123},
3653  {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {121, 121, 121},
3654  {121, 121, 121}, {121, 121, 121}, {120, 120, 120}, {120, 120, 120}, {120, 120, 120},
3655  {120, 120, 120}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119},
3656  {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {117, 117, 117},
3657  {117, 117, 117}, {117, 117, 117}, {117, 117, 117}, {116, 116, 116}, {116, 116, 116},
3658  {116, 116, 116}, {116, 116, 116}, {115, 115, 115}, {115, 115, 115}, {115, 115, 115},
3659  {115, 115, 115}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114},
3660  {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {112, 112, 112},
3661  {112, 112, 112}, {112, 112, 112}, {112, 112, 112}, {111, 111, 111}, {111, 111, 111},
3662  {111, 111, 111}, {111, 111, 111}, {110, 110, 110}, {110, 110, 110}, {110, 110, 110},
3663  {110, 110, 110}, {109, 109, 109}, {109, 109, 109}, {109, 109, 109}, {108, 108, 108},
3664  {108, 108, 108}, {108, 108, 108}, {108, 108, 108}, {107, 107, 107}, {107, 107, 107},
3665  {107, 107, 107}, {107, 107, 107}, {106, 106, 106}, {106, 106, 106}, {106, 106, 106},
3666  {106, 106, 106}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105},
3667  {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {103, 103, 103},
3668  {103, 103, 103}, {103, 103, 103}, {103, 103, 103}, {102, 102, 102}, {102, 102, 102},
3669  {102, 102, 102}, {102, 102, 102}, {101, 101, 101}, {101, 101, 101}, {101, 101, 101},
3670  {101, 101, 101}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100},
3671  { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 98, 98, 98},
3672  { 98, 98, 98}, { 98, 98, 98}, { 98, 98, 98}, { 97, 97, 97}, { 97, 97, 97},
3673  { 97, 97, 97}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96},
3674  { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 94, 94, 94},
3675  { 94, 94, 94}, { 94, 94, 94}, { 94, 94, 94}, { 93, 93, 93}, { 93, 93, 93},
3676  { 93, 93, 93}, { 93, 93, 93}, { 92, 92, 92}, { 92, 92, 92}, { 92, 92, 92},
3677  { 92, 92, 92}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91},
3678  { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 89, 89, 89},
3679  { 89, 89, 89}, { 89, 89, 89}, { 89, 89, 89}, { 88, 88, 88}, { 88, 88, 88},
3680  { 88, 88, 88}, { 88, 88, 88}, { 87, 87, 87}, { 87, 87, 87}, { 87, 87, 87},
3681  { 87, 87, 87}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86},
3682  { 85, 85, 85}, { 85, 85, 85}, { 85, 85, 85}, { 84, 84, 84}, { 84, 84, 84},
3683  { 84, 84, 84}, { 84, 84, 84}, { 83, 83, 83}, { 83, 83, 83}, { 83, 83, 83},
3684  { 83, 83, 83}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82},
3685  { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 80, 80, 80},
3686  { 80, 80, 80}, { 80, 80, 80}, { 80, 80, 80}, { 79, 79, 79}, { 79, 79, 79},
3687  { 79, 79, 79}, { 79, 79, 79}, { 78, 78, 78}, { 78, 78, 78}, { 78, 78, 78},
3688  { 78, 78, 78}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77},
3689  { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 75, 75, 75},
3690  { 75, 75, 75}, { 75, 75, 75}, { 75, 75, 75}, { 74, 74, 74}, { 74, 74, 74},
3691  { 74, 74, 74}, { 74, 74, 74}, { 73, 73, 73}, { 73, 73, 73}, { 73, 73, 73},
3692  { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 71, 71, 71},
3693  { 71, 71, 71}, { 71, 71, 71}, { 71, 71, 71}, { 70, 70, 70}, { 70, 70, 70},
3694  { 70, 70, 70}, { 70, 70, 70}, { 69, 69, 69}, { 69, 69, 69}, { 69, 69, 69},
3695  { 69, 69, 69}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68},
3696  { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 66, 66, 66},
3697  { 66, 66, 66}, { 66, 66, 66}, { 66, 66, 66}, { 65, 65, 65}, { 65, 65, 65},
3698  { 65, 65, 65}, { 65, 65, 65}, { 64, 64, 64}, { 64, 64, 64}, { 64, 64, 64},
3699  { 64, 64, 64}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63},
3700  { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 61, 61, 61},
3701  { 61, 61, 61}, { 61, 61, 61}, { 60, 60, 60}, { 60, 60, 60}, { 60, 60, 60},
3702  { 60, 60, 60}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59},
3703  { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 57, 57, 57},
3704  { 57, 57, 57}, { 57, 57, 57}, { 57, 57, 57}, { 56, 56, 56}, { 56, 56, 56},
3705  { 56, 56, 56}, { 56, 56, 56}, { 55, 55, 55}, { 55, 55, 55}, { 55, 55, 55},
3706  { 55, 55, 55}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54},
3707  { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 52, 52, 52},
3708  { 52, 52, 52}, { 52, 52, 52}, { 52, 52, 52}, { 51, 51, 51}, { 51, 51, 51},
3709  { 51, 51, 51}, { 51, 51, 51}, { 50, 50, 50}, { 50, 50, 50}, { 50, 50, 50},
3710  { 50, 50, 50}, { 49, 49, 49}, { 49, 49, 49}, { 49, 49, 49}, { 48, 48, 48},
3711  { 48, 48, 48}, { 48, 48, 48}, { 48, 48, 48}, { 47, 47, 47}, { 47, 47, 47},
3712  { 47, 47, 47}, { 47, 47, 47}, { 46, 46, 46}, { 46, 46, 46}, { 46, 46, 46},
3713  { 46, 46, 46}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45},
3714  { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 43, 43, 43},
3715  { 43, 43, 43}, { 43, 43, 43}, { 43, 43, 43}, { 42, 42, 42}, { 42, 42, 42},
3716  { 42, 42, 42}, { 42, 42, 42}, { 41, 41, 41}, { 41, 41, 41}, { 41, 41, 41},
3717  { 41, 41, 41}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40},
3718  { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 38, 38, 38},
3719  { 38, 38, 38}, { 38, 38, 38}, { 38, 38, 38}, { 37, 37, 37}, { 37, 37, 37},
3720  { 37, 37, 37}, { 37, 37, 37}, { 36, 36, 36}, { 36, 36, 36}, { 36, 36, 36},
3721  { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 34, 34, 34},
3722  { 34, 34, 34}, { 34, 34, 34}, { 34, 34, 34}, { 33, 33, 33}, { 33, 33, 33},
3723  { 33, 33, 33}, { 33, 33, 33}, { 32, 32, 32}, { 32, 32, 32}, { 32, 32, 32},
3724  { 32, 32, 32}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31},
3725  { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 29, 29, 29},
3726  { 29, 29, 29}, { 29, 29, 29}, { 29, 29, 29}, { 28, 28, 28}, { 28, 28, 28},
3727  { 28, 28, 28}, { 28, 28, 28}, { 27, 27, 27}, { 27, 27, 27}, { 27, 27, 27},
3728  { 27, 27, 27}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26},
3729  { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 24, 24, 24},
3730  { 24, 24, 24}, { 24, 24, 24}, { 23, 23, 23}, { 23, 23, 23}, { 23, 23, 23},
3731  { 23, 23, 23}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22},
3732  { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 20, 20, 20},
3733  { 20, 20, 20}, { 20, 20, 20}, { 20, 20, 20}, { 19, 19, 19}, { 19, 19, 19},
3734  { 19, 19, 19}, { 19, 19, 19}, { 18, 18, 18}, { 18, 18, 18}, { 18, 18, 18},
3735  { 18, 18, 18}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17},
3736  { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 15, 15, 15},
3737  { 15, 15, 15}, { 15, 15, 15}, { 15, 15, 15}, { 14, 14, 14}, { 14, 14, 14},
3738  { 14, 14, 14}, { 14, 14, 14}, { 13, 13, 13}, { 13, 13, 13}, { 13, 13, 13},
3739  { 13, 13, 13}, { 12, 12, 12}, { 12, 12, 12}, { 12, 12, 12}, { 11, 11, 11},
3740  { 11, 11, 11}, { 11, 11, 11}, { 11, 11, 11}, { 10, 10, 10}, { 10, 10, 10},
3741  { 10, 10, 10}, { 10, 10, 10}, { 9, 9, 9}, { 9, 9, 9}, { 9, 9, 9},
3742  { 9, 9, 9}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8},
3743  { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 6, 6, 6},
3744  { 6, 6, 6}, { 6, 6, 6}, { 6, 6, 6}, { 5, 5, 5}, { 5, 5, 5},
3745  { 5, 5, 5}, { 5, 5, 5}, { 4, 4, 4}, { 4, 4, 4}, { 4, 4, 4},
3746  { 4, 4, 4}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3},
3747  { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 1, 1, 1},
3748  { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 0, 0, 0}, { 0, 0, 0}
3749 };
3750 
3751 const rgb_t hot_colormap[1000] = {
3752  { 11, 0, 0}, { 11, 0, 0}, { 12, 0, 0}, { 13, 0, 0}, { 13, 0, 0},
3753  { 14, 0, 0}, { 15, 0, 0}, { 15, 0, 0}, { 16, 0, 0}, { 17, 0, 0},
3754  { 17, 0, 0}, { 18, 0, 0}, { 19, 0, 0}, { 19, 0, 0}, { 20, 0, 0},
3755  { 21, 0, 0}, { 21, 0, 0}, { 22, 0, 0}, { 23, 0, 0}, { 23, 0, 0},
3756  { 24, 0, 0}, { 25, 0, 0}, { 25, 0, 0}, { 26, 0, 0}, { 27, 0, 0},
3757  { 27, 0, 0}, { 28, 0, 0}, { 29, 0, 0}, { 29, 0, 0}, { 30, 0, 0},
3758  { 31, 0, 0}, { 31, 0, 0}, { 32, 0, 0}, { 33, 0, 0}, { 33, 0, 0},
3759  { 34, 0, 0}, { 35, 0, 0}, { 35, 0, 0}, { 36, 0, 0}, { 37, 0, 0},
3760  { 37, 0, 0}, { 38, 0, 0}, { 39, 0, 0}, { 39, 0, 0}, { 40, 0, 0},
3761  { 41, 0, 0}, { 41, 0, 0}, { 42, 0, 0}, { 43, 0, 0}, { 43, 0, 0},
3762  { 44, 0, 0}, { 45, 0, 0}, { 45, 0, 0}, { 46, 0, 0}, { 47, 0, 0},
3763  { 47, 0, 0}, { 48, 0, 0}, { 49, 0, 0}, { 49, 0, 0}, { 50, 0, 0},
3764  { 51, 0, 0}, { 51, 0, 0}, { 52, 0, 0}, { 53, 0, 0}, { 54, 0, 0},
3765  { 54, 0, 0}, { 55, 0, 0}, { 56, 0, 0}, { 56, 0, 0}, { 57, 0, 0},
3766  { 58, 0, 0}, { 58, 0, 0}, { 59, 0, 0}, { 60, 0, 0}, { 60, 0, 0},
3767  { 61, 0, 0}, { 62, 0, 0}, { 62, 0, 0}, { 63, 0, 0}, { 64, 0, 0},
3768  { 64, 0, 0}, { 65, 0, 0}, { 66, 0, 0}, { 66, 0, 0}, { 67, 0, 0},
3769  { 68, 0, 0}, { 68, 0, 0}, { 69, 0, 0}, { 70, 0, 0}, { 70, 0, 0},
3770  { 71, 0, 0}, { 72, 0, 0}, { 72, 0, 0}, { 73, 0, 0}, { 74, 0, 0},
3771  { 74, 0, 0}, { 75, 0, 0}, { 76, 0, 0}, { 76, 0, 0}, { 77, 0, 0},
3772  { 78, 0, 0}, { 78, 0, 0}, { 79, 0, 0}, { 80, 0, 0}, { 80, 0, 0},
3773  { 81, 0, 0}, { 82, 0, 0}, { 82, 0, 0}, { 83, 0, 0}, { 84, 0, 0},
3774  { 84, 0, 0}, { 85, 0, 0}, { 86, 0, 0}, { 86, 0, 0}, { 87, 0, 0},
3775  { 88, 0, 0}, { 88, 0, 0}, { 89, 0, 0}, { 90, 0, 0}, { 90, 0, 0},
3776  { 91, 0, 0}, { 92, 0, 0}, { 92, 0, 0}, { 93, 0, 0}, { 94, 0, 0},
3777  { 94, 0, 0}, { 95, 0, 0}, { 96, 0, 0}, { 96, 0, 0}, { 97, 0, 0},
3778  { 98, 0, 0}, { 98, 0, 0}, { 99, 0, 0}, {100, 0, 0}, {100, 0, 0},
3779  {101, 0, 0}, {102, 0, 0}, {102, 0, 0}, {103, 0, 0}, {104, 0, 0},
3780  {104, 0, 0}, {105, 0, 0}, {106, 0, 0}, {106, 0, 0}, {107, 0, 0},
3781  {108, 0, 0}, {108, 0, 0}, {109, 0, 0}, {110, 0, 0}, {110, 0, 0},
3782  {111, 0, 0}, {112, 0, 0}, {112, 0, 0}, {113, 0, 0}, {114, 0, 0},
3783  {114, 0, 0}, {115, 0, 0}, {116, 0, 0}, {116, 0, 0}, {117, 0, 0},
3784  {118, 0, 0}, {119, 0, 0}, {119, 0, 0}, {120, 0, 0}, {121, 0, 0},
3785  {121, 0, 0}, {122, 0, 0}, {123, 0, 0}, {123, 0, 0}, {124, 0, 0},
3786  {125, 0, 0}, {125, 0, 0}, {126, 0, 0}, {127, 0, 0}, {127, 0, 0},
3787  {128, 0, 0}, {129, 0, 0}, {129, 0, 0}, {130, 0, 0}, {131, 0, 0},
3788  {131, 0, 0}, {132, 0, 0}, {133, 0, 0}, {133, 0, 0}, {134, 0, 0},
3789  {135, 0, 0}, {135, 0, 0}, {136, 0, 0}, {137, 0, 0}, {137, 0, 0},
3790  {138, 0, 0}, {139, 0, 0}, {139, 0, 0}, {140, 0, 0}, {141, 0, 0},
3791  {141, 0, 0}, {142, 0, 0}, {143, 0, 0}, {143, 0, 0}, {144, 0, 0},
3792  {145, 0, 0}, {145, 0, 0}, {146, 0, 0}, {147, 0, 0}, {147, 0, 0},
3793  {148, 0, 0}, {149, 0, 0}, {149, 0, 0}, {150, 0, 0}, {151, 0, 0},
3794  {151, 0, 0}, {152, 0, 0}, {153, 0, 0}, {153, 0, 0}, {154, 0, 0},
3795  {155, 0, 0}, {155, 0, 0}, {156, 0, 0}, {157, 0, 0}, {157, 0, 0},
3796  {158, 0, 0}, {159, 0, 0}, {159, 0, 0}, {160, 0, 0}, {161, 0, 0},
3797  {161, 0, 0}, {162, 0, 0}, {163, 0, 0}, {163, 0, 0}, {164, 0, 0},
3798  {165, 0, 0}, {165, 0, 0}, {166, 0, 0}, {167, 0, 0}, {167, 0, 0},
3799  {168, 0, 0}, {169, 0, 0}, {169, 0, 0}, {170, 0, 0}, {171, 0, 0},
3800  {171, 0, 0}, {172, 0, 0}, {173, 0, 0}, {173, 0, 0}, {174, 0, 0},
3801  {175, 0, 0}, {175, 0, 0}, {176, 0, 0}, {177, 0, 0}, {177, 0, 0},
3802  {178, 0, 0}, {179, 0, 0}, {179, 0, 0}, {180, 0, 0}, {181, 0, 0},
3803  {181, 0, 0}, {182, 0, 0}, {183, 0, 0}, {183, 0, 0}, {184, 0, 0},
3804  {185, 0, 0}, {186, 0, 0}, {186, 0, 0}, {187, 0, 0}, {188, 0, 0},
3805  {188, 0, 0}, {189, 0, 0}, {190, 0, 0}, {190, 0, 0}, {191, 0, 0},
3806  {192, 0, 0}, {192, 0, 0}, {193, 0, 0}, {194, 0, 0}, {194, 0, 0},
3807  {195, 0, 0}, {196, 0, 0}, {196, 0, 0}, {197, 0, 0}, {198, 0, 0},
3808  {198, 0, 0}, {199, 0, 0}, {200, 0, 0}, {200, 0, 0}, {201, 0, 0},
3809  {202, 0, 0}, {202, 0, 0}, {203, 0, 0}, {204, 0, 0}, {204, 0, 0},
3810  {205, 0, 0}, {206, 0, 0}, {206, 0, 0}, {207, 0, 0}, {208, 0, 0},
3811  {208, 0, 0}, {209, 0, 0}, {210, 0, 0}, {210, 0, 0}, {211, 0, 0},
3812  {212, 0, 0}, {212, 0, 0}, {213, 0, 0}, {214, 0, 0}, {214, 0, 0},
3813  {215, 0, 0}, {216, 0, 0}, {216, 0, 0}, {217, 0, 0}, {218, 0, 0},
3814  {218, 0, 0}, {219, 0, 0}, {220, 0, 0}, {220, 0, 0}, {221, 0, 0},
3815  {222, 0, 0}, {222, 0, 0}, {223, 0, 0}, {224, 0, 0}, {224, 0, 0},
3816  {225, 0, 0}, {226, 0, 0}, {226, 0, 0}, {227, 0, 0}, {228, 0, 0},
3817  {228, 0, 0}, {229, 0, 0}, {230, 0, 0}, {230, 0, 0}, {231, 0, 0},
3818  {232, 0, 0}, {232, 0, 0}, {233, 0, 0}, {234, 0, 0}, {234, 0, 0},
3819  {235, 0, 0}, {236, 0, 0}, {236, 0, 0}, {237, 0, 0}, {238, 0, 0},
3820  {238, 0, 0}, {239, 0, 0}, {240, 0, 0}, {240, 0, 0}, {241, 0, 0},
3821  {242, 0, 0}, {242, 0, 0}, {243, 0, 0}, {244, 0, 0}, {244, 0, 0},
3822  {245, 0, 0}, {246, 0, 0}, {246, 0, 0}, {247, 0, 0}, {248, 0, 0},
3823  {248, 0, 0}, {249, 0, 0}, {250, 0, 0}, {251, 0, 0}, {251, 0, 0},
3824  {252, 0, 0}, {253, 0, 0}, {253, 0, 0}, {254, 0, 0}, {255, 0, 0},
3825  {255, 0, 0}, {255, 1, 0}, {255, 2, 0}, {255, 2, 0}, {255, 3, 0},
3826  {255, 4, 0}, {255, 4, 0}, {255, 5, 0}, {255, 6, 0}, {255, 6, 0},
3827  {255, 7, 0}, {255, 8, 0}, {255, 8, 0}, {255, 9, 0}, {255, 10, 0},
3828  {255, 10, 0}, {255, 11, 0}, {255, 12, 0}, {255, 12, 0}, {255, 13, 0},
3829  {255, 14, 0}, {255, 14, 0}, {255, 15, 0}, {255, 16, 0}, {255, 16, 0},
3830  {255, 17, 0}, {255, 18, 0}, {255, 18, 0}, {255, 19, 0}, {255, 20, 0},
3831  {255, 20, 0}, {255, 21, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
3832  {255, 24, 0}, {255, 24, 0}, {255, 25, 0}, {255, 26, 0}, {255, 26, 0},
3833  {255, 27, 0}, {255, 28, 0}, {255, 28, 0}, {255, 29, 0}, {255, 30, 0},
3834  {255, 30, 0}, {255, 31, 0}, {255, 32, 0}, {255, 32, 0}, {255, 33, 0},
3835  {255, 34, 0}, {255, 34, 0}, {255, 35, 0}, {255, 36, 0}, {255, 36, 0},
3836  {255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 39, 0}, {255, 40, 0},
3837  {255, 40, 0}, {255, 41, 0}, {255, 42, 0}, {255, 42, 0}, {255, 43, 0},
3838  {255, 44, 0}, {255, 44, 0}, {255, 45, 0}, {255, 46, 0}, {255, 46, 0},
3839  {255, 47, 0}, {255, 48, 0}, {255, 48, 0}, {255, 49, 0}, {255, 50, 0},
3840  {255, 50, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0}, {255, 53, 0},
3841  {255, 54, 0}, {255, 54, 0}, {255, 55, 0}, {255, 56, 0}, {255, 56, 0},
3842  {255, 57, 0}, {255, 58, 0}, {255, 58, 0}, {255, 59, 0}, {255, 60, 0},
3843  {255, 60, 0}, {255, 61, 0}, {255, 62, 0}, {255, 63, 0}, {255, 63, 0},
3844  {255, 64, 0}, {255, 65, 0}, {255, 65, 0}, {255, 66, 0}, {255, 67, 0},
3845  {255, 67, 0}, {255, 68, 0}, {255, 69, 0}, {255, 69, 0}, {255, 70, 0},
3846  {255, 71, 0}, {255, 71, 0}, {255, 72, 0}, {255, 73, 0}, {255, 73, 0},
3847  {255, 74, 0}, {255, 75, 0}, {255, 75, 0}, {255, 76, 0}, {255, 77, 0},
3848  {255, 77, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0}, {255, 80, 0},
3849  {255, 81, 0}, {255, 81, 0}, {255, 82, 0}, {255, 83, 0}, {255, 83, 0},
3850  {255, 84, 0}, {255, 85, 0}, {255, 85, 0}, {255, 86, 0}, {255, 87, 0},
3851  {255, 87, 0}, {255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 90, 0},
3852  {255, 91, 0}, {255, 91, 0}, {255, 92, 0}, {255, 93, 0}, {255, 93, 0},
3853  {255, 94, 0}, {255, 95, 0}, {255, 95, 0}, {255, 96, 0}, {255, 97, 0},
3854  {255, 97, 0}, {255, 98, 0}, {255, 99, 0}, {255, 99, 0}, {255, 100, 0},
3855  {255, 101, 0}, {255, 101, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0},
3856  {255, 104, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0}, {255, 107, 0},
3857  {255, 107, 0}, {255, 108, 0}, {255, 109, 0}, {255, 109, 0}, {255, 110, 0},
3858  {255, 111, 0}, {255, 111, 0}, {255, 112, 0}, {255, 113, 0}, {255, 113, 0},
3859  {255, 114, 0}, {255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 117, 0},
3860  {255, 117, 0}, {255, 118, 0}, {255, 119, 0}, {255, 119, 0}, {255, 120, 0},
3861  {255, 121, 0}, {255, 121, 0}, {255, 122, 0}, {255, 123, 0}, {255, 123, 0},
3862  {255, 124, 0}, {255, 125, 0}, {255, 125, 0}, {255, 126, 0}, {255, 127, 0},
3863  {255, 128, 0}, {255, 128, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
3864  {255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 133, 0}, {255, 134, 0},
3865  {255, 134, 0}, {255, 135, 0}, {255, 136, 0}, {255, 136, 0}, {255, 137, 0},
3866  {255, 138, 0}, {255, 138, 0}, {255, 139, 0}, {255, 140, 0}, {255, 140, 0},
3867  {255, 141, 0}, {255, 142, 0}, {255, 142, 0}, {255, 143, 0}, {255, 144, 0},
3868  {255, 144, 0}, {255, 145, 0}, {255, 146, 0}, {255, 146, 0}, {255, 147, 0},
3869  {255, 148, 0}, {255, 148, 0}, {255, 149, 0}, {255, 150, 0}, {255, 150, 0},
3870  {255, 151, 0}, {255, 152, 0}, {255, 152, 0}, {255, 153, 0}, {255, 154, 0},
3871  {255, 154, 0}, {255, 155, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
3872  {255, 158, 0}, {255, 158, 0}, {255, 159, 0}, {255, 160, 0}, {255, 160, 0},
3873  {255, 161, 0}, {255, 162, 0}, {255, 162, 0}, {255, 163, 0}, {255, 164, 0},
3874  {255, 164, 0}, {255, 165, 0}, {255, 166, 0}, {255, 166, 0}, {255, 167, 0},
3875  {255, 168, 0}, {255, 168, 0}, {255, 169, 0}, {255, 170, 0}, {255, 170, 0},
3876  {255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 173, 0}, {255, 174, 0},
3877  {255, 174, 0}, {255, 175, 0}, {255, 176, 0}, {255, 176, 0}, {255, 177, 0},
3878  {255, 178, 0}, {255, 178, 0}, {255, 179, 0}, {255, 180, 0}, {255, 180, 0},
3879  {255, 181, 0}, {255, 182, 0}, {255, 182, 0}, {255, 183, 0}, {255, 184, 0},
3880  {255, 184, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0}, {255, 187, 0},
3881  {255, 188, 0}, {255, 188, 0}, {255, 189, 0}, {255, 190, 0}, {255, 190, 0},
3882  {255, 191, 0}, {255, 192, 0}, {255, 192, 0}, {255, 193, 0}, {255, 194, 0},
3883  {255, 195, 0}, {255, 195, 0}, {255, 196, 0}, {255, 197, 0}, {255, 197, 0},
3884  {255, 198, 0}, {255, 199, 0}, {255, 199, 0}, {255, 200, 0}, {255, 201, 0},
3885  {255, 201, 0}, {255, 202, 0}, {255, 203, 0}, {255, 203, 0}, {255, 204, 0},
3886  {255, 205, 0}, {255, 205, 0}, {255, 206, 0}, {255, 207, 0}, {255, 207, 0},
3887  {255, 208, 0}, {255, 209, 0}, {255, 209, 0}, {255, 210, 0}, {255, 211, 0},
3888  {255, 211, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0}, {255, 214, 0},
3889  {255, 215, 0}, {255, 215, 0}, {255, 216, 0}, {255, 217, 0}, {255, 217, 0},
3890  {255, 218, 0}, {255, 219, 0}, {255, 219, 0}, {255, 220, 0}, {255, 221, 0},
3891  {255, 221, 0}, {255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 224, 0},
3892  {255, 225, 0}, {255, 225, 0}, {255, 226, 0}, {255, 227, 0}, {255, 227, 0},
3893  {255, 228, 0}, {255, 229, 0}, {255, 229, 0}, {255, 230, 0}, {255, 231, 0},
3894  {255, 231, 0}, {255, 232, 0}, {255, 233, 0}, {255, 233, 0}, {255, 234, 0},
3895  {255, 235, 0}, {255, 235, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0},
3896  {255, 238, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0}, {255, 241, 0},
3897  {255, 241, 0}, {255, 242, 0}, {255, 243, 0}, {255, 243, 0}, {255, 244, 0},
3898  {255, 245, 0}, {255, 245, 0}, {255, 246, 0}, {255, 247, 0}, {255, 247, 0},
3899  {255, 248, 0}, {255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 251, 0},
3900  {255, 251, 0}, {255, 252, 0}, {255, 253, 0}, {255, 253, 0}, {255, 254, 0},
3901  {255, 255, 0}, {255, 255, 1}, {255, 255, 2}, {255, 255, 3}, {255, 255, 4},
3902  {255, 255, 5}, {255, 255, 6}, {255, 255, 7}, {255, 255, 8}, {255, 255, 9},
3903  {255, 255, 10}, {255, 255, 11}, {255, 255, 12}, {255, 255, 13}, {255, 255, 14},
3904  {255, 255, 15}, {255, 255, 16}, {255, 255, 17}, {255, 255, 18}, {255, 255, 19},
3905  {255, 255, 20}, {255, 255, 21}, {255, 255, 22}, {255, 255, 23}, {255, 255, 24},
3906  {255, 255, 25}, {255, 255, 26}, {255, 255, 27}, {255, 255, 28}, {255, 255, 29},
3907  {255, 255, 30}, {255, 255, 31}, {255, 255, 32}, {255, 255, 33}, {255, 255, 34},
3908  {255, 255, 35}, {255, 255, 36}, {255, 255, 37}, {255, 255, 38}, {255, 255, 39},
3909  {255, 255, 40}, {255, 255, 41}, {255, 255, 42}, {255, 255, 43}, {255, 255, 44},
3910  {255, 255, 45}, {255, 255, 46}, {255, 255, 47}, {255, 255, 48}, {255, 255, 49},
3911  {255, 255, 50}, {255, 255, 51}, {255, 255, 52}, {255, 255, 53}, {255, 255, 54},
3912  {255, 255, 55}, {255, 255, 56}, {255, 255, 57}, {255, 255, 58}, {255, 255, 59},
3913  {255, 255, 60}, {255, 255, 61}, {255, 255, 62}, {255, 255, 63}, {255, 255, 64},
3914  {255, 255, 65}, {255, 255, 66}, {255, 255, 67}, {255, 255, 68}, {255, 255, 69},
3915  {255, 255, 70}, {255, 255, 71}, {255, 255, 72}, {255, 255, 73}, {255, 255, 74},
3916  {255, 255, 75}, {255, 255, 76}, {255, 255, 77}, {255, 255, 78}, {255, 255, 79},
3917  {255, 255, 80}, {255, 255, 81}, {255, 255, 82}, {255, 255, 83}, {255, 255, 84},
3918  {255, 255, 85}, {255, 255, 86}, {255, 255, 87}, {255, 255, 88}, {255, 255, 89},
3919  {255, 255, 90}, {255, 255, 91}, {255, 255, 92}, {255, 255, 93}, {255, 255, 94},
3920  {255, 255, 95}, {255, 255, 96}, {255, 255, 97}, {255, 255, 98}, {255, 255, 99},
3921  {255, 255, 100}, {255, 255, 101}, {255, 255, 102}, {255, 255, 103}, {255, 255, 104},
3922  {255, 255, 105}, {255, 255, 106}, {255, 255, 107}, {255, 255, 108}, {255, 255, 109},
3923  {255, 255, 110}, {255, 255, 111}, {255, 255, 112}, {255, 255, 113}, {255, 255, 114},
3924  {255, 255, 115}, {255, 255, 116}, {255, 255, 117}, {255, 255, 118}, {255, 255, 119},
3925  {255, 255, 120}, {255, 255, 121}, {255, 255, 122}, {255, 255, 123}, {255, 255, 124},
3926  {255, 255, 125}, {255, 255, 126}, {255, 255, 127}, {255, 255, 128}, {255, 255, 129},
3927  {255, 255, 130}, {255, 255, 131}, {255, 255, 132}, {255, 255, 133}, {255, 255, 134},
3928  {255, 255, 135}, {255, 255, 136}, {255, 255, 137}, {255, 255, 138}, {255, 255, 139},
3929  {255, 255, 140}, {255, 255, 141}, {255, 255, 142}, {255, 255, 143}, {255, 255, 144},
3930  {255, 255, 145}, {255, 255, 146}, {255, 255, 147}, {255, 255, 148}, {255, 255, 149},
3931  {255, 255, 150}, {255, 255, 151}, {255, 255, 152}, {255, 255, 153}, {255, 255, 154},
3932  {255, 255, 155}, {255, 255, 157}, {255, 255, 158}, {255, 255, 159}, {255, 255, 160},
3933  {255, 255, 161}, {255, 255, 162}, {255, 255, 163}, {255, 255, 164}, {255, 255, 165},
3934  {255, 255, 166}, {255, 255, 167}, {255, 255, 168}, {255, 255, 169}, {255, 255, 170},
3935  {255, 255, 171}, {255, 255, 172}, {255, 255, 173}, {255, 255, 174}, {255, 255, 175},
3936  {255, 255, 176}, {255, 255, 177}, {255, 255, 178}, {255, 255, 179}, {255, 255, 180},
3937  {255, 255, 181}, {255, 255, 182}, {255, 255, 183}, {255, 255, 184}, {255, 255, 185},
3938  {255, 255, 186}, {255, 255, 187}, {255, 255, 188}, {255, 255, 189}, {255, 255, 190},
3939  {255, 255, 191}, {255, 255, 192}, {255, 255, 193}, {255, 255, 194}, {255, 255, 195},
3940  {255, 255, 196}, {255, 255, 197}, {255, 255, 198}, {255, 255, 199}, {255, 255, 200},
3941  {255, 255, 201}, {255, 255, 202}, {255, 255, 203}, {255, 255, 204}, {255, 255, 205},
3942  {255, 255, 206}, {255, 255, 207}, {255, 255, 208}, {255, 255, 209}, {255, 255, 210},
3943  {255, 255, 211}, {255, 255, 212}, {255, 255, 213}, {255, 255, 214}, {255, 255, 215},
3944  {255, 255, 216}, {255, 255, 217}, {255, 255, 218}, {255, 255, 219}, {255, 255, 220},
3945  {255, 255, 221}, {255, 255, 222}, {255, 255, 223}, {255, 255, 224}, {255, 255, 225},
3946  {255, 255, 226}, {255, 255, 227}, {255, 255, 228}, {255, 255, 229}, {255, 255, 230},
3947  {255, 255, 231}, {255, 255, 232}, {255, 255, 233}, {255, 255, 234}, {255, 255, 235},
3948  {255, 255, 236}, {255, 255, 237}, {255, 255, 238}, {255, 255, 239}, {255, 255, 240},
3949  {255, 255, 241}, {255, 255, 242}, {255, 255, 243}, {255, 255, 244}, {255, 255, 245},
3950  {255, 255, 246}, {255, 255, 247}, {255, 255, 248}, {255, 255, 249}, {255, 255, 250},
3951  {255, 255, 251}, {255, 255, 252}, {255, 255, 253}, {255, 255, 254}, {255, 255, 255}
3952 };
3953 
3954 const rgb_t hsv_colormap[1000] = {
3955  {255, 0, 0}, {255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 6, 0},
3956  {255, 8, 0}, {255, 9, 0}, {255, 11, 0}, {255, 12, 0}, {255, 14, 0},
3957  {255, 15, 0}, {255, 17, 0}, {255, 18, 0}, {255, 20, 0}, {255, 21, 0},
3958  {255, 23, 0}, {255, 24, 0}, {255, 26, 0}, {255, 27, 0}, {255, 29, 0},
3959  {255, 30, 0}, {255, 32, 0}, {255, 33, 0}, {255, 35, 0}, {255, 36, 0},
3960  {255, 38, 0}, {255, 39, 0}, {255, 41, 0}, {255, 42, 0}, {255, 44, 0},
3961  {255, 45, 0}, {255, 47, 0}, {255, 48, 0}, {255, 50, 0}, {255, 51, 0},
3962  {255, 53, 0}, {255, 54, 0}, {255, 56, 0}, {255, 57, 0}, {255, 59, 0},
3963  {255, 60, 0}, {255, 62, 0}, {255, 63, 0}, {255, 65, 0}, {255, 66, 0},
3964  {255, 68, 0}, {255, 69, 0}, {255, 71, 0}, {255, 72, 0}, {255, 74, 0},
3965  {255, 75, 0}, {255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 81, 0},
3966  {255, 83, 0}, {255, 84, 0}, {255, 86, 0}, {255, 87, 0}, {255, 89, 0},
3967  {255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0}, {255, 96, 0},
3968  {255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0}, {255, 104, 0},
3969  {255, 106, 0}, {255, 107, 0}, {255, 109, 0}, {255, 110, 0}, {255, 112, 0},
3970  {255, 113, 0}, {255, 115, 0}, {255, 116, 0}, {255, 118, 0}, {255, 119, 0},
3971  {255, 121, 0}, {255, 122, 0}, {255, 124, 0}, {255, 125, 0}, {255, 127, 0},
3972  {255, 128, 0}, {255, 130, 0}, {255, 131, 0}, {255, 133, 0}, {255, 134, 0},
3973  {255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 140, 0}, {255, 142, 0},
3974  {255, 143, 0}, {255, 145, 0}, {255, 146, 0}, {255, 148, 0}, {255, 149, 0},
3975  {255, 151, 0}, {255, 152, 0}, {255, 154, 0}, {255, 155, 0}, {255, 157, 0},
3976  {255, 158, 0}, {255, 160, 0}, {255, 161, 0}, {255, 163, 0}, {255, 164, 0},
3977  {255, 166, 0}, {255, 167, 0}, {255, 169, 0}, {255, 170, 0}, {255, 172, 0},
3978  {255, 173, 0}, {255, 175, 0}, {255, 176, 0}, {255, 178, 0}, {255, 179, 0},
3979  {255, 181, 0}, {255, 182, 0}, {255, 184, 0}, {255, 185, 0}, {255, 187, 0},
3980  {255, 188, 0}, {255, 190, 0}, {255, 191, 0}, {255, 193, 0}, {255, 194, 0},
3981  {255, 196, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0}, {255, 202, 0},
3982  {255, 204, 0}, {255, 205, 0}, {255, 207, 0}, {255, 208, 0}, {255, 210, 0},
3983  {255, 211, 0}, {255, 213, 0}, {255, 214, 0}, {255, 216, 0}, {255, 217, 0},
3984  {255, 219, 0}, {255, 220, 0}, {255, 222, 0}, {255, 223, 0}, {255, 225, 0},
3985  {255, 226, 0}, {255, 228, 0}, {255, 229, 0}, {255, 231, 0}, {255, 232, 0},
3986  {255, 234, 0}, {255, 235, 0}, {255, 237, 0}, {255, 238, 0}, {255, 239, 0},
3987  {254, 240, 0}, {254, 242, 0}, {253, 243, 0}, {253, 244, 0}, {252, 245, 0},
3988  {252, 246, 0}, {251, 247, 0}, {251, 248, 0}, {250, 249, 0}, {250, 250, 0},
3989  {249, 251, 0}, {249, 252, 0}, {248, 253, 0}, {248, 254, 0}, {247, 255, 0},
3990  {246, 255, 0}, {245, 255, 0}, {243, 255, 0}, {242, 255, 0}, {240, 255, 0},
3991  {239, 255, 0}, {237, 255, 0}, {236, 255, 0}, {234, 255, 0}, {233, 255, 0},
3992  {231, 255, 0}, {230, 255, 0}, {228, 255, 0}, {227, 255, 0}, {225, 255, 0},
3993  {224, 255, 0}, {222, 255, 0}, {221, 255, 0}, {219, 255, 0}, {218, 255, 0},
3994  {216, 255, 0}, {215, 255, 0}, {213, 255, 0}, {211, 255, 0}, {210, 255, 0},
3995  {208, 255, 0}, {207, 255, 0}, {205, 255, 0}, {204, 255, 0}, {202, 255, 0},
3996  {201, 255, 0}, {199, 255, 0}, {198, 255, 0}, {196, 255, 0}, {195, 255, 0},
3997  {193, 255, 0}, {192, 255, 0}, {190, 255, 0}, {189, 255, 0}, {187, 255, 0},
3998  {186, 255, 0}, {184, 255, 0}, {183, 255, 0}, {181, 255, 0}, {180, 255, 0},
3999  {178, 255, 0}, {177, 255, 0}, {175, 255, 0}, {174, 255, 0}, {172, 255, 0},
4000  {171, 255, 0}, {169, 255, 0}, {168, 255, 0}, {166, 255, 0}, {165, 255, 0},
4001  {163, 255, 0}, {162, 255, 0}, {160, 255, 0}, {159, 255, 0}, {157, 255, 0},
4002  {156, 255, 0}, {154, 255, 0}, {153, 255, 0}, {151, 255, 0}, {150, 255, 0},
4003  {148, 255, 0}, {147, 255, 0}, {145, 255, 0}, {144, 255, 0}, {142, 255, 0},
4004  {141, 255, 0}, {139, 255, 0}, {138, 255, 0}, {136, 255, 0}, {135, 255, 0},
4005  {133, 255, 0}, {132, 255, 0}, {130, 255, 0}, {129, 255, 0}, {127, 255, 0},
4006  {126, 255, 0}, {124, 255, 0}, {123, 255, 0}, {121, 255, 0}, {120, 255, 0},
4007  {118, 255, 0}, {117, 255, 0}, {115, 255, 0}, {114, 255, 0}, {112, 255, 0},
4008  {110, 255, 0}, {109, 255, 0}, {107, 255, 0}, {106, 255, 0}, {104, 255, 0},
4009  {103, 255, 0}, {101, 255, 0}, {100, 255, 0}, { 98, 255, 0}, { 97, 255, 0},
4010  { 95, 255, 0}, { 94, 255, 0}, { 92, 255, 0}, { 91, 255, 0}, { 89, 255, 0},
4011  { 88, 255, 0}, { 86, 255, 0}, { 85, 255, 0}, { 83, 255, 0}, { 82, 255, 0},
4012  { 80, 255, 0}, { 79, 255, 0}, { 77, 255, 0}, { 76, 255, 0}, { 74, 255, 0},
4013  { 73, 255, 0}, { 71, 255, 0}, { 70, 255, 0}, { 68, 255, 0}, { 67, 255, 0},
4014  { 65, 255, 0}, { 64, 255, 0}, { 62, 255, 0}, { 61, 255, 0}, { 59, 255, 0},
4015  { 58, 255, 0}, { 56, 255, 0}, { 55, 255, 0}, { 53, 255, 0}, { 52, 255, 0},
4016  { 50, 255, 0}, { 49, 255, 0}, { 47, 255, 0}, { 46, 255, 0}, { 44, 255, 0},
4017  { 43, 255, 0}, { 41, 255, 0}, { 40, 255, 0}, { 38, 255, 0}, { 37, 255, 0},
4018  { 35, 255, 0}, { 34, 255, 0}, { 32, 255, 0}, { 31, 255, 0}, { 29, 255, 0},
4019  { 28, 255, 0}, { 26, 255, 0}, { 25, 255, 0}, { 23, 255, 0}, { 22, 255, 0},
4020  { 20, 255, 0}, { 19, 255, 0}, { 17, 255, 0}, { 16, 255, 0}, { 14, 255, 0},
4021  { 12, 255, 0}, { 11, 255, 0}, { 9, 255, 0}, { 8, 255, 0}, { 7, 255, 1},
4022  { 7, 255, 2}, { 6, 255, 3}, { 6, 255, 4}, { 5, 255, 5}, { 5, 255, 6},
4023  { 4, 255, 7}, { 4, 255, 8}, { 3, 255, 9}, { 3, 255, 10}, { 2, 255, 11},
4024  { 2, 255, 12}, { 1, 255, 13}, { 1, 255, 14}, { 0, 255, 15}, { 0, 255, 16},
4025  { 0, 255, 18}, { 0, 255, 19}, { 0, 255, 21}, { 0, 255, 22}, { 0, 255, 24},
4026  { 0, 255, 25}, { 0, 255, 27}, { 0, 255, 28}, { 0, 255, 30}, { 0, 255, 31},
4027  { 0, 255, 33}, { 0, 255, 34}, { 0, 255, 36}, { 0, 255, 37}, { 0, 255, 39},
4028  { 0, 255, 40}, { 0, 255, 42}, { 0, 255, 43}, { 0, 255, 45}, { 0, 255, 46},
4029  { 0, 255, 48}, { 0, 255, 49}, { 0, 255, 51}, { 0, 255, 52}, { 0, 255, 54},
4030  { 0, 255, 55}, { 0, 255, 57}, { 0, 255, 58}, { 0, 255, 60}, { 0, 255, 61},
4031  { 0, 255, 63}, { 0, 255, 64}, { 0, 255, 66}, { 0, 255, 67}, { 0, 255, 69},
4032  { 0, 255, 70}, { 0, 255, 72}, { 0, 255, 73}, { 0, 255, 75}, { 0, 255, 76},
4033  { 0, 255, 78}, { 0, 255, 79}, { 0, 255, 81}, { 0, 255, 82}, { 0, 255, 84},
4034  { 0, 255, 86}, { 0, 255, 87}, { 0, 255, 89}, { 0, 255, 90}, { 0, 255, 92},
4035  { 0, 255, 93}, { 0, 255, 95}, { 0, 255, 96}, { 0, 255, 98}, { 0, 255, 99},
4036  { 0, 255, 101}, { 0, 255, 102}, { 0, 255, 104}, { 0, 255, 105}, { 0, 255, 107},
4037  { 0, 255, 108}, { 0, 255, 110}, { 0, 255, 111}, { 0, 255, 113}, { 0, 255, 114},
4038  { 0, 255, 116}, { 0, 255, 117}, { 0, 255, 119}, { 0, 255, 120}, { 0, 255, 122},
4039  { 0, 255, 123}, { 0, 255, 125}, { 0, 255, 126}, { 0, 255, 128}, { 0, 255, 129},
4040  { 0, 255, 131}, { 0, 255, 132}, { 0, 255, 134}, { 0, 255, 135}, { 0, 255, 137},
4041  { 0, 255, 138}, { 0, 255, 140}, { 0, 255, 141}, { 0, 255, 143}, { 0, 255, 144},
4042  { 0, 255, 146}, { 0, 255, 147}, { 0, 255, 149}, { 0, 255, 150}, { 0, 255, 152},
4043  { 0, 255, 153}, { 0, 255, 155}, { 0, 255, 156}, { 0, 255, 158}, { 0, 255, 159},
4044  { 0, 255, 161}, { 0, 255, 162}, { 0, 255, 164}, { 0, 255, 165}, { 0, 255, 167},
4045  { 0, 255, 168}, { 0, 255, 170}, { 0, 255, 171}, { 0, 255, 173}, { 0, 255, 174},
4046  { 0, 255, 176}, { 0, 255, 177}, { 0, 255, 179}, { 0, 255, 180}, { 0, 255, 182},
4047  { 0, 255, 183}, { 0, 255, 185}, { 0, 255, 187}, { 0, 255, 188}, { 0, 255, 190},
4048  { 0, 255, 191}, { 0, 255, 193}, { 0, 255, 194}, { 0, 255, 196}, { 0, 255, 197},
4049  { 0, 255, 199}, { 0, 255, 200}, { 0, 255, 202}, { 0, 255, 203}, { 0, 255, 205},
4050  { 0, 255, 206}, { 0, 255, 208}, { 0, 255, 209}, { 0, 255, 211}, { 0, 255, 212},
4051  { 0, 255, 214}, { 0, 255, 215}, { 0, 255, 217}, { 0, 255, 218}, { 0, 255, 220},
4052  { 0, 255, 221}, { 0, 255, 223}, { 0, 255, 224}, { 0, 255, 226}, { 0, 255, 227},
4053  { 0, 255, 229}, { 0, 255, 230}, { 0, 255, 232}, { 0, 255, 233}, { 0, 255, 235},
4054  { 0, 255, 236}, { 0, 255, 238}, { 0, 255, 239}, { 0, 255, 241}, { 0, 255, 242},
4055  { 0, 255, 244}, { 0, 255, 245}, { 0, 255, 247}, { 0, 255, 248}, { 0, 255, 250},
4056  { 0, 255, 251}, { 0, 255, 253}, { 0, 255, 254}, { 0, 254, 255}, { 0, 253, 255},
4057  { 0, 251, 255}, { 0, 250, 255}, { 0, 248, 255}, { 0, 247, 255}, { 0, 245, 255},
4058  { 0, 244, 255}, { 0, 242, 255}, { 0, 241, 255}, { 0, 239, 255}, { 0, 238, 255},
4059  { 0, 236, 255}, { 0, 235, 255}, { 0, 233, 255}, { 0, 232, 255}, { 0, 230, 255},
4060  { 0, 229, 255}, { 0, 227, 255}, { 0, 225, 255}, { 0, 224, 255}, { 0, 222, 255},
4061  { 0, 221, 255}, { 0, 219, 255}, { 0, 218, 255}, { 0, 216, 255}, { 0, 215, 255},
4062  { 0, 213, 255}, { 0, 212, 255}, { 0, 210, 255}, { 0, 209, 255}, { 0, 207, 255},
4063  { 0, 206, 255}, { 0, 204, 255}, { 0, 203, 255}, { 0, 201, 255}, { 0, 200, 255},
4064  { 0, 198, 255}, { 0, 197, 255}, { 0, 195, 255}, { 0, 194, 255}, { 0, 192, 255},
4065  { 0, 191, 255}, { 0, 189, 255}, { 0, 188, 255}, { 0, 186, 255}, { 0, 185, 255},
4066  { 0, 183, 255}, { 0, 182, 255}, { 0, 180, 255}, { 0, 179, 255}, { 0, 177, 255},
4067  { 0, 176, 255}, { 0, 174, 255}, { 0, 173, 255}, { 0, 171, 255}, { 0, 170, 255},
4068  { 0, 168, 255}, { 0, 167, 255}, { 0, 165, 255}, { 0, 164, 255}, { 0, 162, 255},
4069  { 0, 161, 255}, { 0, 159, 255}, { 0, 158, 255}, { 0, 156, 255}, { 0, 155, 255},
4070  { 0, 153, 255}, { 0, 152, 255}, { 0, 150, 255}, { 0, 149, 255}, { 0, 147, 255},
4071  { 0, 146, 255}, { 0, 144, 255}, { 0, 143, 255}, { 0, 141, 255}, { 0, 140, 255},
4072  { 0, 138, 255}, { 0, 137, 255}, { 0, 135, 255}, { 0, 134, 255}, { 0, 132, 255},
4073  { 0, 131, 255}, { 0, 129, 255}, { 0, 128, 255}, { 0, 126, 255}, { 0, 124, 255},
4074  { 0, 123, 255}, { 0, 121, 255}, { 0, 120, 255}, { 0, 118, 255}, { 0, 117, 255},
4075  { 0, 115, 255}, { 0, 114, 255}, { 0, 112, 255}, { 0, 111, 255}, { 0, 109, 255},
4076  { 0, 108, 255}, { 0, 106, 255}, { 0, 105, 255}, { 0, 103, 255}, { 0, 102, 255},
4077  { 0, 100, 255}, { 0, 99, 255}, { 0, 97, 255}, { 0, 96, 255}, { 0, 94, 255},
4078  { 0, 93, 255}, { 0, 91, 255}, { 0, 90, 255}, { 0, 88, 255}, { 0, 87, 255},
4079  { 0, 85, 255}, { 0, 84, 255}, { 0, 82, 255}, { 0, 81, 255}, { 0, 79, 255},
4080  { 0, 78, 255}, { 0, 76, 255}, { 0, 75, 255}, { 0, 73, 255}, { 0, 72, 255},
4081  { 0, 70, 255}, { 0, 69, 255}, { 0, 67, 255}, { 0, 66, 255}, { 0, 64, 255},
4082  { 0, 63, 255}, { 0, 61, 255}, { 0, 60, 255}, { 0, 58, 255}, { 0, 57, 255},
4083  { 0, 55, 255}, { 0, 54, 255}, { 0, 52, 255}, { 0, 51, 255}, { 0, 49, 255},
4084  { 0, 48, 255}, { 0, 46, 255}, { 0, 45, 255}, { 0, 43, 255}, { 0, 42, 255},
4085  { 0, 40, 255}, { 0, 39, 255}, { 0, 37, 255}, { 0, 36, 255}, { 0, 34, 255},
4086  { 0, 33, 255}, { 0, 31, 255}, { 0, 30, 255}, { 0, 28, 255}, { 0, 26, 255},
4087  { 0, 25, 255}, { 0, 23, 255}, { 0, 22, 255}, { 0, 20, 255}, { 0, 19, 255},
4088  { 0, 17, 255}, { 0, 16, 255}, { 1, 15, 255}, { 1, 14, 255}, { 2, 13, 255},
4089  { 2, 12, 255}, { 3, 11, 255}, { 3, 10, 255}, { 4, 9, 255}, { 4, 8, 255},
4090  { 5, 7, 255}, { 5, 6, 255}, { 6, 5, 255}, { 6, 4, 255}, { 7, 3, 255},
4091  { 7, 2, 255}, { 8, 1, 255}, { 8, 0, 255}, { 10, 0, 255}, { 11, 0, 255},
4092  { 13, 0, 255}, { 14, 0, 255}, { 16, 0, 255}, { 17, 0, 255}, { 19, 0, 255},
4093  { 20, 0, 255}, { 22, 0, 255}, { 23, 0, 255}, { 25, 0, 255}, { 26, 0, 255},
4094  { 28, 0, 255}, { 29, 0, 255}, { 31, 0, 255}, { 32, 0, 255}, { 34, 0, 255},
4095  { 35, 0, 255}, { 37, 0, 255}, { 38, 0, 255}, { 40, 0, 255}, { 41, 0, 255},
4096  { 43, 0, 255}, { 44, 0, 255}, { 46, 0, 255}, { 47, 0, 255}, { 49, 0, 255},
4097  { 50, 0, 255}, { 52, 0, 255}, { 53, 0, 255}, { 55, 0, 255}, { 56, 0, 255},
4098  { 58, 0, 255}, { 59, 0, 255}, { 61, 0, 255}, { 62, 0, 255}, { 64, 0, 255},
4099  { 65, 0, 255}, { 67, 0, 255}, { 68, 0, 255}, { 70, 0, 255}, { 72, 0, 255},
4100  { 73, 0, 255}, { 75, 0, 255}, { 76, 0, 255}, { 78, 0, 255}, { 79, 0, 255},
4101  { 81, 0, 255}, { 82, 0, 255}, { 84, 0, 255}, { 85, 0, 255}, { 87, 0, 255},
4102  { 88, 0, 255}, { 90, 0, 255}, { 91, 0, 255}, { 93, 0, 255}, { 94, 0, 255},
4103  { 96, 0, 255}, { 97, 0, 255}, { 99, 0, 255}, {100, 0, 255}, {102, 0, 255},
4104  {103, 0, 255}, {105, 0, 255}, {106, 0, 255}, {108, 0, 255}, {109, 0, 255},
4105  {111, 0, 255}, {112, 0, 255}, {114, 0, 255}, {115, 0, 255}, {117, 0, 255},
4106  {118, 0, 255}, {120, 0, 255}, {121, 0, 255}, {123, 0, 255}, {124, 0, 255},
4107  {126, 0, 255}, {127, 0, 255}, {129, 0, 255}, {130, 0, 255}, {132, 0, 255},
4108  {133, 0, 255}, {135, 0, 255}, {136, 0, 255}, {138, 0, 255}, {139, 0, 255},
4109  {141, 0, 255}, {142, 0, 255}, {144, 0, 255}, {145, 0, 255}, {147, 0, 255},
4110  {148, 0, 255}, {150, 0, 255}, {151, 0, 255}, {153, 0, 255}, {154, 0, 255},
4111  {156, 0, 255}, {157, 0, 255}, {159, 0, 255}, {160, 0, 255}, {162, 0, 255},
4112  {163, 0, 255}, {165, 0, 255}, {166, 0, 255}, {168, 0, 255}, {169, 0, 255},
4113  {171, 0, 255}, {173, 0, 255}, {174, 0, 255}, {176, 0, 255}, {177, 0, 255},
4114  {179, 0, 255}, {180, 0, 255}, {182, 0, 255}, {183, 0, 255}, {185, 0, 255},
4115  {186, 0, 255}, {188, 0, 255}, {189, 0, 255}, {191, 0, 255}, {192, 0, 255},
4116  {194, 0, 255}, {195, 0, 255}, {197, 0, 255}, {198, 0, 255}, {200, 0, 255},
4117  {201, 0, 255}, {203, 0, 255}, {204, 0, 255}, {206, 0, 255}, {207, 0, 255},
4118  {209, 0, 255}, {210, 0, 255}, {212, 0, 255}, {213, 0, 255}, {215, 0, 255},
4119  {216, 0, 255}, {218, 0, 255}, {219, 0, 255}, {221, 0, 255}, {222, 0, 255},
4120  {224, 0, 255}, {225, 0, 255}, {227, 0, 255}, {228, 0, 255}, {230, 0, 255},
4121  {231, 0, 255}, {233, 0, 255}, {234, 0, 255}, {236, 0, 255}, {237, 0, 255},
4122  {239, 0, 255}, {240, 0, 255}, {242, 0, 255}, {243, 0, 255}, {245, 0, 255},
4123  {246, 0, 255}, {247, 0, 254}, {248, 0, 253}, {248, 0, 252}, {249, 0, 251},
4124  {249, 0, 250}, {250, 0, 249}, {250, 0, 248}, {251, 0, 247}, {251, 0, 246},
4125  {252, 0, 245}, {252, 0, 244}, {253, 0, 243}, {253, 0, 242}, {254, 0, 241},
4126  {254, 0, 240}, {255, 0, 239}, {255, 0, 238}, {255, 0, 236}, {255, 0, 235},
4127  {255, 0, 233}, {255, 0, 232}, {255, 0, 230}, {255, 0, 229}, {255, 0, 227},
4128  {255, 0, 226}, {255, 0, 224}, {255, 0, 223}, {255, 0, 221}, {255, 0, 220},
4129  {255, 0, 218}, {255, 0, 217}, {255, 0, 215}, {255, 0, 214}, {255, 0, 212},
4130  {255, 0, 211}, {255, 0, 209}, {255, 0, 208}, {255, 0, 206}, {255, 0, 205},
4131  {255, 0, 203}, {255, 0, 202}, {255, 0, 200}, {255, 0, 199}, {255, 0, 197},
4132  {255, 0, 196}, {255, 0, 194}, {255, 0, 193}, {255, 0, 191}, {255, 0, 190},
4133  {255, 0, 188}, {255, 0, 187}, {255, 0, 185}, {255, 0, 184}, {255, 0, 182},
4134  {255, 0, 181}, {255, 0, 179}, {255, 0, 178}, {255, 0, 176}, {255, 0, 175},
4135  {255, 0, 173}, {255, 0, 172}, {255, 0, 170}, {255, 0, 169}, {255, 0, 167},
4136  {255, 0, 166}, {255, 0, 164}, {255, 0, 163}, {255, 0, 161}, {255, 0, 160},
4137  {255, 0, 158}, {255, 0, 157}, {255, 0, 155}, {255, 0, 154}, {255, 0, 152},
4138  {255, 0, 151}, {255, 0, 149}, {255, 0, 148}, {255, 0, 146}, {255, 0, 145},
4139  {255, 0, 143}, {255, 0, 141}, {255, 0, 140}, {255, 0, 138}, {255, 0, 137},
4140  {255, 0, 135}, {255, 0, 134}, {255, 0, 132}, {255, 0, 131}, {255, 0, 129},
4141  {255, 0, 128}, {255, 0, 126}, {255, 0, 125}, {255, 0, 123}, {255, 0, 122},
4142  {255, 0, 120}, {255, 0, 119}, {255, 0, 117}, {255, 0, 116}, {255, 0, 114},
4143  {255, 0, 113}, {255, 0, 111}, {255, 0, 110}, {255, 0, 108}, {255, 0, 107},
4144  {255, 0, 105}, {255, 0, 104}, {255, 0, 102}, {255, 0, 101}, {255, 0, 99},
4145  {255, 0, 98}, {255, 0, 96}, {255, 0, 95}, {255, 0, 93}, {255, 0, 92},
4146  {255, 0, 90}, {255, 0, 89}, {255, 0, 87}, {255, 0, 86}, {255, 0, 84},
4147  {255, 0, 83}, {255, 0, 81}, {255, 0, 80}, {255, 0, 78}, {255, 0, 77},
4148  {255, 0, 75}, {255, 0, 74}, {255, 0, 72}, {255, 0, 71}, {255, 0, 69},
4149  {255, 0, 68}, {255, 0, 66}, {255, 0, 65}, {255, 0, 63}, {255, 0, 62},
4150  {255, 0, 60}, {255, 0, 59}, {255, 0, 57}, {255, 0, 56}, {255, 0, 54},
4151  {255, 0, 53}, {255, 0, 51}, {255, 0, 50}, {255, 0, 48}, {255, 0, 47},
4152  {255, 0, 45}, {255, 0, 44}, {255, 0, 42}, {255, 0, 40}, {255, 0, 39},
4153  {255, 0, 37}, {255, 0, 36}, {255, 0, 34}, {255, 0, 33}, {255, 0, 31},
4154  {255, 0, 30}, {255, 0, 28}, {255, 0, 27}, {255, 0, 25}, {255, 0, 24}
4155 };
4156 
4157 const rgb_t jet_colormap[1000] = {
4158  { 29, 0, 102}, { 23, 0, 107}, { 17, 0, 112}, { 12, 0, 117}, { 6, 0, 122},
4159  { 0, 0, 127}, { 0, 0, 128}, { 0, 0, 129}, { 0, 0, 129}, { 0, 0, 130},
4160  { 0, 0, 131}, { 0, 0, 132}, { 0, 0, 133}, { 0, 0, 133}, { 0, 0, 134},
4161  { 0, 0, 135}, { 0, 0, 136}, { 0, 0, 137}, { 0, 0, 138}, { 0, 0, 140},
4162  { 0, 0, 141}, { 0, 0, 142}, { 0, 0, 143}, { 0, 0, 145}, { 0, 0, 146},
4163  { 0, 0, 147}, { 0, 0, 148}, { 0, 0, 150}, { 0, 0, 151}, { 0, 0, 152},
4164  { 0, 0, 153}, { 0, 0, 154}, { 0, 0, 156}, { 0, 0, 157}, { 0, 0, 158},
4165  { 0, 0, 159}, { 0, 0, 160}, { 0, 0, 161}, { 0, 0, 163}, { 0, 0, 164},
4166  { 0, 0, 165}, { 0, 0, 166}, { 0, 0, 168}, { 0, 0, 169}, { 0, 0, 170},
4167  { 0, 0, 171}, { 0, 0, 173}, { 0, 0, 174}, { 0, 0, 175}, { 0, 0, 176},
4168  { 0, 0, 178}, { 0, 0, 179}, { 0, 0, 180}, { 0, 0, 181}, { 0, 0, 183},
4169  { 0, 0, 184}, { 0, 0, 185}, { 0, 0, 186}, { 0, 0, 188}, { 0, 0, 189},
4170  { 0, 0, 190}, { 0, 0, 191}, { 0, 0, 193}, { 0, 0, 194}, { 0, 0, 195},
4171  { 0, 0, 196}, { 0, 0, 197}, { 0, 0, 198}, { 0, 0, 200}, { 0, 0, 201},
4172  { 0, 0, 202}, { 0, 0, 203}, { 0, 0, 204}, { 0, 0, 206}, { 0, 0, 207},
4173  { 0, 0, 208}, { 0, 0, 209}, { 0, 0, 211}, { 0, 0, 212}, { 0, 0, 213},
4174  { 0, 0, 214}, { 0, 0, 216}, { 0, 0, 217}, { 0, 0, 218}, { 0, 0, 219},
4175  { 0, 0, 221}, { 0, 0, 222}, { 0, 0, 223}, { 0, 0, 225}, { 0, 0, 226},
4176  { 0, 0, 227}, { 0, 0, 228}, { 0, 0, 230}, { 0, 0, 231}, { 0, 0, 232},
4177  { 0, 0, 233}, { 0, 0, 234}, { 0, 0, 234}, { 0, 0, 235}, { 0, 0, 236},
4178  { 0, 0, 237}, { 0, 0, 238}, { 0, 0, 239}, { 0, 0, 239}, { 0, 0, 240},
4179  { 0, 0, 241}, { 0, 0, 242}, { 0, 0, 243}, { 0, 0, 244}, { 0, 0, 246},
4180  { 0, 0, 247}, { 0, 0, 248}, { 0, 0, 249}, { 0, 0, 250}, { 0, 0, 251},
4181  { 0, 0, 253}, { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 254},
4182  { 0, 0, 254}, { 0, 0, 254}, { 0, 0, 255}, { 0, 0, 255}, { 0, 0, 255},
4183  { 0, 0, 255}, { 0, 0, 255}, { 0, 0, 255}, { 0, 1, 255}, { 0, 1, 255},
4184  { 0, 2, 255}, { 0, 3, 255}, { 0, 3, 255}, { 0, 4, 255}, { 0, 5, 255},
4185  { 0, 6, 255}, { 0, 6, 255}, { 0, 7, 255}, { 0, 8, 255}, { 0, 9, 255},
4186  { 0, 10, 255}, { 0, 11, 255}, { 0, 12, 255}, { 0, 13, 255}, { 0, 14, 255},
4187  { 0, 15, 255}, { 0, 16, 255}, { 0, 17, 255}, { 0, 18, 255}, { 0, 19, 255},
4188  { 0, 21, 255}, { 0, 22, 255}, { 0, 23, 255}, { 0, 24, 255}, { 0, 25, 255},
4189  { 0, 26, 255}, { 0, 27, 255}, { 0, 28, 255}, { 0, 29, 255}, { 0, 30, 255},
4190  { 0, 31, 255}, { 0, 32, 255}, { 0, 34, 255}, { 0, 35, 255}, { 0, 36, 255},
4191  { 0, 37, 255}, { 0, 38, 255}, { 0, 39, 255}, { 0, 40, 255}, { 0, 41, 255},
4192  { 0, 42, 255}, { 0, 43, 255}, { 0, 44, 255}, { 0, 45, 255}, { 0, 46, 255},
4193  { 0, 48, 255}, { 0, 49, 255}, { 0, 50, 255}, { 0, 51, 255}, { 0, 52, 255},
4194  { 0, 53, 255}, { 0, 54, 255}, { 0, 55, 255}, { 0, 56, 255}, { 0, 57, 255},
4195  { 0, 58, 255}, { 0, 58, 255}, { 0, 59, 255}, { 0, 60, 255}, { 0, 60, 255},
4196  { 0, 61, 255}, { 0, 62, 255}, { 0, 63, 255}, { 0, 63, 255}, { 0, 64, 255},
4197  { 0, 65, 255}, { 0, 66, 255}, { 0, 67, 255}, { 0, 68, 255}, { 0, 69, 255},
4198  { 0, 71, 255}, { 0, 72, 255}, { 0, 73, 255}, { 0, 74, 255}, { 0, 75, 255},
4199  { 0, 76, 255}, { 0, 77, 255}, { 0, 78, 255}, { 0, 79, 255}, { 0, 80, 255},
4200  { 0, 81, 255}, { 0, 82, 255}, { 0, 84, 255}, { 0, 85, 255}, { 0, 86, 255},
4201  { 0, 87, 255}, { 0, 88, 255}, { 0, 89, 255}, { 0, 90, 255}, { 0, 91, 255},
4202  { 0, 92, 255}, { 0, 93, 255}, { 0, 94, 255}, { 0, 95, 255}, { 0, 96, 255},
4203  { 0, 98, 255}, { 0, 99, 255}, { 0, 100, 255}, { 0, 101, 255}, { 0, 102, 255},
4204  { 0, 103, 255}, { 0, 104, 255}, { 0, 105, 255}, { 0, 106, 255}, { 0, 107, 255},
4205  { 0, 108, 255}, { 0, 109, 255}, { 0, 111, 255}, { 0, 112, 255}, { 0, 113, 255},
4206  { 0, 114, 255}, { 0, 115, 255}, { 0, 116, 255}, { 0, 117, 255}, { 0, 118, 255},
4207  { 0, 119, 255}, { 0, 120, 255}, { 0, 121, 255}, { 0, 122, 255}, { 0, 123, 255},
4208  { 0, 125, 255}, { 0, 126, 255}, { 0, 127, 255}, { 0, 128, 255}, { 0, 129, 255},
4209  { 0, 130, 255}, { 0, 131, 255}, { 0, 132, 255}, { 0, 133, 255}, { 0, 134, 255},
4210  { 0, 135, 255}, { 0, 136, 255}, { 0, 138, 255}, { 0, 139, 255}, { 0, 140, 255},
4211  { 0, 141, 255}, { 0, 142, 255}, { 0, 143, 255}, { 0, 144, 255}, { 0, 145, 255},
4212  { 0, 146, 255}, { 0, 147, 255}, { 0, 148, 255}, { 0, 149, 255}, { 0, 150, 255},
4213  { 0, 150, 255}, { 0, 151, 255}, { 0, 152, 255}, { 0, 153, 255}, { 0, 153, 255},
4214  { 0, 154, 255}, { 0, 155, 255}, { 0, 155, 255}, { 0, 156, 255}, { 0, 157, 255},
4215  { 0, 158, 255}, { 0, 159, 255}, { 0, 161, 255}, { 0, 162, 255}, { 0, 163, 255},
4216  { 0, 164, 255}, { 0, 165, 255}, { 0, 166, 255}, { 0, 167, 255}, { 0, 168, 255},
4217  { 0, 169, 255}, { 0, 170, 255}, { 0, 171, 255}, { 0, 172, 255}, { 0, 173, 255},
4218  { 0, 175, 255}, { 0, 176, 255}, { 0, 177, 255}, { 0, 178, 255}, { 0, 179, 255},
4219  { 0, 180, 255}, { 0, 181, 255}, { 0, 182, 255}, { 0, 183, 255}, { 0, 184, 255},
4220  { 0, 185, 255}, { 0, 186, 255}, { 0, 188, 255}, { 0, 189, 255}, { 0, 190, 255},
4221  { 0, 191, 255}, { 0, 192, 255}, { 0, 193, 255}, { 0, 194, 255}, { 0, 195, 255},
4222  { 0, 196, 255}, { 0, 197, 255}, { 0, 198, 255}, { 0, 199, 255}, { 0, 200, 255},
4223  { 0, 202, 255}, { 0, 203, 255}, { 0, 204, 255}, { 0, 205, 255}, { 0, 206, 255},
4224  { 0, 207, 255}, { 0, 208, 255}, { 0, 209, 255}, { 0, 210, 255}, { 0, 211, 255},
4225  { 0, 212, 255}, { 0, 213, 255}, { 0, 215, 255}, { 0, 216, 255}, { 0, 217, 255},
4226  { 0, 218, 254}, { 0, 219, 253}, { 0, 220, 252}, { 0, 221, 252}, { 0, 222, 251},
4227  { 0, 223, 250}, { 0, 224, 250}, { 0, 225, 249}, { 0, 226, 248}, { 0, 227, 247},
4228  { 0, 229, 247}, { 1, 230, 246}, { 2, 231, 245}, { 3, 232, 244}, { 3, 233, 243},
4229  { 4, 234, 242}, { 5, 235, 241}, { 5, 236, 240}, { 6, 237, 239}, { 7, 238, 238},
4230  { 8, 239, 238}, { 8, 240, 237}, { 9, 241, 236}, { 10, 242, 236}, { 10, 242, 235},
4231  { 11, 243, 235}, { 11, 244, 234}, { 12, 245, 234}, { 13, 245, 233}, { 13, 246, 232},
4232  { 14, 247, 232}, { 15, 247, 231}, { 15, 248, 231}, { 16, 249, 230}, { 17, 249, 229},
4233  { 18, 250, 228}, { 18, 251, 227}, { 19, 251, 226}, { 20, 252, 225}, { 21, 253, 224},
4234  { 22, 253, 224}, { 23, 254, 223}, { 23, 254, 222}, { 24, 255, 221}, { 25, 255, 220},
4235  { 26, 255, 219}, { 27, 255, 218}, { 28, 255, 218}, { 29, 255, 217}, { 30, 255, 216},
4236  { 30, 255, 215}, { 31, 255, 214}, { 32, 255, 214}, { 33, 255, 213}, { 34, 255, 212},
4237  { 35, 255, 211}, { 36, 255, 210}, { 37, 255, 209}, { 38, 255, 208}, { 39, 255, 207},
4238  { 39, 255, 207}, { 40, 255, 206}, { 41, 255, 205}, { 42, 255, 204}, { 43, 255, 203},
4239  { 44, 255, 202}, { 45, 255, 201}, { 46, 255, 200}, { 47, 255, 199}, { 48, 255, 198},
4240  { 48, 255, 198}, { 49, 255, 197}, { 50, 255, 196}, { 51, 255, 195}, { 52, 255, 194},
4241  { 53, 255, 193}, { 54, 255, 192}, { 55, 255, 191}, { 55, 255, 191}, { 56, 255, 190},
4242  { 57, 255, 189}, { 58, 255, 188}, { 59, 255, 187}, { 60, 255, 186}, { 60, 255, 186},
4243  { 61, 255, 185}, { 62, 255, 184}, { 63, 255, 183}, { 64, 255, 182}, { 65, 255, 181},
4244  { 65, 255, 181}, { 66, 255, 180}, { 67, 255, 179}, { 68, 255, 178}, { 69, 255, 177},
4245  { 70, 255, 176}, { 71, 255, 175}, { 72, 255, 174}, { 73, 255, 173}, { 74, 255, 172},
4246  { 74, 255, 172}, { 75, 255, 171}, { 76, 255, 170}, { 77, 255, 169}, { 78, 255, 168},
4247  { 79, 255, 167}, { 80, 255, 166}, { 81, 255, 165}, { 82, 255, 164}, { 83, 255, 163},
4248  { 83, 255, 163}, { 84, 255, 162}, { 84, 255, 162}, { 85, 255, 161}, { 85, 255, 161},
4249  { 86, 255, 160}, { 87, 255, 159}, { 87, 255, 159}, { 88, 255, 158}, { 88, 255, 158},
4250  { 89, 255, 157}, { 89, 255, 157}, { 90, 255, 156}, { 91, 255, 155}, { 92, 255, 154},
4251  { 93, 255, 153}, { 94, 255, 152}, { 95, 255, 151}, { 96, 255, 150}, { 97, 255, 149},
4252  { 97, 255, 149}, { 98, 255, 148}, { 99, 255, 147}, {100, 255, 146}, {101, 255, 145},
4253  {102, 255, 144}, {102, 255, 143}, {103, 255, 142}, {104, 255, 141}, {105, 255, 140},
4254  {106, 255, 140}, {107, 255, 139}, {107, 255, 138}, {108, 255, 137}, {109, 255, 136},
4255  {110, 255, 135}, {111, 255, 134}, {112, 255, 134}, {113, 255, 133}, {114, 255, 132},
4256  {114, 255, 131}, {115, 255, 130}, {116, 255, 130}, {117, 255, 129}, {118, 255, 128},
4257  {119, 255, 127}, {120, 255, 126}, {121, 255, 125}, {122, 255, 124}, {123, 255, 123},
4258  {123, 255, 123}, {124, 255, 122}, {125, 255, 121}, {126, 255, 120}, {127, 255, 119},
4259  {128, 255, 118}, {129, 255, 117}, {130, 255, 116}, {130, 255, 115}, {131, 255, 114},
4260  {132, 255, 114}, {133, 255, 113}, {134, 255, 112}, {134, 255, 111}, {135, 255, 110},
4261  {136, 255, 109}, {137, 255, 108}, {138, 255, 107}, {139, 255, 107}, {140, 255, 106},
4262  {140, 255, 105}, {141, 255, 104}, {142, 255, 103}, {143, 255, 102}, {144, 255, 102},
4263  {145, 255, 101}, {146, 255, 100}, {147, 255, 99}, {148, 255, 98}, {149, 255, 97},
4264  {149, 255, 97}, {150, 255, 96}, {151, 255, 95}, {152, 255, 94}, {153, 255, 93},
4265  {154, 255, 92}, {155, 255, 91}, {156, 255, 90}, {157, 255, 89}, {157, 255, 89},
4266  {158, 255, 88}, {158, 255, 88}, {159, 255, 87}, {159, 255, 87}, {160, 255, 86},
4267  {161, 255, 85}, {161, 255, 85}, {162, 255, 84}, {162, 255, 84}, {163, 255, 83},
4268  {163, 255, 83}, {164, 255, 82}, {165, 255, 81}, {166, 255, 80}, {167, 255, 79},
4269  {168, 255, 78}, {169, 255, 77}, {170, 255, 76}, {171, 255, 75}, {172, 255, 74},
4270  {172, 255, 74}, {173, 255, 73}, {174, 255, 72}, {175, 255, 71}, {176, 255, 70},
4271  {177, 255, 69}, {178, 255, 68}, {179, 255, 67}, {180, 255, 66}, {181, 255, 65},
4272  {181, 255, 65}, {182, 255, 64}, {183, 255, 63}, {184, 255, 62}, {185, 255, 61},
4273  {186, 255, 60}, {186, 255, 60}, {187, 255, 59}, {188, 255, 58}, {189, 255, 57},
4274  {190, 255, 56}, {191, 255, 55}, {191, 255, 55}, {192, 255, 54}, {193, 255, 53},
4275  {194, 255, 52}, {195, 255, 51}, {196, 255, 50}, {197, 255, 49}, {198, 255, 48},
4276  {198, 255, 48}, {199, 255, 47}, {200, 255, 46}, {201, 255, 45}, {202, 255, 44},
4277  {203, 255, 43}, {204, 255, 42}, {205, 255, 41}, {206, 255, 40}, {207, 255, 39},
4278  {207, 255, 39}, {208, 255, 38}, {209, 255, 37}, {210, 255, 36}, {211, 255, 35},
4279  {212, 255, 34}, {213, 255, 33}, {214, 255, 32}, {214, 255, 31}, {215, 255, 30},
4280  {216, 255, 30}, {217, 255, 29}, {218, 255, 28}, {218, 255, 27}, {219, 255, 26},
4281  {220, 255, 25}, {221, 255, 24}, {222, 255, 23}, {223, 255, 23}, {224, 255, 22},
4282  {224, 255, 21}, {225, 255, 20}, {226, 255, 19}, {227, 255, 18}, {228, 255, 18},
4283  {229, 255, 17}, {230, 255, 16}, {231, 255, 15}, {231, 255, 15}, {232, 255, 14},
4284  {232, 255, 13}, {233, 255, 13}, {234, 255, 12}, {234, 255, 11}, {235, 255, 11},
4285  {235, 255, 10}, {236, 255, 10}, {236, 255, 9}, {237, 255, 8}, {238, 254, 8},
4286  {238, 253, 7}, {239, 252, 6}, {240, 251, 5}, {241, 250, 5}, {242, 249, 4},
4287  {243, 248, 3}, {244, 247, 3}, {245, 246, 2}, {246, 246, 1}, {247, 245, 0},
4288  {247, 243, 0}, {248, 242, 0}, {249, 242, 0}, {250, 241, 0}, {250, 240, 0},
4289  {251, 239, 0}, {252, 238, 0}, {252, 237, 0}, {253, 236, 0}, {254, 235, 0},
4290  {255, 234, 0}, {255, 233, 0}, {255, 232, 0}, {255, 231, 0}, {255, 230, 0},
4291  {255, 229, 0}, {255, 228, 0}, {255, 227, 0}, {255, 226, 0}, {255, 225, 0},
4292  {255, 224, 0}, {255, 223, 0}, {255, 222, 0}, {255, 221, 0}, {255, 220, 0},
4293  {255, 219, 0}, {255, 218, 0}, {255, 217, 0}, {255, 216, 0}, {255, 215, 0},
4294  {255, 214, 0}, {255, 213, 0}, {255, 212, 0}, {255, 211, 0}, {255, 210, 0},
4295  {255, 209, 0}, {255, 208, 0}, {255, 207, 0}, {255, 206, 0}, {255, 205, 0},
4296  {255, 204, 0}, {255, 203, 0}, {255, 202, 0}, {255, 201, 0}, {255, 200, 0},
4297  {255, 199, 0}, {255, 198, 0}, {255, 197, 0}, {255, 196, 0}, {255, 195, 0},
4298  {255, 194, 0}, {255, 193, 0}, {255, 192, 0}, {255, 191, 0}, {255, 190, 0},
4299  {255, 189, 0}, {255, 188, 0}, {255, 187, 0}, {255, 186, 0}, {255, 185, 0},
4300  {255, 184, 0}, {255, 183, 0}, {255, 182, 0}, {255, 180, 0}, {255, 179, 0},
4301  {255, 178, 0}, {255, 177, 0}, {255, 176, 0}, {255, 176, 0}, {255, 175, 0},
4302  {255, 175, 0}, {255, 174, 0}, {255, 173, 0}, {255, 173, 0}, {255, 172, 0},
4303  {255, 171, 0}, {255, 171, 0}, {255, 170, 0}, {255, 169, 0}, {255, 168, 0},
4304  {255, 167, 0}, {255, 166, 0}, {255, 165, 0}, {255, 164, 0}, {255, 163, 0},
4305  {255, 162, 0}, {255, 161, 0}, {255, 160, 0}, {255, 159, 0}, {255, 158, 0},
4306  {255, 157, 0}, {255, 156, 0}, {255, 155, 0}, {255, 154, 0}, {255, 153, 0},
4307  {255, 152, 0}, {255, 151, 0}, {255, 150, 0}, {255, 150, 0}, {255, 149, 0},
4308  {255, 147, 0}, {255, 146, 0}, {255, 146, 0}, {255, 145, 0}, {255, 144, 0},
4309  {255, 143, 0}, {255, 142, 0}, {255, 141, 0}, {255, 140, 0}, {255, 139, 0},
4310  {255, 138, 0}, {255, 137, 0}, {255, 136, 0}, {255, 135, 0}, {255, 134, 0},
4311  {255, 133, 0}, {255, 132, 0}, {255, 131, 0}, {255, 130, 0}, {255, 129, 0},
4312  {255, 128, 0}, {255, 127, 0}, {255, 126, 0}, {255, 125, 0}, {255, 124, 0},
4313  {255, 123, 0}, {255, 122, 0}, {255, 121, 0}, {255, 120, 0}, {255, 119, 0},
4314  {255, 118, 0}, {255, 117, 0}, {255, 116, 0}, {255, 115, 0}, {255, 114, 0},
4315  {255, 113, 0}, {255, 112, 0}, {255, 111, 0}, {255, 109, 0}, {255, 108, 0},
4316  {255, 107, 0}, {255, 106, 0}, {255, 105, 0}, {255, 104, 0}, {255, 103, 0},
4317  {255, 102, 0}, {255, 101, 0}, {255, 100, 0}, {255, 99, 0}, {255, 98, 0},
4318  {255, 97, 0}, {255, 96, 0}, {255, 95, 0}, {255, 94, 0}, {255, 93, 0},
4319  {255, 92, 0}, {255, 91, 0}, {255, 91, 0}, {255, 90, 0}, {255, 90, 0},
4320  {255, 89, 0}, {255, 88, 0}, {255, 88, 0}, {255, 87, 0}, {255, 86, 0},
4321  {255, 86, 0}, {255, 85, 0}, {255, 84, 0}, {255, 83, 0}, {255, 82, 0},
4322  {255, 81, 0}, {255, 80, 0}, {255, 79, 0}, {255, 78, 0}, {255, 77, 0},
4323  {255, 76, 0}, {255, 75, 0}, {255, 74, 0}, {255, 73, 0}, {255, 72, 0},
4324  {255, 71, 0}, {255, 70, 0}, {255, 69, 0}, {255, 68, 0}, {255, 67, 0},
4325  {255, 66, 0}, {255, 65, 0}, {255, 64, 0}, {255, 63, 0}, {255, 62, 0},
4326  {255, 61, 0}, {255, 60, 0}, {255, 59, 0}, {255, 58, 0}, {255, 57, 0},
4327  {255, 56, 0}, {255, 55, 0}, {255, 54, 0}, {255, 54, 0}, {255, 53, 0},
4328  {255, 51, 0}, {255, 50, 0}, {255, 49, 0}, {255, 48, 0}, {255, 47, 0},
4329  {255, 46, 0}, {255, 45, 0}, {255, 44, 0}, {255, 43, 0}, {255, 42, 0},
4330  {255, 41, 0}, {255, 40, 0}, {255, 39, 0}, {255, 38, 0}, {255, 37, 0},
4331  {255, 36, 0}, {255, 35, 0}, {255, 34, 0}, {255, 33, 0}, {255, 32, 0},
4332  {255, 31, 0}, {255, 30, 0}, {255, 29, 0}, {255, 28, 0}, {255, 27, 0},
4333  {255, 26, 0}, {255, 25, 0}, {255, 24, 0}, {254, 23, 0}, {254, 22, 0},
4334  {254, 21, 0}, {254, 20, 0}, {254, 19, 0}, {254, 18, 0}, {253, 17, 0},
4335  {251, 16, 0}, {250, 15, 0}, {249, 14, 0}, {248, 13, 0}, {247, 12, 0},
4336  {246, 11, 0}, {244, 10, 0}, {243, 9, 0}, {242, 8, 0}, {241, 7, 0},
4337  {240, 6, 0}, {239, 6, 0}, {239, 5, 0}, {238, 4, 0}, {237, 4, 0},
4338  {236, 3, 0}, {235, 3, 0}, {234, 2, 0}, {234, 1, 0}, {233, 1, 0},
4339  {232, 0, 0}, {231, 0, 0}, {230, 0, 0}, {228, 0, 0}, {227, 0, 0},
4340  {226, 0, 0}, {225, 0, 0}, {223, 0, 0}, {222, 0, 0}, {221, 0, 0},
4341  {219, 0, 0}, {218, 0, 0}, {217, 0, 0}, {216, 0, 0}, {214, 0, 0},
4342  {213, 0, 0}, {212, 0, 0}, {211, 0, 0}, {209, 0, 0}, {208, 0, 0},
4343  {207, 0, 0}, {206, 0, 0}, {204, 0, 0}, {203, 0, 0}, {202, 0, 0},
4344  {201, 0, 0}, {200, 0, 0}, {198, 0, 0}, {197, 0, 0}, {196, 0, 0},
4345  {195, 0, 0}, {194, 0, 0}, {193, 0, 0}, {191, 0, 0}, {190, 0, 0},
4346  {189, 0, 0}, {188, 0, 0}, {186, 0, 0}, {185, 0, 0}, {184, 0, 0},
4347  {183, 0, 0}, {181, 0, 0}, {180, 0, 0}, {179, 0, 0}, {178, 0, 0},
4348  {176, 0, 0}, {175, 0, 0}, {174, 0, 0}, {173, 0, 0}, {171, 0, 0},
4349  {170, 0, 0}, {169, 0, 0}, {168, 0, 0}, {166, 0, 0}, {165, 0, 0},
4350  {164, 0, 0}, {163, 0, 0}, {161, 0, 0}, {160, 0, 0}, {159, 0, 0},
4351  {158, 0, 0}, {157, 0, 0}, {156, 0, 0}, {154, 0, 0}, {153, 0, 0},
4352  {152, 0, 0}, {151, 0, 0}, {150, 0, 0}, {148, 0, 0}, {147, 0, 0},
4353  {146, 0, 0}, {145, 0, 0}, {143, 0, 0}, {142, 0, 0}, {141, 0, 0},
4354  {140, 0, 0}, {138, 0, 0}, {137, 0, 0}, {136, 0, 0}, {135, 0, 0},
4355  {134, 0, 0}, {133, 0, 0}, {133, 0, 0}, {132, 0, 0}, {131, 0, 0},
4356  {130, 0, 0}, {129, 0, 0}, {129, 0, 0}, {128, 0, 0}, {127, 0, 0},
4357  {122, 0, 9}, {117, 0, 18}, {112, 0, 27}, {107, 0, 36}, {102, 0, 45}
4358 };
4359 
4360 const rgb_t prism_colormap[1000] = {
4361  {255, 0, 0}, {255, 2, 0}, {255, 4, 0}, {255, 6, 0}, {255, 8, 0},
4362  {255, 10, 0}, {255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0},
4363  {255, 19, 0}, {255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 27, 0},
4364  {255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 34, 0}, {255, 36, 0},
4365  {255, 38, 0}, {255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0},
4366  {255, 48, 0}, {255, 50, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
4367  {255, 57, 0}, {255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0},
4368  {255, 67, 0}, {255, 69, 0}, {255, 71, 0}, {255, 73, 0}, {255, 75, 0},
4369  {255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0},
4370  {255, 86, 0}, {255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 94, 0},
4371  {255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0},
4372  {255, 105, 0}, {255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0},
4373  {255, 115, 0}, {255, 117, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
4374  {255, 124, 0}, {255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0},
4375  {255, 134, 0}, {255, 136, 0}, {255, 138, 0}, {255, 140, 0}, {255, 142, 0},
4376  {255, 144, 0}, {255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0},
4377  {255, 153, 0}, {255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 161, 0},
4378  {255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 168, 0}, {255, 170, 0},
4379  {255, 172, 0}, {255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0},
4380  {255, 182, 0}, {255, 184, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
4381  {255, 191, 0}, {255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0},
4382  {255, 201, 0}, {255, 203, 0}, {255, 205, 0}, {255, 207, 0}, {255, 209, 0},
4383  {255, 211, 0}, {255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0},
4384  {255, 220, 0}, {255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 228, 0},
4385  {255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 235, 0}, {255, 237, 0},
4386  {255, 239, 0}, {255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0},
4387  {255, 249, 0}, {255, 251, 0}, {255, 253, 0}, {255, 255, 0}, {252, 255, 0},
4388  {248, 255, 0}, {244, 255, 0}, {240, 255, 0}, {237, 255, 0}, {233, 255, 0},
4389  {229, 255, 0}, {225, 255, 0}, {221, 255, 0}, {217, 255, 0}, {214, 255, 0},
4390  {210, 255, 0}, {206, 255, 0}, {202, 255, 0}, {198, 255, 0}, {195, 255, 0},
4391  {191, 255, 0}, {187, 255, 0}, {183, 255, 0}, {179, 255, 0}, {175, 255, 0},
4392  {172, 255, 0}, {168, 255, 0}, {164, 255, 0}, {160, 255, 0}, {156, 255, 0},
4393  {152, 255, 0}, {149, 255, 0}, {145, 255, 0}, {141, 255, 0}, {137, 255, 0},
4394  {133, 255, 0}, {129, 255, 0}, {126, 255, 0}, {122, 255, 0}, {118, 255, 0},
4395  {114, 255, 0}, {110, 255, 0}, {106, 255, 0}, {103, 255, 0}, { 99, 255, 0},
4396  { 95, 255, 0}, { 91, 255, 0}, { 87, 255, 0}, { 83, 255, 0}, { 80, 255, 0},
4397  { 76, 255, 0}, { 72, 255, 0}, { 68, 255, 0}, { 64, 255, 0}, { 60, 255, 0},
4398  { 57, 255, 0}, { 53, 255, 0}, { 49, 255, 0}, { 45, 255, 0}, { 41, 255, 0},
4399  { 38, 255, 0}, { 34, 255, 0}, { 30, 255, 0}, { 26, 255, 0}, { 22, 255, 0},
4400  { 18, 255, 0}, { 15, 255, 0}, { 11, 255, 0}, { 7, 255, 0}, { 3, 255, 0},
4401  { 0, 254, 1}, { 0, 250, 5}, { 0, 247, 8}, { 0, 243, 12}, { 0, 239, 16},
4402  { 0, 235, 20}, { 0, 231, 24}, { 0, 227, 28}, { 0, 224, 31}, { 0, 220, 35},
4403  { 0, 216, 39}, { 0, 212, 43}, { 0, 208, 47}, { 0, 204, 51}, { 0, 201, 54},
4404  { 0, 197, 58}, { 0, 193, 62}, { 0, 189, 66}, { 0, 185, 70}, { 0, 181, 74},
4405  { 0, 178, 77}, { 0, 174, 81}, { 0, 170, 85}, { 0, 166, 89}, { 0, 162, 93},
4406  { 0, 159, 96}, { 0, 155, 100}, { 0, 151, 104}, { 0, 147, 108}, { 0, 143, 112},
4407  { 0, 139, 116}, { 0, 136, 119}, { 0, 132, 123}, { 0, 128, 127}, { 0, 124, 131},
4408  { 0, 120, 135}, { 0, 116, 139}, { 0, 113, 142}, { 0, 109, 146}, { 0, 105, 150},
4409  { 0, 101, 154}, { 0, 97, 158}, { 0, 93, 162}, { 0, 90, 165}, { 0, 86, 169},
4410  { 0, 82, 173}, { 0, 78, 177}, { 0, 74, 181}, { 0, 70, 185}, { 0, 67, 188},
4411  { 0, 63, 192}, { 0, 59, 196}, { 0, 55, 200}, { 0, 51, 204}, { 0, 47, 208},
4412  { 0, 44, 211}, { 0, 40, 215}, { 0, 36, 219}, { 0, 32, 223}, { 0, 28, 227},
4413  { 0, 25, 230}, { 0, 21, 234}, { 0, 17, 238}, { 0, 13, 242}, { 0, 9, 246},
4414  { 0, 5, 250}, { 0, 2, 253}, { 2, 0, 255}, { 4, 0, 255}, { 7, 0, 255},
4415  { 9, 0, 255}, { 12, 0, 255}, { 14, 0, 255}, { 17, 0, 255}, { 19, 0, 255},
4416  { 22, 0, 255}, { 25, 0, 255}, { 27, 0, 255}, { 30, 0, 255}, { 32, 0, 255},
4417  { 35, 0, 255}, { 37, 0, 255}, { 40, 0, 255}, { 42, 0, 255}, { 45, 0, 255},
4418  { 47, 0, 255}, { 50, 0, 255}, { 53, 0, 255}, { 55, 0, 255}, { 58, 0, 255},
4419  { 60, 0, 255}, { 63, 0, 255}, { 65, 0, 255}, { 68, 0, 255}, { 70, 0, 255},
4420  { 73, 0, 255}, { 76, 0, 255}, { 78, 0, 255}, { 81, 0, 255}, { 83, 0, 255},
4421  { 86, 0, 255}, { 88, 0, 255}, { 91, 0, 255}, { 93, 0, 255}, { 96, 0, 255},
4422  { 99, 0, 255}, {101, 0, 255}, {104, 0, 255}, {106, 0, 255}, {109, 0, 255},
4423  {111, 0, 255}, {114, 0, 255}, {116, 0, 255}, {119, 0, 255}, {122, 0, 255},
4424  {124, 0, 255}, {127, 0, 255}, {129, 0, 255}, {132, 0, 255}, {134, 0, 255},
4425  {137, 0, 255}, {139, 0, 255}, {142, 0, 255}, {144, 0, 255}, {147, 0, 255},
4426  {150, 0, 255}, {152, 0, 255}, {155, 0, 255}, {157, 0, 255}, {160, 0, 255},
4427  {162, 0, 255}, {165, 0, 255}, {167, 0, 255}, {170, 0, 255}, {171, 0, 251},
4428  {173, 0, 247}, {174, 0, 244}, {175, 0, 240}, {176, 0, 236}, {178, 0, 232},
4429  {179, 0, 228}, {180, 0, 224}, {181, 0, 221}, {183, 0, 217}, {184, 0, 213},
4430  {185, 0, 209}, {187, 0, 205}, {188, 0, 201}, {189, 0, 198}, {190, 0, 194},
4431  {192, 0, 190}, {193, 0, 186}, {194, 0, 182}, {196, 0, 178}, {197, 0, 175},
4432  {198, 0, 171}, {199, 0, 167}, {201, 0, 163}, {202, 0, 159}, {203, 0, 155},
4433  {204, 0, 152}, {206, 0, 148}, {207, 0, 144}, {208, 0, 140}, {210, 0, 136},
4434  {211, 0, 132}, {212, 0, 129}, {213, 0, 125}, {215, 0, 121}, {216, 0, 117},
4435  {217, 0, 113}, {218, 0, 110}, {220, 0, 106}, {221, 0, 102}, {222, 0, 98},
4436  {224, 0, 94}, {225, 0, 90}, {226, 0, 87}, {227, 0, 83}, {229, 0, 79},
4437  {230, 0, 75}, {231, 0, 71}, {233, 0, 67}, {234, 0, 64}, {235, 0, 60},
4438  {236, 0, 56}, {238, 0, 52}, {239, 0, 48}, {240, 0, 44}, {241, 0, 41},
4439  {243, 0, 37}, {244, 0, 33}, {245, 0, 29}, {247, 0, 25}, {248, 0, 21},
4440  {249, 0, 18}, {250, 0, 14}, {252, 0, 10}, {253, 0, 6}, {254, 0, 2},
4441  {255, 1, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 8, 0},
4442  {255, 10, 0}, {255, 12, 0}, {255, 14, 0}, {255, 16, 0}, {255, 18, 0},
4443  {255, 20, 0}, {255, 22, 0}, {255, 24, 0}, {255, 26, 0}, {255, 28, 0},
4444  {255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 35, 0}, {255, 37, 0},
4445  {255, 39, 0}, {255, 41, 0}, {255, 43, 0}, {255, 45, 0}, {255, 47, 0},
4446  {255, 49, 0}, {255, 51, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
4447  {255, 58, 0}, {255, 60, 0}, {255, 62, 0}, {255, 64, 0}, {255, 66, 0},
4448  {255, 68, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 75, 0},
4449  {255, 77, 0}, {255, 79, 0}, {255, 81, 0}, {255, 83, 0}, {255, 85, 0},
4450  {255, 87, 0}, {255, 89, 0}, {255, 91, 0}, {255, 93, 0}, {255, 95, 0},
4451  {255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 102, 0}, {255, 104, 0},
4452  {255, 106, 0}, {255, 108, 0}, {255, 110, 0}, {255, 112, 0}, {255, 114, 0},
4453  {255, 116, 0}, {255, 118, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
4454  {255, 125, 0}, {255, 127, 0}, {255, 129, 0}, {255, 131, 0}, {255, 133, 0},
4455  {255, 135, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 142, 0},
4456  {255, 144, 0}, {255, 146, 0}, {255, 148, 0}, {255, 150, 0}, {255, 152, 0},
4457  {255, 154, 0}, {255, 156, 0}, {255, 158, 0}, {255, 160, 0}, {255, 162, 0},
4458  {255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 169, 0}, {255, 171, 0},
4459  {255, 173, 0}, {255, 175, 0}, {255, 177, 0}, {255, 179, 0}, {255, 181, 0},
4460  {255, 183, 0}, {255, 185, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
4461  {255, 192, 0}, {255, 194, 0}, {255, 196, 0}, {255, 198, 0}, {255, 200, 0},
4462  {255, 202, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 209, 0},
4463  {255, 211, 0}, {255, 213, 0}, {255, 215, 0}, {255, 217, 0}, {255, 219, 0},
4464  {255, 221, 0}, {255, 223, 0}, {255, 225, 0}, {255, 227, 0}, {255, 229, 0},
4465  {255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 236, 0}, {255, 238, 0},
4466  {255, 240, 0}, {255, 242, 0}, {255, 244, 0}, {255, 246, 0}, {255, 248, 0},
4467  {255, 250, 0}, {255, 252, 0}, {255, 253, 0}, {254, 255, 0}, {250, 255, 0},
4468  {247, 255, 0}, {243, 255, 0}, {239, 255, 0}, {235, 255, 0}, {231, 255, 0},
4469  {227, 255, 0}, {224, 255, 0}, {220, 255, 0}, {216, 255, 0}, {212, 255, 0},
4470  {208, 255, 0}, {204, 255, 0}, {201, 255, 0}, {197, 255, 0}, {193, 255, 0},
4471  {189, 255, 0}, {185, 255, 0}, {181, 255, 0}, {178, 255, 0}, {174, 255, 0},
4472  {170, 255, 0}, {166, 255, 0}, {162, 255, 0}, {159, 255, 0}, {155, 255, 0},
4473  {151, 255, 0}, {147, 255, 0}, {143, 255, 0}, {139, 255, 0}, {136, 255, 0},
4474  {132, 255, 0}, {128, 255, 0}, {124, 255, 0}, {120, 255, 0}, {116, 255, 0},
4475  {113, 255, 0}, {109, 255, 0}, {105, 255, 0}, {101, 255, 0}, { 97, 255, 0},
4476  { 93, 255, 0}, { 90, 255, 0}, { 86, 255, 0}, { 82, 255, 0}, { 78, 255, 0},
4477  { 74, 255, 0}, { 70, 255, 0}, { 67, 255, 0}, { 63, 255, 0}, { 59, 255, 0},
4478  { 55, 255, 0}, { 51, 255, 0}, { 47, 255, 0}, { 44, 255, 0}, { 40, 255, 0},
4479  { 36, 255, 0}, { 32, 255, 0}, { 28, 255, 0}, { 25, 255, 0}, { 21, 255, 0},
4480  { 17, 255, 0}, { 13, 255, 0}, { 9, 255, 0}, { 5, 255, 0}, { 2, 255, 0},
4481  { 0, 253, 2}, { 0, 249, 6}, { 0, 245, 10}, { 0, 241, 14}, { 0, 237, 18},
4482  { 0, 234, 21}, { 0, 230, 25}, { 0, 226, 29}, { 0, 222, 33}, { 0, 218, 37},
4483  { 0, 214, 41}, { 0, 211, 44}, { 0, 207, 48}, { 0, 203, 52}, { 0, 199, 56},
4484  { 0, 195, 60}, { 0, 191, 64}, { 0, 188, 67}, { 0, 184, 71}, { 0, 180, 75},
4485  { 0, 176, 79}, { 0, 172, 83}, { 0, 168, 87}, { 0, 165, 90}, { 0, 161, 94},
4486  { 0, 157, 98}, { 0, 153, 102}, { 0, 149, 106}, { 0, 145, 110}, { 0, 142, 113},
4487  { 0, 138, 117}, { 0, 134, 121}, { 0, 130, 125}, { 0, 126, 129}, { 0, 123, 132},
4488  { 0, 119, 136}, { 0, 115, 140}, { 0, 111, 144}, { 0, 107, 148}, { 0, 103, 152},
4489  { 0, 100, 155}, { 0, 96, 159}, { 0, 92, 163}, { 0, 88, 167}, { 0, 84, 171},
4490  { 0, 80, 175}, { 0, 77, 178}, { 0, 73, 182}, { 0, 69, 186}, { 0, 65, 190},
4491  { 0, 61, 194}, { 0, 57, 198}, { 0, 54, 201}, { 0, 50, 205}, { 0, 46, 209},
4492  { 0, 42, 213}, { 0, 38, 217}, { 0, 34, 221}, { 0, 31, 224}, { 0, 27, 228},
4493  { 0, 23, 232}, { 0, 19, 236}, { 0, 15, 240}, { 0, 11, 244}, { 0, 8, 247},
4494  { 0, 4, 251}, { 0, 0, 255}, { 3, 0, 255}, { 5, 0, 255}, { 8, 0, 255},
4495  { 10, 0, 255}, { 13, 0, 255}, { 15, 0, 255}, { 18, 0, 255}, { 20, 0, 255},
4496  { 23, 0, 255}, { 26, 0, 255}, { 28, 0, 255}, { 31, 0, 255}, { 33, 0, 255},
4497  { 36, 0, 255}, { 38, 0, 255}, { 41, 0, 255}, { 43, 0, 255}, { 46, 0, 255},
4498  { 48, 0, 255}, { 51, 0, 255}, { 54, 0, 255}, { 56, 0, 255}, { 59, 0, 255},
4499  { 61, 0, 255}, { 64, 0, 255}, { 66, 0, 255}, { 69, 0, 255}, { 71, 0, 255},
4500  { 74, 0, 255}, { 77, 0, 255}, { 79, 0, 255}, { 82, 0, 255}, { 84, 0, 255},
4501  { 87, 0, 255}, { 89, 0, 255}, { 92, 0, 255}, { 94, 0, 255}, { 97, 0, 255},
4502  {100, 0, 255}, {102, 0, 255}, {105, 0, 255}, {107, 0, 255}, {110, 0, 255},
4503  {112, 0, 255}, {115, 0, 255}, {117, 0, 255}, {120, 0, 255}, {123, 0, 255},
4504  {125, 0, 255}, {128, 0, 255}, {130, 0, 255}, {133, 0, 255}, {135, 0, 255},
4505  {138, 0, 255}, {140, 0, 255}, {143, 0, 255}, {145, 0, 255}, {148, 0, 255},
4506  {151, 0, 255}, {153, 0, 255}, {156, 0, 255}, {158, 0, 255}, {161, 0, 255},
4507  {163, 0, 255}, {166, 0, 255}, {168, 0, 255}, {171, 0, 253}, {172, 0, 250},
4508  {173, 0, 246}, {174, 0, 242}, {176, 0, 238}, {177, 0, 234}, {178, 0, 230},
4509  {179, 0, 227}, {181, 0, 223}, {182, 0, 219}, {183, 0, 215}, {185, 0, 211},
4510  {186, 0, 208}, {187, 0, 204}, {188, 0, 200}, {190, 0, 196}, {191, 0, 192},
4511  {192, 0, 188}, {193, 0, 185}, {195, 0, 181}, {196, 0, 177}, {197, 0, 173},
4512  {199, 0, 169}, {200, 0, 165}, {201, 0, 162}, {202, 0, 158}, {204, 0, 154},
4513  {205, 0, 150}, {206, 0, 146}, {208, 0, 142}, {209, 0, 139}, {210, 0, 135},
4514  {211, 0, 131}, {213, 0, 127}, {214, 0, 123}, {215, 0, 119}, {216, 0, 116},
4515  {218, 0, 112}, {219, 0, 108}, {220, 0, 104}, {222, 0, 100}, {223, 0, 96},
4516  {224, 0, 93}, {225, 0, 89}, {227, 0, 85}, {228, 0, 81}, {229, 0, 77},
4517  {230, 0, 74}, {232, 0, 70}, {233, 0, 66}, {234, 0, 62}, {236, 0, 58},
4518  {237, 0, 54}, {238, 0, 51}, {239, 0, 47}, {241, 0, 43}, {242, 0, 39},
4519  {243, 0, 35}, {245, 0, 31}, {246, 0, 28}, {247, 0, 24}, {248, 0, 20},
4520  {250, 0, 16}, {251, 0, 12}, {252, 0, 8}, {253, 0, 5}, {255, 0, 1},
4521  {255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 9, 0},
4522  {255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0}, {255, 19, 0},
4523  {255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 26, 0}, {255, 28, 0},
4524  {255, 30, 0}, {255, 32, 0}, {255, 34, 0}, {255, 36, 0}, {255, 38, 0},
4525  {255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0}, {255, 47, 0},
4526  {255, 49, 0}, {255, 51, 0}, {255, 53, 0}, {255, 55, 0}, {255, 57, 0},
4527  {255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0}, {255, 67, 0},
4528  {255, 69, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 76, 0},
4529  {255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0}, {255, 86, 0},
4530  {255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0},
4531  {255, 97, 0}, {255, 99, 0}, {255, 101, 0}, {255, 103, 0}, {255, 105, 0},
4532  {255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0}, {255, 114, 0},
4533  {255, 116, 0}, {255, 118, 0}, {255, 120, 0}, {255, 122, 0}, {255, 124, 0},
4534  {255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0}, {255, 134, 0},
4535  {255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 143, 0},
4536  {255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0}, {255, 153, 0},
4537  {255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 160, 0}, {255, 162, 0},
4538  {255, 164, 0}, {255, 166, 0}, {255, 168, 0}, {255, 170, 0}, {255, 172, 0},
4539  {255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0}, {255, 181, 0},
4540  {255, 183, 0}, {255, 185, 0}, {255, 187, 0}, {255, 189, 0}, {255, 191, 0},
4541  {255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0},
4542  {255, 203, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 210, 0},
4543  {255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0}, {255, 220, 0},
4544  {255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 227, 0}, {255, 229, 0},
4545  {255, 231, 0}, {255, 233, 0}, {255, 235, 0}, {255, 237, 0}, {255, 239, 0},
4546  {255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0}, {255, 248, 0},
4547  {255, 250, 0}, {255, 252, 0}, {255, 254, 0}, {253, 255, 0}, {249, 255, 0},
4548  {245, 255, 0}, {241, 255, 0}, {237, 255, 0}, {234, 255, 0}, {230, 255, 0},
4549  {226, 255, 0}, {222, 255, 0}, {218, 255, 0}, {214, 255, 0}, {211, 255, 0},
4550  {207, 255, 0}, {203, 255, 0}, {199, 255, 0}, {195, 255, 0}, {191, 255, 0},
4551  {188, 255, 0}, {184, 255, 0}, {180, 255, 0}, {176, 255, 0}, {172, 255, 0},
4552  {168, 255, 0}, {165, 255, 0}, {161, 255, 0}, {157, 255, 0}, {153, 255, 0},
4553  {149, 255, 0}, {145, 255, 0}, {142, 255, 0}, {138, 255, 0}, {134, 255, 0},
4554  {130, 255, 0}, {126, 255, 0}, {123, 255, 0}, {119, 255, 0}, {115, 255, 0},
4555  {111, 255, 0}, {107, 255, 0}, {103, 255, 0}, {100, 255, 0}, { 96, 255, 0},
4556  { 92, 255, 0}, { 88, 255, 0}, { 84, 255, 0}, { 80, 255, 0}, { 77, 255, 0},
4557  { 73, 255, 0}, { 69, 255, 0}, { 65, 255, 0}, { 61, 255, 0}, { 57, 255, 0},
4558  { 54, 255, 0}, { 50, 255, 0}, { 46, 255, 0}, { 42, 255, 0}, { 38, 255, 0},
4559  { 34, 255, 0}, { 31, 255, 0}, { 27, 255, 0}, { 23, 255, 0}, { 19, 255, 0},
4560  { 15, 255, 0}, { 11, 255, 0}, { 8, 255, 0}, { 4, 255, 0}, { 0, 255, 0}
4561 };
4562 
4563 const rgb_t vga_colormap[1000] = {
4564  {255, 255, 255}, {254, 254, 254}, {253, 253, 253}, {252, 252, 252}, {251, 251, 251},
4565  {250, 250, 250}, {249, 249, 249}, {248, 248, 248}, {247, 247, 247}, {246, 246, 246},
4566  {245, 245, 245}, {244, 244, 244}, {244, 244, 244}, {243, 243, 243}, {242, 242, 242},
4567  {241, 241, 241}, {240, 240, 240}, {239, 239, 239}, {238, 238, 238}, {237, 237, 237},
4568  {236, 236, 236}, {235, 235, 235}, {234, 234, 234}, {233, 233, 233}, {232, 232, 232},
4569  {231, 231, 231}, {230, 230, 230}, {229, 229, 229}, {228, 228, 228}, {227, 227, 227},
4570  {226, 226, 226}, {225, 225, 225}, {224, 224, 224}, {223, 223, 223}, {222, 222, 222},
4571  {221, 221, 221}, {221, 221, 221}, {220, 220, 220}, {219, 219, 219}, {218, 218, 218},
4572  {217, 217, 217}, {216, 216, 216}, {215, 215, 215}, {214, 214, 214}, {213, 213, 213},
4573  {212, 212, 212}, {211, 211, 211}, {210, 210, 210}, {209, 209, 209}, {208, 208, 208},
4574  {207, 207, 207}, {206, 206, 206}, {205, 205, 205}, {204, 204, 204}, {203, 203, 203},
4575  {202, 202, 202}, {201, 201, 201}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
4576  {198, 198, 198}, {197, 197, 197}, {196, 196, 196}, {195, 195, 195}, {194, 194, 194},
4577  {193, 193, 193}, {192, 192, 192}, {192, 190, 190}, {193, 187, 187}, {194, 184, 184},
4578  {195, 181, 181}, {195, 179, 179}, {196, 176, 176}, {197, 173, 173}, {198, 170, 170},
4579  {199, 167, 167}, {200, 164, 164}, {201, 161, 161}, {202, 159, 159}, {203, 156, 156},
4580  {204, 153, 153}, {205, 150, 150}, {206, 147, 147}, {207, 144, 144}, {208, 141, 141},
4581  {209, 138, 138}, {210, 136, 136}, {211, 133, 133}, {212, 130, 130}, {213, 127, 127},
4582  {214, 124, 124}, {215, 121, 121}, {216, 118, 118}, {217, 115, 115}, {217, 113, 113},
4583  {218, 110, 110}, {219, 107, 107}, {220, 104, 104}, {221, 101, 101}, {222, 98, 98},
4584  {223, 95, 95}, {224, 92, 92}, {225, 90, 90}, {226, 87, 87}, {227, 84, 84},
4585  {228, 81, 81}, {229, 78, 78}, {230, 75, 75}, {231, 72, 72}, {232, 69, 69},
4586  {233, 67, 67}, {234, 64, 64}, {235, 61, 61}, {236, 58, 58}, {237, 55, 55},
4587  {238, 52, 52}, {239, 49, 49}, {239, 47, 47}, {240, 44, 44}, {241, 41, 41},
4588  {242, 38, 38}, {243, 35, 35}, {244, 32, 32}, {245, 29, 29}, {246, 26, 26},
4589  {247, 24, 24}, {248, 21, 21}, {249, 18, 18}, {250, 15, 15}, {251, 12, 12},
4590  {252, 9, 9}, {253, 6, 6}, {254, 3, 3}, {255, 1, 1}, {255, 3, 0},
4591  {255, 7, 0}, {255, 11, 0}, {255, 15, 0}, {255, 18, 0}, {255, 22, 0},
4592  {255, 26, 0}, {255, 30, 0}, {255, 34, 0}, {255, 38, 0}, {255, 41, 0},
4593  {255, 45, 0}, {255, 49, 0}, {255, 53, 0}, {255, 57, 0}, {255, 60, 0},
4594  {255, 64, 0}, {255, 68, 0}, {255, 72, 0}, {255, 76, 0}, {255, 80, 0},
4595  {255, 83, 0}, {255, 87, 0}, {255, 91, 0}, {255, 95, 0}, {255, 99, 0},
4596  {255, 103, 0}, {255, 106, 0}, {255, 110, 0}, {255, 114, 0}, {255, 118, 0},
4597  {255, 122, 0}, {255, 126, 0}, {255, 129, 0}, {255, 133, 0}, {255, 137, 0},
4598  {255, 141, 0}, {255, 145, 0}, {255, 149, 0}, {255, 152, 0}, {255, 156, 0},
4599  {255, 160, 0}, {255, 164, 0}, {255, 168, 0}, {255, 172, 0}, {255, 175, 0},
4600  {255, 179, 0}, {255, 183, 0}, {255, 187, 0}, {255, 191, 0}, {255, 195, 0},
4601  {255, 198, 0}, {255, 202, 0}, {255, 206, 0}, {255, 210, 0}, {255, 214, 0},
4602  {255, 217, 0}, {255, 221, 0}, {255, 225, 0}, {255, 229, 0}, {255, 233, 0},
4603  {255, 237, 0}, {255, 240, 0}, {255, 244, 0}, {255, 248, 0}, {255, 252, 0},
4604  {254, 255, 0}, {250, 255, 0}, {247, 255, 0}, {243, 255, 0}, {239, 255, 0},
4605  {235, 255, 0}, {231, 255, 0}, {227, 255, 0}, {224, 255, 0}, {220, 255, 0},
4606  {216, 255, 0}, {212, 255, 0}, {208, 255, 0}, {204, 255, 0}, {201, 255, 0},
4607  {197, 255, 0}, {193, 255, 0}, {189, 255, 0}, {185, 255, 0}, {181, 255, 0},
4608  {178, 255, 0}, {174, 255, 0}, {170, 255, 0}, {166, 255, 0}, {162, 255, 0},
4609  {159, 255, 0}, {155, 255, 0}, {151, 255, 0}, {147, 255, 0}, {143, 255, 0},
4610  {139, 255, 0}, {136, 255, 0}, {132, 255, 0}, {128, 255, 0}, {124, 255, 0},
4611  {120, 255, 0}, {116, 255, 0}, {113, 255, 0}, {109, 255, 0}, {105, 255, 0},
4612  {101, 255, 0}, { 97, 255, 0}, { 93, 255, 0}, { 90, 255, 0}, { 86, 255, 0},
4613  { 82, 255, 0}, { 78, 255, 0}, { 74, 255, 0}, { 70, 255, 0}, { 67, 255, 0},
4614  { 63, 255, 0}, { 59, 255, 0}, { 55, 255, 0}, { 51, 255, 0}, { 47, 255, 0},
4615  { 44, 255, 0}, { 40, 255, 0}, { 36, 255, 0}, { 32, 255, 0}, { 28, 255, 0},
4616  { 25, 255, 0}, { 21, 255, 0}, { 17, 255, 0}, { 13, 255, 0}, { 9, 255, 0},
4617  { 5, 255, 0}, { 2, 255, 0}, { 0, 255, 2}, { 0, 255, 6}, { 0, 255, 10},
4618  { 0, 255, 14}, { 0, 255, 18}, { 0, 255, 21}, { 0, 255, 25}, { 0, 255, 29},
4619  { 0, 255, 33}, { 0, 255, 37}, { 0, 255, 41}, { 0, 255, 44}, { 0, 255, 48},
4620  { 0, 255, 52}, { 0, 255, 56}, { 0, 255, 60}, { 0, 255, 64}, { 0, 255, 67},
4621  { 0, 255, 71}, { 0, 255, 75}, { 0, 255, 79}, { 0, 255, 83}, { 0, 255, 87},
4622  { 0, 255, 90}, { 0, 255, 94}, { 0, 255, 98}, { 0, 255, 102}, { 0, 255, 106},
4623  { 0, 255, 110}, { 0, 255, 113}, { 0, 255, 117}, { 0, 255, 121}, { 0, 255, 125},
4624  { 0, 255, 129}, { 0, 255, 132}, { 0, 255, 136}, { 0, 255, 140}, { 0, 255, 144},
4625  { 0, 255, 148}, { 0, 255, 152}, { 0, 255, 155}, { 0, 255, 159}, { 0, 255, 163},
4626  { 0, 255, 167}, { 0, 255, 171}, { 0, 255, 175}, { 0, 255, 178}, { 0, 255, 182},
4627  { 0, 255, 186}, { 0, 255, 190}, { 0, 255, 194}, { 0, 255, 198}, { 0, 255, 201},
4628  { 0, 255, 205}, { 0, 255, 209}, { 0, 255, 213}, { 0, 255, 217}, { 0, 255, 221},
4629  { 0, 255, 224}, { 0, 255, 228}, { 0, 255, 232}, { 0, 255, 236}, { 0, 255, 240},
4630  { 0, 255, 244}, { 0, 255, 247}, { 0, 255, 251}, { 0, 255, 255}, { 0, 251, 255},
4631  { 0, 247, 255}, { 0, 244, 255}, { 0, 240, 255}, { 0, 236, 255}, { 0, 232, 255},
4632  { 0, 228, 255}, { 0, 224, 255}, { 0, 221, 255}, { 0, 217, 255}, { 0, 213, 255},
4633  { 0, 209, 255}, { 0, 205, 255}, { 0, 201, 255}, { 0, 198, 255}, { 0, 194, 255},
4634  { 0, 190, 255}, { 0, 186, 255}, { 0, 182, 255}, { 0, 178, 255}, { 0, 175, 255},
4635  { 0, 171, 255}, { 0, 167, 255}, { 0, 163, 255}, { 0, 159, 255}, { 0, 155, 255},
4636  { 0, 152, 255}, { 0, 148, 255}, { 0, 144, 255}, { 0, 140, 255}, { 0, 136, 255},
4637  { 0, 132, 255}, { 0, 129, 255}, { 0, 125, 255}, { 0, 121, 255}, { 0, 117, 255},
4638  { 0, 113, 255}, { 0, 110, 255}, { 0, 106, 255}, { 0, 102, 255}, { 0, 98, 255},
4639  { 0, 94, 255}, { 0, 90, 255}, { 0, 87, 255}, { 0, 83, 255}, { 0, 79, 255},
4640  { 0, 75, 255}, { 0, 71, 255}, { 0, 67, 255}, { 0, 64, 255}, { 0, 60, 255},
4641  { 0, 56, 255}, { 0, 52, 255}, { 0, 48, 255}, { 0, 44, 255}, { 0, 41, 255},
4642  { 0, 37, 255}, { 0, 33, 255}, { 0, 29, 255}, { 0, 25, 255}, { 0, 21, 255},
4643  { 0, 18, 255}, { 0, 14, 255}, { 0, 10, 255}, { 0, 6, 255}, { 0, 2, 255},
4644  { 2, 0, 255}, { 5, 0, 255}, { 9, 0, 255}, { 13, 0, 255}, { 17, 0, 255},
4645  { 21, 0, 255}, { 25, 0, 255}, { 28, 0, 255}, { 32, 0, 255}, { 36, 0, 255},
4646  { 40, 0, 255}, { 44, 0, 255}, { 47, 0, 255}, { 51, 0, 255}, { 55, 0, 255},
4647  { 59, 0, 255}, { 63, 0, 255}, { 67, 0, 255}, { 70, 0, 255}, { 74, 0, 255},
4648  { 78, 0, 255}, { 82, 0, 255}, { 86, 0, 255}, { 90, 0, 255}, { 93, 0, 255},
4649  { 97, 0, 255}, {101, 0, 255}, {105, 0, 255}, {109, 0, 255}, {113, 0, 255},
4650  {116, 0, 255}, {120, 0, 255}, {124, 0, 255}, {128, 0, 255}, {132, 0, 255},
4651  {136, 0, 255}, {139, 0, 255}, {143, 0, 255}, {147, 0, 255}, {151, 0, 255},
4652  {155, 0, 255}, {159, 0, 255}, {162, 0, 255}, {166, 0, 255}, {170, 0, 255},
4653  {174, 0, 255}, {178, 0, 255}, {181, 0, 255}, {185, 0, 255}, {189, 0, 255},
4654  {193, 0, 255}, {197, 0, 255}, {201, 0, 255}, {204, 0, 255}, {208, 0, 255},
4655  {212, 0, 255}, {216, 0, 255}, {220, 0, 255}, {224, 0, 255}, {227, 0, 255},
4656  {231, 0, 255}, {235, 0, 255}, {239, 0, 255}, {243, 0, 255}, {247, 0, 255},
4657  {250, 0, 255}, {254, 0, 255}, {252, 0, 252}, {248, 0, 248}, {244, 0, 244},
4658  {240, 0, 240}, {237, 0, 237}, {233, 0, 233}, {229, 0, 229}, {225, 0, 225},
4659  {221, 0, 221}, {217, 0, 217}, {214, 0, 214}, {210, 0, 210}, {206, 0, 206},
4660  {202, 0, 202}, {198, 0, 198}, {195, 0, 195}, {191, 0, 191}, {187, 0, 187},
4661  {183, 0, 183}, {179, 0, 179}, {175, 0, 175}, {172, 0, 172}, {168, 0, 168},
4662  {164, 0, 164}, {160, 0, 160}, {156, 0, 156}, {152, 0, 152}, {149, 0, 149},
4663  {145, 0, 145}, {141, 0, 141}, {137, 0, 137}, {133, 0, 133}, {129, 0, 129},
4664  {126, 0, 126}, {122, 0, 122}, {118, 0, 118}, {114, 0, 114}, {110, 0, 110},
4665  {106, 0, 106}, {103, 0, 103}, { 99, 0, 99}, { 95, 0, 95}, { 91, 0, 91},
4666  { 87, 0, 87}, { 83, 0, 83}, { 80, 0, 80}, { 76, 0, 76}, { 72, 0, 72},
4667  { 68, 0, 68}, { 64, 0, 64}, { 60, 0, 60}, { 57, 0, 57}, { 53, 0, 53},
4668  { 49, 0, 49}, { 45, 0, 45}, { 41, 0, 41}, { 38, 0, 38}, { 34, 0, 34},
4669  { 30, 0, 30}, { 26, 0, 26}, { 22, 0, 22}, { 18, 0, 18}, { 15, 0, 15},
4670  { 11, 0, 11}, { 7, 0, 7}, { 3, 0, 3}, { 0, 0, 0}, { 2, 2, 2},
4671  { 4, 4, 4}, { 6, 6, 6}, { 8, 8, 8}, { 10, 10, 10}, { 12, 12, 12},
4672  { 14, 14, 14}, { 16, 16, 16}, { 18, 18, 18}, { 20, 20, 20}, { 21, 21, 21},
4673  { 23, 23, 23}, { 25, 25, 25}, { 27, 27, 27}, { 29, 29, 29}, { 31, 31, 31},
4674  { 33, 33, 33}, { 35, 35, 35}, { 37, 37, 37}, { 39, 39, 39}, { 41, 41, 41},
4675  { 43, 43, 43}, { 44, 44, 44}, { 46, 46, 46}, { 48, 48, 48}, { 50, 50, 50},
4676  { 52, 52, 52}, { 54, 54, 54}, { 56, 56, 56}, { 58, 58, 58}, { 60, 60, 60},
4677  { 62, 62, 62}, { 64, 64, 64}, { 65, 65, 65}, { 67, 67, 67}, { 69, 69, 69},
4678  { 71, 71, 71}, { 73, 73, 73}, { 75, 75, 75}, { 77, 77, 77}, { 79, 79, 79},
4679  { 81, 81, 81}, { 83, 83, 83}, { 85, 85, 85}, { 87, 87, 87}, { 88, 88, 88},
4680  { 90, 90, 90}, { 92, 92, 92}, { 94, 94, 94}, { 96, 96, 96}, { 98, 98, 98},
4681  {100, 100, 100}, {102, 102, 102}, {104, 104, 104}, {106, 106, 106}, {108, 108, 108},
4682  {110, 110, 110}, {111, 111, 111}, {113, 113, 113}, {115, 115, 115}, {117, 117, 117},
4683  {119, 119, 119}, {121, 121, 121}, {123, 123, 123}, {125, 125, 125}, {127, 127, 127},
4684  {128, 126, 126}, {128, 124, 124}, {128, 123, 123}, {128, 121, 121}, {128, 119, 119},
4685  {128, 117, 117}, {128, 115, 115}, {128, 113, 113}, {128, 111, 111}, {128, 109, 109},
4686  {128, 107, 107}, {128, 105, 105}, {128, 103, 103}, {128, 101, 101}, {128, 100, 100},
4687  {128, 98, 98}, {128, 96, 96}, {128, 94, 94}, {128, 92, 92}, {128, 90, 90},
4688  {128, 88, 88}, {128, 86, 86}, {128, 84, 84}, {128, 82, 82}, {128, 80, 80},
4689  {128, 78, 78}, {128, 77, 77}, {128, 75, 75}, {128, 73, 73}, {128, 71, 71},
4690  {128, 69, 69}, {128, 67, 67}, {128, 65, 65}, {128, 63, 63}, {128, 61, 61},
4691  {128, 59, 59}, {128, 57, 57}, {128, 56, 56}, {128, 54, 54}, {128, 52, 52},
4692  {128, 50, 50}, {128, 48, 48}, {128, 46, 46}, {128, 44, 44}, {128, 42, 42},
4693  {128, 40, 40}, {128, 38, 38}, {128, 36, 36}, {128, 34, 34}, {128, 33, 33},
4694  {128, 31, 31}, {128, 29, 29}, {128, 27, 27}, {128, 25, 25}, {128, 23, 23},
4695  {128, 21, 21}, {128, 19, 19}, {128, 17, 17}, {128, 15, 15}, {128, 13, 13},
4696  {128, 11, 11}, {128, 10, 10}, {128, 8, 8}, {128, 6, 6}, {128, 4, 4},
4697  {128, 2, 2}, {128, 0, 0}, {128, 2, 0}, {128, 4, 0}, {128, 6, 0},
4698  {128, 8, 0}, {128, 10, 0}, {128, 11, 0}, {128, 13, 0}, {128, 15, 0},
4699  {128, 17, 0}, {128, 19, 0}, {128, 21, 0}, {128, 23, 0}, {128, 25, 0},
4700  {128, 27, 0}, {128, 29, 0}, {128, 31, 0}, {128, 33, 0}, {128, 34, 0},
4701  {128, 36, 0}, {128, 38, 0}, {128, 40, 0}, {128, 42, 0}, {128, 44, 0},
4702  {128, 46, 0}, {128, 48, 0}, {128, 50, 0}, {128, 52, 0}, {128, 54, 0},
4703  {128, 56, 0}, {128, 57, 0}, {128, 59, 0}, {128, 61, 0}, {128, 63, 0},
4704  {128, 65, 0}, {128, 67, 0}, {128, 69, 0}, {128, 71, 0}, {128, 73, 0},
4705  {128, 75, 0}, {128, 77, 0}, {128, 78, 0}, {128, 80, 0}, {128, 82, 0},
4706  {128, 84, 0}, {128, 86, 0}, {128, 88, 0}, {128, 90, 0}, {128, 92, 0},
4707  {128, 94, 0}, {128, 96, 0}, {128, 98, 0}, {128, 100, 0}, {128, 101, 0},
4708  {128, 103, 0}, {128, 105, 0}, {128, 107, 0}, {128, 109, 0}, {128, 111, 0},
4709  {128, 113, 0}, {128, 115, 0}, {128, 117, 0}, {128, 119, 0}, {128, 121, 0},
4710  {128, 123, 0}, {128, 124, 0}, {128, 126, 0}, {127, 128, 0}, {125, 128, 0},
4711  {123, 128, 0}, {121, 128, 0}, {119, 128, 0}, {117, 128, 0}, {115, 128, 0},
4712  {113, 128, 0}, {111, 128, 0}, {110, 128, 0}, {108, 128, 0}, {106, 128, 0},
4713  {104, 128, 0}, {102, 128, 0}, {100, 128, 0}, { 98, 128, 0}, { 96, 128, 0},
4714  { 94, 128, 0}, { 92, 128, 0}, { 90, 128, 0}, { 88, 128, 0}, { 87, 128, 0},
4715  { 85, 128, 0}, { 83, 128, 0}, { 81, 128, 0}, { 79, 128, 0}, { 77, 128, 0},
4716  { 75, 128, 0}, { 73, 128, 0}, { 71, 128, 0}, { 69, 128, 0}, { 67, 128, 0},
4717  { 65, 128, 0}, { 64, 128, 0}, { 62, 128, 0}, { 60, 128, 0}, { 58, 128, 0},
4718  { 56, 128, 0}, { 54, 128, 0}, { 52, 128, 0}, { 50, 128, 0}, { 48, 128, 0},
4719  { 46, 128, 0}, { 44, 128, 0}, { 43, 128, 0}, { 41, 128, 0}, { 39, 128, 0},
4720  { 37, 128, 0}, { 35, 128, 0}, { 33, 128, 0}, { 31, 128, 0}, { 29, 128, 0},
4721  { 27, 128, 0}, { 25, 128, 0}, { 23, 128, 0}, { 21, 128, 0}, { 20, 128, 0},
4722  { 18, 128, 0}, { 16, 128, 0}, { 14, 128, 0}, { 12, 128, 0}, { 10, 128, 0},
4723  { 8, 128, 0}, { 6, 128, 0}, { 4, 128, 0}, { 2, 128, 0}, { 0, 128, 0},
4724  { 0, 128, 2}, { 0, 128, 3}, { 0, 128, 5}, { 0, 128, 7}, { 0, 128, 9},
4725  { 0, 128, 11}, { 0, 128, 13}, { 0, 128, 15}, { 0, 128, 17}, { 0, 128, 19},
4726  { 0, 128, 21}, { 0, 128, 23}, { 0, 128, 25}, { 0, 128, 26}, { 0, 128, 28},
4727  { 0, 128, 30}, { 0, 128, 32}, { 0, 128, 34}, { 0, 128, 36}, { 0, 128, 38},
4728  { 0, 128, 40}, { 0, 128, 42}, { 0, 128, 44}, { 0, 128, 46}, { 0, 128, 47},
4729  { 0, 128, 49}, { 0, 128, 51}, { 0, 128, 53}, { 0, 128, 55}, { 0, 128, 57},
4730  { 0, 128, 59}, { 0, 128, 61}, { 0, 128, 63}, { 0, 128, 65}, { 0, 128, 67},
4731  { 0, 128, 69}, { 0, 128, 70}, { 0, 128, 72}, { 0, 128, 74}, { 0, 128, 76},
4732  { 0, 128, 78}, { 0, 128, 80}, { 0, 128, 82}, { 0, 128, 84}, { 0, 128, 86},
4733  { 0, 128, 88}, { 0, 128, 90}, { 0, 128, 92}, { 0, 128, 93}, { 0, 128, 95},
4734  { 0, 128, 97}, { 0, 128, 99}, { 0, 128, 101}, { 0, 128, 103}, { 0, 128, 105},
4735  { 0, 128, 107}, { 0, 128, 109}, { 0, 128, 111}, { 0, 128, 113}, { 0, 128, 114},
4736  { 0, 128, 116}, { 0, 128, 118}, { 0, 128, 120}, { 0, 128, 122}, { 0, 128, 124},
4737  { 0, 128, 126}, { 0, 127, 128}, { 0, 125, 128}, { 0, 123, 128}, { 0, 121, 128},
4738  { 0, 119, 128}, { 0, 118, 128}, { 0, 116, 128}, { 0, 114, 128}, { 0, 112, 128},
4739  { 0, 110, 128}, { 0, 108, 128}, { 0, 106, 128}, { 0, 104, 128}, { 0, 102, 128},
4740  { 0, 100, 128}, { 0, 98, 128}, { 0, 96, 128}, { 0, 95, 128}, { 0, 93, 128},
4741  { 0, 91, 128}, { 0, 89, 128}, { 0, 87, 128}, { 0, 85, 128}, { 0, 83, 128},
4742  { 0, 81, 128}, { 0, 79, 128}, { 0, 77, 128}, { 0, 75, 128}, { 0, 74, 128},
4743  { 0, 72, 128}, { 0, 70, 128}, { 0, 68, 128}, { 0, 66, 128}, { 0, 64, 128},
4744  { 0, 62, 128}, { 0, 60, 128}, { 0, 58, 128}, { 0, 56, 128}, { 0, 54, 128},
4745  { 0, 52, 128}, { 0, 51, 128}, { 0, 49, 128}, { 0, 47, 128}, { 0, 45, 128},
4746  { 0, 43, 128}, { 0, 41, 128}, { 0, 39, 128}, { 0, 37, 128}, { 0, 35, 128},
4747  { 0, 33, 128}, { 0, 31, 128}, { 0, 29, 128}, { 0, 28, 128}, { 0, 26, 128},
4748  { 0, 24, 128}, { 0, 22, 128}, { 0, 20, 128}, { 0, 18, 128}, { 0, 16, 128},
4749  { 0, 14, 128}, { 0, 12, 128}, { 0, 10, 128}, { 0, 8, 128}, { 0, 7, 128},
4750  { 0, 5, 128}, { 0, 3, 128}, { 0, 1, 128}, { 1, 0, 128}, { 3, 0, 128},
4751  { 5, 0, 128}, { 7, 0, 128}, { 9, 0, 128}, { 11, 0, 128}, { 13, 0, 128},
4752  { 15, 0, 128}, { 16, 0, 128}, { 18, 0, 128}, { 20, 0, 128}, { 22, 0, 128},
4753  { 24, 0, 128}, { 26, 0, 128}, { 28, 0, 128}, { 30, 0, 128}, { 32, 0, 128},
4754  { 34, 0, 128}, { 36, 0, 128}, { 38, 0, 128}, { 39, 0, 128}, { 41, 0, 128},
4755  { 43, 0, 128}, { 45, 0, 128}, { 47, 0, 128}, { 49, 0, 128}, { 51, 0, 128},
4756  { 53, 0, 128}, { 55, 0, 128}, { 57, 0, 128}, { 59, 0, 128}, { 60, 0, 128},
4757  { 62, 0, 128}, { 64, 0, 128}, { 66, 0, 128}, { 68, 0, 128}, { 70, 0, 128},
4758  { 72, 0, 128}, { 74, 0, 128}, { 76, 0, 128}, { 78, 0, 128}, { 80, 0, 128},
4759  { 82, 0, 128}, { 83, 0, 128}, { 85, 0, 128}, { 87, 0, 128}, { 89, 0, 128},
4760  { 91, 0, 128}, { 93, 0, 128}, { 95, 0, 128}, { 97, 0, 128}, { 99, 0, 128},
4761  {101, 0, 128}, {103, 0, 128}, {105, 0, 128}, {106, 0, 128}, {108, 0, 128},
4762  {110, 0, 128}, {112, 0, 128}, {114, 0, 128}, {116, 0, 128}, {118, 0, 128},
4763  {120, 0, 128}, {122, 0, 128}, {124, 0, 128}, {126, 0, 128}, {128, 0, 128}
4764 };
4765 
4766 const rgb_t yarg_colormap[1000] = {
4767  { 0, 0, 0}, { 0, 0, 0}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
4768  { 1, 1, 1}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2}, { 2, 2, 2},
4769  { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 3, 3, 3}, { 4, 4, 4},
4770  { 4, 4, 4}, { 4, 4, 4}, { 4, 4, 4}, { 5, 5, 5}, { 5, 5, 5},
4771  { 5, 5, 5}, { 5, 5, 5}, { 6, 6, 6}, { 6, 6, 6}, { 6, 6, 6},
4772  { 6, 6, 6}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7}, { 7, 7, 7},
4773  { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 8, 8, 8}, { 9, 9, 9},
4774  { 9, 9, 9}, { 9, 9, 9}, { 9, 9, 9}, { 10, 10, 10}, { 10, 10, 10},
4775  { 10, 10, 10}, { 10, 10, 10}, { 11, 11, 11}, { 11, 11, 11}, { 11, 11, 11},
4776  { 11, 11, 11}, { 12, 12, 12}, { 12, 12, 12}, { 12, 12, 12}, { 13, 13, 13},
4777  { 13, 13, 13}, { 13, 13, 13}, { 13, 13, 13}, { 14, 14, 14}, { 14, 14, 14},
4778  { 14, 14, 14}, { 14, 14, 14}, { 15, 15, 15}, { 15, 15, 15}, { 15, 15, 15},
4779  { 15, 15, 15}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16}, { 16, 16, 16},
4780  { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 17, 17, 17}, { 18, 18, 18},
4781  { 18, 18, 18}, { 18, 18, 18}, { 18, 18, 18}, { 19, 19, 19}, { 19, 19, 19},
4782  { 19, 19, 19}, { 19, 19, 19}, { 20, 20, 20}, { 20, 20, 20}, { 20, 20, 20},
4783  { 20, 20, 20}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21}, { 21, 21, 21},
4784  { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 22, 22, 22}, { 23, 23, 23},
4785  { 23, 23, 23}, { 23, 23, 23}, { 23, 23, 23}, { 24, 24, 24}, { 24, 24, 24},
4786  { 24, 24, 24}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25}, { 25, 25, 25},
4787  { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 26, 26, 26}, { 27, 27, 27},
4788  { 27, 27, 27}, { 27, 27, 27}, { 27, 27, 27}, { 28, 28, 28}, { 28, 28, 28},
4789  { 28, 28, 28}, { 28, 28, 28}, { 29, 29, 29}, { 29, 29, 29}, { 29, 29, 29},
4790  { 29, 29, 29}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30}, { 30, 30, 30},
4791  { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 31, 31, 31}, { 32, 32, 32},
4792  { 32, 32, 32}, { 32, 32, 32}, { 32, 32, 32}, { 33, 33, 33}, { 33, 33, 33},
4793  { 33, 33, 33}, { 33, 33, 33}, { 34, 34, 34}, { 34, 34, 34}, { 34, 34, 34},
4794  { 34, 34, 34}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35}, { 35, 35, 35},
4795  { 36, 36, 36}, { 36, 36, 36}, { 36, 36, 36}, { 37, 37, 37}, { 37, 37, 37},
4796  { 37, 37, 37}, { 37, 37, 37}, { 38, 38, 38}, { 38, 38, 38}, { 38, 38, 38},
4797  { 38, 38, 38}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39}, { 39, 39, 39},
4798  { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 40, 40, 40}, { 41, 41, 41},
4799  { 41, 41, 41}, { 41, 41, 41}, { 41, 41, 41}, { 42, 42, 42}, { 42, 42, 42},
4800  { 42, 42, 42}, { 42, 42, 42}, { 43, 43, 43}, { 43, 43, 43}, { 43, 43, 43},
4801  { 43, 43, 43}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44}, { 44, 44, 44},
4802  { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 45, 45, 45}, { 46, 46, 46},
4803  { 46, 46, 46}, { 46, 46, 46}, { 46, 46, 46}, { 47, 47, 47}, { 47, 47, 47},
4804  { 47, 47, 47}, { 47, 47, 47}, { 48, 48, 48}, { 48, 48, 48}, { 48, 48, 48},
4805  { 48, 48, 48}, { 49, 49, 49}, { 49, 49, 49}, { 49, 49, 49}, { 50, 50, 50},
4806  { 50, 50, 50}, { 50, 50, 50}, { 50, 50, 50}, { 51, 51, 51}, { 51, 51, 51},
4807  { 51, 51, 51}, { 51, 51, 51}, { 52, 52, 52}, { 52, 52, 52}, { 52, 52, 52},
4808  { 52, 52, 52}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53}, { 53, 53, 53},
4809  { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 54, 54, 54}, { 55, 55, 55},
4810  { 55, 55, 55}, { 55, 55, 55}, { 55, 55, 55}, { 56, 56, 56}, { 56, 56, 56},
4811  { 56, 56, 56}, { 56, 56, 56}, { 57, 57, 57}, { 57, 57, 57}, { 57, 57, 57},
4812  { 57, 57, 57}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58}, { 58, 58, 58},
4813  { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 59, 59, 59}, { 60, 60, 60},
4814  { 60, 60, 60}, { 60, 60, 60}, { 60, 60, 60}, { 61, 61, 61}, { 61, 61, 61},
4815  { 61, 61, 61}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62}, { 62, 62, 62},
4816  { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 63, 63, 63}, { 64, 64, 64},
4817  { 64, 64, 64}, { 64, 64, 64}, { 64, 64, 64}, { 65, 65, 65}, { 65, 65, 65},
4818  { 65, 65, 65}, { 65, 65, 65}, { 66, 66, 66}, { 66, 66, 66}, { 66, 66, 66},
4819  { 66, 66, 66}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67}, { 67, 67, 67},
4820  { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 68, 68, 68}, { 69, 69, 69},
4821  { 69, 69, 69}, { 69, 69, 69}, { 69, 69, 69}, { 70, 70, 70}, { 70, 70, 70},
4822  { 70, 70, 70}, { 70, 70, 70}, { 71, 71, 71}, { 71, 71, 71}, { 71, 71, 71},
4823  { 71, 71, 71}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72}, { 72, 72, 72},
4824  { 73, 73, 73}, { 73, 73, 73}, { 73, 73, 73}, { 74, 74, 74}, { 74, 74, 74},
4825  { 74, 74, 74}, { 74, 74, 74}, { 75, 75, 75}, { 75, 75, 75}, { 75, 75, 75},
4826  { 75, 75, 75}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76}, { 76, 76, 76},
4827  { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 77, 77, 77}, { 78, 78, 78},
4828  { 78, 78, 78}, { 78, 78, 78}, { 78, 78, 78}, { 79, 79, 79}, { 79, 79, 79},
4829  { 79, 79, 79}, { 79, 79, 79}, { 80, 80, 80}, { 80, 80, 80}, { 80, 80, 80},
4830  { 80, 80, 80}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81}, { 81, 81, 81},
4831  { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 82, 82, 82}, { 83, 83, 83},
4832  { 83, 83, 83}, { 83, 83, 83}, { 83, 83, 83}, { 84, 84, 84}, { 84, 84, 84},
4833  { 84, 84, 84}, { 84, 84, 84}, { 85, 85, 85}, { 85, 85, 85}, { 85, 85, 85},
4834  { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 86, 86, 86}, { 87, 87, 87},
4835  { 87, 87, 87}, { 87, 87, 87}, { 87, 87, 87}, { 88, 88, 88}, { 88, 88, 88},
4836  { 88, 88, 88}, { 88, 88, 88}, { 89, 89, 89}, { 89, 89, 89}, { 89, 89, 89},
4837  { 89, 89, 89}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90}, { 90, 90, 90},
4838  { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 91, 91, 91}, { 92, 92, 92},
4839  { 92, 92, 92}, { 92, 92, 92}, { 92, 92, 92}, { 93, 93, 93}, { 93, 93, 93},
4840  { 93, 93, 93}, { 93, 93, 93}, { 94, 94, 94}, { 94, 94, 94}, { 94, 94, 94},
4841  { 94, 94, 94}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95}, { 95, 95, 95},
4842  { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 96, 96, 96}, { 97, 97, 97},
4843  { 97, 97, 97}, { 97, 97, 97}, { 98, 98, 98}, { 98, 98, 98}, { 98, 98, 98},
4844  { 98, 98, 98}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99}, { 99, 99, 99},
4845  {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {100, 100, 100}, {101, 101, 101},
4846  {101, 101, 101}, {101, 101, 101}, {101, 101, 101}, {102, 102, 102}, {102, 102, 102},
4847  {102, 102, 102}, {102, 102, 102}, {103, 103, 103}, {103, 103, 103}, {103, 103, 103},
4848  {103, 103, 103}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104}, {104, 104, 104},
4849  {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {105, 105, 105}, {106, 106, 106},
4850  {106, 106, 106}, {106, 106, 106}, {106, 106, 106}, {107, 107, 107}, {107, 107, 107},
4851  {107, 107, 107}, {107, 107, 107}, {108, 108, 108}, {108, 108, 108}, {108, 108, 108},
4852  {108, 108, 108}, {109, 109, 109}, {109, 109, 109}, {109, 109, 109}, {110, 110, 110},
4853  {110, 110, 110}, {110, 110, 110}, {110, 110, 110}, {111, 111, 111}, {111, 111, 111},
4854  {111, 111, 111}, {111, 111, 111}, {112, 112, 112}, {112, 112, 112}, {112, 112, 112},
4855  {112, 112, 112}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113},
4856  {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {115, 115, 115},
4857  {115, 115, 115}, {115, 115, 115}, {115, 115, 115}, {116, 116, 116}, {116, 116, 116},
4858  {116, 116, 116}, {116, 116, 116}, {117, 117, 117}, {117, 117, 117}, {117, 117, 117},
4859  {117, 117, 117}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118},
4860  {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {120, 120, 120},
4861  {120, 120, 120}, {120, 120, 120}, {120, 120, 120}, {121, 121, 121}, {121, 121, 121},
4862  {121, 121, 121}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122},
4863  {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {124, 124, 124},
4864  {124, 124, 124}, {124, 124, 124}, {124, 124, 124}, {125, 125, 125}, {125, 125, 125},
4865  {125, 125, 125}, {125, 125, 125}, {126, 126, 126}, {126, 126, 126}, {126, 126, 126},
4866  {126, 126, 126}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127},
4867  {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {129, 129, 129},
4868  {129, 129, 129}, {129, 129, 129}, {129, 129, 129}, {130, 130, 130}, {130, 130, 130},
4869  {130, 130, 130}, {130, 130, 130}, {131, 131, 131}, {131, 131, 131}, {131, 131, 131},
4870  {131, 131, 131}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132},
4871  {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {134, 134, 134},
4872  {134, 134, 134}, {134, 134, 134}, {135, 135, 135}, {135, 135, 135}, {135, 135, 135},
4873  {135, 135, 135}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136},
4874  {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {138, 138, 138},
4875  {138, 138, 138}, {138, 138, 138}, {138, 138, 138}, {139, 139, 139}, {139, 139, 139},
4876  {139, 139, 139}, {139, 139, 139}, {140, 140, 140}, {140, 140, 140}, {140, 140, 140},
4877  {140, 140, 140}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141},
4878  {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {143, 143, 143},
4879  {143, 143, 143}, {143, 143, 143}, {143, 143, 143}, {144, 144, 144}, {144, 144, 144},
4880  {144, 144, 144}, {144, 144, 144}, {145, 145, 145}, {145, 145, 145}, {145, 145, 145},
4881  {145, 145, 145}, {146, 146, 146}, {146, 146, 146}, {146, 146, 146}, {147, 147, 147},
4882  {147, 147, 147}, {147, 147, 147}, {147, 147, 147}, {148, 148, 148}, {148, 148, 148},
4883  {148, 148, 148}, {148, 148, 148}, {149, 149, 149}, {149, 149, 149}, {149, 149, 149},
4884  {149, 149, 149}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150}, {150, 150, 150},
4885  {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {151, 151, 151}, {152, 152, 152},
4886  {152, 152, 152}, {152, 152, 152}, {152, 152, 152}, {153, 153, 153}, {153, 153, 153},
4887  {153, 153, 153}, {153, 153, 153}, {154, 154, 154}, {154, 154, 154}, {154, 154, 154},
4888  {154, 154, 154}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155}, {155, 155, 155},
4889  {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {156, 156, 156}, {157, 157, 157},
4890  {157, 157, 157}, {157, 157, 157}, {157, 157, 157}, {158, 158, 158}, {158, 158, 158},
4891  {158, 158, 158}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159},
4892  {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {161, 161, 161},
4893  {161, 161, 161}, {161, 161, 161}, {161, 161, 161}, {162, 162, 162}, {162, 162, 162},
4894  {162, 162, 162}, {162, 162, 162}, {163, 163, 163}, {163, 163, 163}, {163, 163, 163},
4895  {163, 163, 163}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164},
4896  {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {166, 166, 166},
4897  {166, 166, 166}, {166, 166, 166}, {166, 166, 166}, {167, 167, 167}, {167, 167, 167},
4898  {167, 167, 167}, {167, 167, 167}, {168, 168, 168}, {168, 168, 168}, {168, 168, 168},
4899  {168, 168, 168}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169},
4900  {170, 170, 170}, {170, 170, 170}, {170, 170, 170}, {171, 171, 171}, {171, 171, 171},
4901  {171, 171, 171}, {171, 171, 171}, {172, 172, 172}, {172, 172, 172}, {172, 172, 172},
4902  {172, 172, 172}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173},
4903  {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {175, 175, 175},
4904  {175, 175, 175}, {175, 175, 175}, {175, 175, 175}, {176, 176, 176}, {176, 176, 176},
4905  {176, 176, 176}, {176, 176, 176}, {177, 177, 177}, {177, 177, 177}, {177, 177, 177},
4906  {177, 177, 177}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178},
4907  {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {180, 180, 180},
4908  {180, 180, 180}, {180, 180, 180}, {180, 180, 180}, {181, 181, 181}, {181, 181, 181},
4909  {181, 181, 181}, {181, 181, 181}, {182, 182, 182}, {182, 182, 182}, {182, 182, 182},
4910  {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {184, 184, 184},
4911  {184, 184, 184}, {184, 184, 184}, {184, 184, 184}, {185, 185, 185}, {185, 185, 185},
4912  {185, 185, 185}, {185, 185, 185}, {186, 186, 186}, {186, 186, 186}, {186, 186, 186},
4913  {186, 186, 186}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187},
4914  {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {189, 189, 189},
4915  {189, 189, 189}, {189, 189, 189}, {189, 189, 189}, {190, 190, 190}, {190, 190, 190},
4916  {190, 190, 190}, {190, 190, 190}, {191, 191, 191}, {191, 191, 191}, {191, 191, 191},
4917  {191, 191, 191}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192},
4918  {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {194, 194, 194},
4919  {194, 194, 194}, {194, 194, 194}, {195, 195, 195}, {195, 195, 195}, {195, 195, 195},
4920  {195, 195, 195}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196}, {196, 196, 196},
4921  {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {197, 197, 197}, {198, 198, 198},
4922  {198, 198, 198}, {198, 198, 198}, {198, 198, 198}, {199, 199, 199}, {199, 199, 199},
4923  {199, 199, 199}, {199, 199, 199}, {200, 200, 200}, {200, 200, 200}, {200, 200, 200},
4924  {200, 200, 200}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201}, {201, 201, 201},
4925  {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {202, 202, 202}, {203, 203, 203},
4926  {203, 203, 203}, {203, 203, 203}, {203, 203, 203}, {204, 204, 204}, {204, 204, 204},
4927  {204, 204, 204}, {204, 204, 204}, {205, 205, 205}, {205, 205, 205}, {205, 205, 205},
4928  {205, 205, 205}, {206, 206, 206}, {206, 206, 206}, {206, 206, 206}, {207, 207, 207},
4929  {207, 207, 207}, {207, 207, 207}, {207, 207, 207}, {208, 208, 208}, {208, 208, 208},
4930  {208, 208, 208}, {208, 208, 208}, {209, 209, 209}, {209, 209, 209}, {209, 209, 209},
4931  {209, 209, 209}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210},
4932  {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {212, 212, 212},
4933  {212, 212, 212}, {212, 212, 212}, {212, 212, 212}, {213, 213, 213}, {213, 213, 213},
4934  {213, 213, 213}, {213, 213, 213}, {214, 214, 214}, {214, 214, 214}, {214, 214, 214},
4935  {214, 214, 214}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215},
4936  {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {217, 217, 217},
4937  {217, 217, 217}, {217, 217, 217}, {217, 217, 217}, {218, 218, 218}, {218, 218, 218},
4938  {218, 218, 218}, {218, 218, 218}, {219, 219, 219}, {219, 219, 219}, {219, 219, 219},
4939  {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {221, 221, 221},
4940  {221, 221, 221}, {221, 221, 221}, {221, 221, 221}, {222, 222, 222}, {222, 222, 222},
4941  {222, 222, 222}, {222, 222, 222}, {223, 223, 223}, {223, 223, 223}, {223, 223, 223},
4942  {223, 223, 223}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224},
4943  {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {226, 226, 226},
4944  {226, 226, 226}, {226, 226, 226}, {226, 226, 226}, {227, 227, 227}, {227, 227, 227},
4945  {227, 227, 227}, {227, 227, 227}, {228, 228, 228}, {228, 228, 228}, {228, 228, 228},
4946  {228, 228, 228}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229},
4947  {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {231, 231, 231},
4948  {231, 231, 231}, {231, 231, 231}, {232, 232, 232}, {232, 232, 232}, {232, 232, 232},
4949  {232, 232, 232}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233},
4950  {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {235, 235, 235},
4951  {235, 235, 235}, {235, 235, 235}, {235, 235, 235}, {236, 236, 236}, {236, 236, 236},
4952  {236, 236, 236}, {236, 236, 236}, {237, 237, 237}, {237, 237, 237}, {237, 237, 237},
4953  {237, 237, 237}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238},
4954  {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {240, 240, 240},
4955  {240, 240, 240}, {240, 240, 240}, {240, 240, 240}, {241, 241, 241}, {241, 241, 241},
4956  {241, 241, 241}, {241, 241, 241}, {242, 242, 242}, {242, 242, 242}, {242, 242, 242},
4957  {242, 242, 242}, {243, 243, 243}, {243, 243, 243}, {243, 243, 243}, {244, 244, 244},
4958  {244, 244, 244}, {244, 244, 244}, {244, 244, 244}, {245, 245, 245}, {245, 245, 245},
4959  {245, 245, 245}, {245, 245, 245}, {246, 246, 246}, {246, 246, 246}, {246, 246, 246},
4960  {246, 246, 246}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247}, {247, 247, 247},
4961  {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {248, 248, 248}, {249, 249, 249},
4962  {249, 249, 249}, {249, 249, 249}, {249, 249, 249}, {250, 250, 250}, {250, 250, 250},
4963  {250, 250, 250}, {250, 250, 250}, {251, 251, 251}, {251, 251, 251}, {251, 251, 251},
4964  {251, 251, 251}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252}, {252, 252, 252},
4965  {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {253, 253, 253}, {254, 254, 254},
4966  {254, 254, 254}, {254, 254, 254}, {254, 254, 254}, {255, 255, 255}, {255, 255, 255}
4967 };
4968 
4969 #endif
unsigned char green_channel(const unsigned int x, const unsigned int y) const
unsigned char red_channel(const unsigned int x, const unsigned int y) const
bool operator!=(const rgb_t &c0, const rgb_t &c1)
void import_rgb(float *red, float *green, float *blue)
void import_rgb_clamped(double *red, double *green, double *blue)
void export_color_plane(const color_plane color, unsigned char *image)
const rgb_t hot_colormap[1000]
void ror_channel(const color_plane color, const unsigned int &ror)
rgb_t convert_wave_length_nm_to_rgb(const double wave_length_nm)
void line_segment(int x1, int y1, int x2, int y2)
response_image(const std::size_t &width, const std::size_t &height, const T null=T(0))
void export_rgb(double *red, double *green, double *blue) const
bool copy_from(const bitmap_image &source_image, const unsigned int &x_offset, const unsigned int &y_offset)
bitmap_image & image()
cartesian_canvas(const double x_length, const double y_length)
void pen_color(const unsigned char &red, const unsigned char &green, const unsigned char &blue)
bool region(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height, bitmap_image &dest_image)
void import_rgb(unsigned char *red, unsigned char *green, unsigned char *blue)
const rgb_t gray_colormap[1000]
void set_pixel(const unsigned int x, const unsigned int y, const unsigned char red, const unsigned char green, const unsigned char blue)
void import_rgb(double *red, double *green, double *blue)
const T * row(const std::size_t &row_index) const
void histogram_normalized(const color_plane color, double hist[256])
T * row(const std::size_t &row_index)
void export_rgb_normal(float *red, float *green, float *blue) const
void ellipse(int centerx, int centery, int a, int b)
void set_all_ith_bits_high(const unsigned int bitr_index)
unsigned int height() const
void export_rgb(float *red, float *green, float *blue) const
unsigned char red
void export_response_image(const color_plane color, double *response_image)
void pen_width(const unsigned int &width)
unsigned char green
void alpha_blend(const double &alpha, const bitmap_image &image)
bitmap_image(const unsigned int width, const unsigned int height)
void reverse_channels()
void vertical_flip()
void import_ycbcr(double *y, double *cb, double *cr)
unsigned int width() const
void blue_channel(const unsigned int x, const unsigned int y, const unsigned char value)
bool valid(const std::size_t &x, const std::size_t &y)
void pen_color(const RGB colour)
void hierarchical_psnr(bitmap_image &image1, bitmap_image &image2, const double threshold, const rgb_t colormap[])
void plot_pen_pixel(int x, int y)
void set_all_ith_bits_low(const unsigned int bitr_index)
void histogram(const color_plane color, double hist[256])
double psnr_region(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height, const bitmap_image &image1, const bitmap_image &image2)
void rgb_to_ycbcr(const unsigned int &length, double *red, double *green, double *blue, double *y, double *cb, double *cr)
void reflective_image(bitmap_image &image, const bool include_diagnols=false)
void plasma(bitmap_image &image, const double &x, const double &y, const double &width, const double &height, const double &c1, const double &c2, const double &c3, const double &c4, const double &roughness=3.0, const rgb_t colormap[]=0)
std::size_t hamming_distance(const rgb_t &c0, const rgb_t &c1)
const T & operator()(const std::size_t &x, const std::size_t &y) const
const rgb_t jet_colormap[1000]
void fill_circle(double cx, double cy, double radius)
void fill_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
void ellipse(double centerx, double centery, double a, double b)
void red_channel(const unsigned int x, const unsigned int y, const unsigned char value)
const rgb_t vga_colormap[1000]
image_drawer(bitmap_image &image)
const unsigned char * data() const
void export_color_plane(const color_plane color, bitmap_image &image)
double min_x() const
void export_gray_scale_response_image(double *response_image) const
unsigned char blue
void quadix(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
void ycbcr_to_rgb(const unsigned int &length, double *y, double *cb, double *cr, double *red, double *green, double *blue)
void triangle(double x1, double y1, double x2, double y2, double x3, double y3)
unsigned char * row(unsigned int row_index) const
void horizontal_flip()
const rgb_t palette_colormap[]
void mul_all(const T &v)
void pen_width(const unsigned int &width)
void invert_color_planes()
const rgb_t autumn_colormap[1000]
void import_rgb_normal(double *red, double *green, double *blue)
void subsample(bitmap_image &dest)
const rgb_t prism_colormap[1000]
void vertical_line_segment(int y1, int y2, int x)
unsigned int bytes_per_pixel() const
void generate_colours(const std::size_t &steps, const rgb_t c0, const rgb_t &c1, OutputIterator out)
double weighted_distance(const unsigned char r0, const unsigned char g0, const unsigned char b0, const unsigned char r1, const unsigned char g1, const unsigned char b1)
bool copy_from(const bitmap_image &image)
void checkered_pattern(const unsigned int x_width, const unsigned int y_width, const unsigned char value, const bitmap_image::color_plane color, bitmap_image &image)
bool operator==(const rgb_t &c0, const rgb_t &c1)
std::size_t height() const
void save_image(const std::string &file_name) const
void set_all_channels(const unsigned char &r_value, const unsigned char &g_value, const unsigned char &b_value)
void rectangle(double x1, double y1, double x2, double y2)
#define round(d)
double min_y() const
void fill_quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
bool set_region(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height, const color_plane color, const unsigned char &value)
void set_all_ith_channels(const unsigned int &channel, const unsigned char &value)
void export_rgb(unsigned char *red, unsigned char *green, unsigned char *blue) const
double max_x() const
const rgb_t copper_colormap[1000]
bool roi_from_center(const unsigned int &cx, const unsigned int &cy, const unsigned int &width, const unsigned int &height, bitmap_image &dest_image)
unsigned char blue_channel(const unsigned int x, const unsigned int y) const
bitmap_image(const std::string &filename)
void triangle(int x1, int y1, int x2, int y2, int x3, int y3)
void line_segment(double x1, double y1, double x2, double y2)
void set_all(const T &t)
T & operator()(const std::size_t &x, const std::size_t &y)
double find_nearest_wave_length(const rgb_t &c, const double increment=0.001)
void plot_pixel(int x, int y)
void hierarchical_psnr_r(const double &x, const double &y, const double &width, const double &height, const bitmap_image &image1, bitmap_image &image2, const double &threshold, const rgb_t colormap[])
void inc_all(const T &v)
void export_ycbcr(double *y, double *cb, double *cr)
bool set_region(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height, const unsigned char &red, const unsigned char &green, const unsigned char &blue)
void set_channel(const color_plane color, const unsigned char &value)
const rgb_t yarg_colormap[1000]
unsigned int pixel_count() const
void circle(int centerx, int centery, int radius)
std::size_t width() const
void add_to_color_plane(const color_plane color, const unsigned char &value)
void import_gray_scale_clamped(double *gray)
void sobel_operator(const bitmap_image &src_image, bitmap_image &dst_image, const double threshold=0.0)
bitmap_image & operator=(const bitmap_image &image)
rgb_t make_colour(const unsigned int &red, const unsigned int &green, const unsigned int &blue)
double max_y() const
void pen_color(const RGB colour)
void green_channel(const unsigned int x, const unsigned int y, const unsigned char value)
bitmap_image(const bitmap_image &image)
unsigned int offset(const color_plane color)
void horiztonal_line_segment(double x1, double x2, double y)
void import_rgb_normal(float *red, float *green, float *blue)
const bitmap_image & image() const
double psnr(const bitmap_image &image)
void get_pixel(const unsigned int x, const unsigned int y, RGB &colour)
palette_name
void plot_pixel(double x, double y)
void import_rgb_clamped(float *red, float *green, float *blue)
void set_widthheight(const double x_length, const double y_length)
void convert_to_grayscale()
void vertical_line_segment(double y1, double y2, double x)
double psnr(const unsigned int &x, const unsigned int &y, const bitmap_image &image)
void upsample(bitmap_image &dest)
const rgb_t hsv_colormap[1000]
std::size_t convert_rsp_to_image(const ResponseImage &resp_image, const Palette &palette, bitmap_image &image)
unsigned char * data()
bool set_region(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height, const unsigned char &value)
void rectangle(int x1, int y1, int x2, int y2)
void circle(double centerx, double centery, double radius)
rgb_t find_nearest_color(const rgb_t &c, const Iterator begin, const Iterator end)
void set_pixel(const unsigned int x, const unsigned int y, const RGB &colour)
void plot_pen_pixel(double x, double y)
void horiztonal_line_segment(int x1, int x2, int y)
void pen_color(const unsigned char &red, const unsigned char &green, const unsigned char &blue)
void setwidth_height(const unsigned int width, const unsigned int height, const bool clear=false)
void quadix(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
void clear(const unsigned char v=0x00)
void set_all_channels(const unsigned char &value)
void get_pixel(const unsigned int x, const unsigned int y, unsigned char &red, unsigned char &green, unsigned char &blue)
void export_rgb_normal(double *red, double *green, double *blue) const
void fill_rectangle(double x1, double y1, double x2, double y2)