Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

Histogram.h

00001 /* Copyright (c) 2001 S.E. Grigorescu */
00002 
00003 #ifndef HISTOGRAM_H
00004 #define HISTOGRAM_H
00005 
00006 #include "config.h"
00007 #include "Image.h"
00008 #include "sys-defines.h"
00009 #ifndef EXTERN_H
00010    #include "extern.h"
00011 #endif
00012 #ifdef HAVE_LIBPLOTTER
00013    #include "graph.h"
00014 #endif
00015 
00020 template< class T > class Histogram 
00021 {
00022   void compute_histogram();    
00028   double min_x;
00032   double max_x;
00036   int bins; 
00039   double *hist;
00042   Image< T > img;
00046 #ifdef HAVE_LIBPLOTTER
00047   bool add_point(double y, double x1, double x2, int pos, Point *p);
00054   void set_point_attr(Point &point);
00062   bool x_range_spec;
00063   bool y_range_spec;
00064   Grapher *grapher_disp;
00065   Grapher *grapher_wrt;
00066   int Width, Height;
00067   const char *bg;
00068   const char *top_label, *x_label, *y_label;
00069   const char *title_font_name;
00070   const char *xy_font_name;
00071   double title_font_size, xy_font_size;
00072   double final_min_x, final_max_x;
00073   double final_min_y, final_max_y; 
00074   double final_spacing_x, final_spacing_y;  
00075   int final_log_axis;
00076   bool final_transpose_axes;
00077   double fill_fraction;
00078 #endif
00079 
00080  public:
00083   Histogram(Image< T > &input, int no_bins = 100);
00084 
00087   Histogram(Image< T > &input, int no_bins, T min, T max);
00088 
00090   ~Histogram();
00091 
00092   double* getHistogram() {return hist;}
00098   void equalize(Image< T > &output);
00105 #ifdef HAVE_LIBPLOTTER
00106   void setDimensions(int w = 600, int h = 600) {
00107     Width = w;
00108     Height = h;
00109   }
00117   void setBgColor(const char *color) {bg = color; }
00125   void setTitle(const char *title) { top_label = title; }
00133   void setTitleFontName(const char *title_font) { title_font_name = title_font; }
00141   void setTitleFontSize(double title_size) { title_font_size = title_size; }
00149   void setXLabel(const char *lb) { x_label = lb; }
00157   void setYLabel(const char *lb) { y_label = lb; }
00165   void setXYFontName(const char *lb) { xy_font_name = lb; }
00173   void setXYFontSize(double lb_size) { xy_font_size = lb_size; }
00181   void setXRange(T x_min, T x_max) {
00182     final_min_x = x_min;
00183     final_max_x = x_max;
00184     x_range_spec = true;
00185   }
00193   void resetXRange() { x_range_spec = false; }
00201   void setYRange(T y_min, T y_max) {
00202     final_min_y = y_min;
00203     final_max_y = y_max;
00204     y_range_spec = true;
00205   }
00214   void resetYRange() { y_range_spec = false; }
00222   void setXTicks(double xt) { final_spacing_x = xt; }
00230   void setYTicks(double yt) { final_spacing_y = yt; }
00238   void setLogMode(bool lg = true) { final_log_axis = (int)lg; }
00246   void transposeAxes(bool tr = true) { final_transpose_axes = tr; }
00254   void setFillIntensity(double fill) { fill_fraction = fill; }
00262   void showHistogram();
00271   void writeHistogram(char *type, char *file_name);
00279   void closeWindow();
00287 #endif
00288 
00289 };
00290 
00292 #endif 
00293