41 s.write((
const char*) &
value,
sizeof(value));
48 s.read((
char*) &
value,
sizeof(value));
61 for (
int i=0; i<8; i++) {
77 return Color((uint8_t) mr, (uint8_t) mg, (uint8_t) mb);
80 return Color(255, 255, 255);
118 for (
unsigned int i=0;i<8;i++) {
137 for (
unsigned int i = 1; i<8; i++) {
154 n->
setColor((prev_color.
r + r)/2, (prev_color.
g + g)/2, (prev_color.
b + b)/2);
172 uint8_t new_r = (uint8_t) ((
double) prev_color.
r * node_prob
173 + (double) r * (0.99-node_prob));
174 uint8_t new_g = (uint8_t) ((
double) prev_color.
g * node_prob
175 + (double) g * (0.99-node_prob));
176 uint8_t new_b = (uint8_t) ((
double) prev_color.
b * node_prob
177 + (double) b * (0.99-node_prob));
197 for (
unsigned int i=0; i<8; i++) {
211 fprintf(stderr,
"The color histogram uses gnuplot, this is not supported under windows.\n");
214 std::vector<int> histogram_r (256,0);
215 std::vector<int> histogram_g (256,0);
216 std::vector<int> histogram_b (256,0);
217 for(ColorOcTree::tree_iterator it = this->
begin_tree(),
226 FILE *gui = popen(
"gnuplot ",
"w");
227 fprintf(gui,
"set term postscript eps enhanced color\n");
228 fprintf(gui,
"set output \"%s\"\n", filename.c_str());
229 fprintf(gui,
"plot [-1:256] ");
230 fprintf(gui,
"'-' w filledcurve lt 1 lc 1 tit \"r\",");
231 fprintf(gui,
"'-' w filledcurve lt 1 lc 2 tit \"g\",");
232 fprintf(gui,
"'-' w filledcurve lt 1 lc 3 tit \"b\",");
233 fprintf(gui,
"'-' w l lt 1 lc 1 tit \"\",");
234 fprintf(gui,
"'-' w l lt 1 lc 2 tit \"\",");
235 fprintf(gui,
"'-' w l lt 1 lc 3 tit \"\"\n");
237 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_r[i]);
238 fprintf(gui,
"0 0\n"); fprintf(gui,
"e\n");
239 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_g[i]);
240 fprintf(gui,
"0 0\n"); fprintf(gui,
"e\n");
241 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_b[i]);
242 fprintf(gui,
"0 0\n"); fprintf(gui,
"e\n");
243 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_r[i]);
245 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_g[i]);
247 for (
int i=0; i<256; ++i) fprintf(gui,
"%d %d\n", i, histogram_b[i]);
254 return out <<
'(' << (
unsigned int)c.
r <<
' ' << (
unsigned int)c.
g <<
' ' << (
unsigned int)c.
b <<
')';
tree_iterator begin_tree(unsigned char maxDepth=0) const
const tree_iterator end_tree() const
const iterator end() const
float value
stored data (payload)
ColorOcTreeNode * integrateNodeColor(const OcTreeKey &key, uint8_t r, uint8_t g, uint8_t b)
const unsigned int tree_depth
Maximum tree depth is fixed to 16 currently.
void writeColorHistogram(std::string filename)
void updateInnerOccupancyRecurs(ColorOcTreeNode *node, unsigned int depth)
double getOccupancy() const
void updateColorChildren()
void deleteNodeChild(ColorOcTreeNode *node, unsigned int childIdx)
Deletes the i-th child of the node.
ColorOcTreeNode * getNodeChild(ColorOcTreeNode *node, unsigned int childIdx) const
ColorOcTreeNode * setNodeColor(const OcTreeKey &key, uint8_t r, uint8_t g, uint8_t b)
void updateOccupancyChildren()
update this node's occupancy according to its children's maximum occupancy
std::ostream & operator<<(std::ostream &out, ColorOcTreeNode::Color const &c)
user friendly output in format (r g b)
ColorOcTreeNode * search(double x, double y, double z, unsigned int depth=0) const
AbstractOcTreeNode ** children
ColorOcTreeNode * averageNodeColor(const OcTreeKey &key, uint8_t r, uint8_t g, uint8_t b)
ColorOcTreeNode::Color getAverageChildColor() const
virtual bool pruneNode(ColorOcTreeNode *node)
virtual bool isNodeCollapsible(const ColorOcTreeNode *node) const
void updateInnerOccupancy()
ColorOcTree(double resolution)
Default constructor, sets resolution of leafs.
ColorOcTreeNode * root
Pointer to the root NODE, NULL for empty tree.
std::ostream & writeData(std::ostream &s) const
std::istream & readData(std::istream &s)
static StaticMemberInitializer colorOcTreeMemberInit
static member to ensure static initialization (only once)
bool isNodeOccupied(const OcTreeNode *occupancyNode) const
queries whether a node is occupied according to the tree's parameter for "occupancy" ...
bool nodeChildExists(const ColorOcTreeNode *node, unsigned int childIdx) const
bool nodeHasChildren(const ColorOcTreeNode *node) const
void copyData(const ColorOcTreeNode &from)