00001 #include "FCam/Histogram.h"
00002 #include <stdio.h>
00003 #include <cmath>
00004
00005 namespace FCam {
00006
00007 void Histogram::debug(const char *name) const {
00008 printf("\tHistogram %s at %px with buckets %d, channels %d\n"
00009 "\t valid: %s\n"
00010 "\t region: start at (%d, %d), size (%d,%d)\n",
00011 name, this, buckets(), channels(), valid() ? "yes" : "NO",
00012 region().x, region().y, region().width, region().height);
00013 if (valid()) {
00014 unsigned maxCount = 1;
00015 for (unsigned int i=0; i < buckets(); i++) {
00016 unsigned count = (*this)(i);
00017 if (count > maxCount) { maxCount = count; }
00018 }
00019
00020 printf("\t 0%18c%d\n",' ',maxCount);
00021 printf("\t |%18c|\n",' ');
00022 float tickSize = maxCount / 20;
00023 for (unsigned int i=0; i < buckets(); i++) {
00024 unsigned count = (*this)(i);
00025 count = static_cast<unsigned>(std::floor((count / tickSize) + 0.5f));
00026 printf("\t%03d ", i);
00027 for (unsigned int c = 0; c < count; c++) {
00028 printf("#");
00029 }
00030 printf("\n");
00031 }
00032 }
00033 }
00034
00035 }