# HG changeset patch # User Eleni Maria Stea # Date 1408347851 -10800 # Node ID eb87d4a12bd39f029392866a1bdadaa18d8285da # Parent 3e4eb9a0d99999640ece00a17b74e55c10e158d9 histogram diff -r 3e4eb9a0d999 -r eb87d4a12bd3 src/main.cc --- a/src/main.cc Sun Aug 17 02:25:01 2014 +0300 +++ b/src/main.cc Mon Aug 18 10:44:11 2014 +0300 @@ -468,6 +468,23 @@ high = thres; } + + //drawing the histogram + float hmax = 1 / (float)vol->max_histogram_value; + + glBegin(GL_QUADS); + for (int i=0; ihistogram[i + 1], 0); + glVertex3f(x0, hmax * vol->histogram[i], 0); + } + glEnd(); + //drawing the transfer function curve glLineWidth(3); diff -r 3e4eb9a0d999 -r eb87d4a12bd3 src/volume.cc --- a/src/volume.cc Sun Aug 17 02:25:01 2014 +0300 +++ b/src/volume.cc Mon Aug 18 10:44:11 2014 +0300 @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -24,6 +25,9 @@ x_rot = 0; vol_tex_valid = false; + memset(histogram, 0, HIST_SIZE * sizeof(int)); + max_histogram_value = 0; + glGenTextures(1, &vol_tex); } @@ -55,6 +59,31 @@ } } +void Volume::create_histogram() +{ + if (slices.empty()) + return; + + for (size_t i=0; i #include "image.h" +#define HIST_SIZE 256 + class Mesh; class Volume { @@ -21,6 +23,10 @@ void create_vol_tex() const; public: + int histogram[HIST_SIZE]; + int max_histogram_value; + +public: Volume(); ~Volume(); @@ -43,6 +49,7 @@ void create_mesh(Mesh *mesh, float tmin, float tmax, int xres, int yres, int zres); + void create_histogram(); void draw() const; };