HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TIL_Histogram.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TIL_Histogram.h (Tile Image Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 #ifndef TIL_HISTOGRAM_H
12 #define TIL_HISTOGRAM_H
13 
14 #include "TIL_API.h"
15 #include <UT/UT_String.h>
16 #include <UT/UT_Vector2.h>
17 #include "TIL_Defines.h"
18 
19 class TIL_Raster;
20 
22 {
23 public:
24 
25  TIL_Histogram();
26  virtual ~TIL_Histogram();
27 
28  // setup.
29  void setRaster(const TIL_Raster *generate_from,
30  int comp = -1);
31  void setMaxBuckets(int max);
32 
33  void generate(TIL_HistogramType type,
34  bool usehue = true,
35  bool primary = true,
36  bool uvmode = false,
37  float uvpos = 0.0f);
38 
39  // query the generated histogram.
40  int isHistogram() const;
41  int isGraph() const;
42 
43  const char *getName() const { return myGraphName; }
44  void getXAxis(UT_String &label, int &limited_range,
45  float &start, float &end,
46  int &floatval, int &usesbwpoints,
47  int &usehue) const;
48  void getYAxis(UT_String &label, int &limited_range,
49  float &start, float &end,
50  int &floatval, int &usesbwpoints,
51  int &usehue) const;
52 
53  void getBWPoints(float &black, float &white) const;
54 
55  unsigned int getHistogramSize(bool rebinned = true) const;
56  const unsigned int *getHistogram(bool rebinned = true) const;
57  float getCutoffPoint() const;
58 
59  bool getUVPos(float &pos, int &dir) const;
60 
61  void getGraphDimensions(int &width, int &height) const;
62  const TIL_Raster *getGraph() const;
63  unsigned int getGraphCount(int x, int y) const;
64 
65  // if hue is undefined, it will be set to -1 (normally it is [0, 360) ).
66  static void RGBtoHSV(float r, float g, float b,
67  float &h, float &s, float &v);
68  static void HSVtoRGB(float h, float s, float v,
69  float &r, float &g, float &b);
70 
71  void rebin(const float histwidth);
72  void getRangeForBar(int bar, float& start, float& end);
73 
74 private:
75  void reset();
76  void scanRange(float &min, float &max);
77  void scanHistogram(float &min, float &max);
78  static void scanHistogram( unsigned int const* histogram, int num_buckets,
79  float &start, float &end, float& cutoff_point
80  );
81 
82  // both these methods return a map from size to max buckets if the size
83  // is too big. Otherwise (the size is less than the max) returns null.
84  // You must delete [] this map! myHistogram or myGraph will point the
85  // alloc'd mem. size = -1 allocs the max amount of mem for the hist/graph.
86  unsigned int *allocHistogram(int size = -1);
87  unsigned int *allocGraph(int width, int depth = -1);
88 
89  void convertGraphToRaster(int use_huex, int use_huey,
90  int cindex);
91 
92  void generateRawHist();
93  void generateHSVHist(int which);
94 
95  void generateRaw(int uv, bool uvmode, float uvpos);
96  void generateHSV(int which, int uv,
97  bool uvmode, float uvpos);
98  void generateHueGraph(int which);
99 
100 private:
101  const TIL_Raster * myRaster;
102  int myComponent;
103  int myGraphType;
104 
105  TIL_HistogramType myType;
106  const char *myGraphName;
107  const char *myXLabel;
108  const char *myYLabel;
109  float myXStart, myXEnd;
110  float myYStart, myYEnd;
111  int myXFloat, myYFloat;
112  int myXHue, myYHue;
113  int myXLimited, myYLimited;
114  int myWhitePointAxis;
115  bool myUVMode;
116  float myUVPos;
117 
118  // for histograms.
119  int myMaxBuckets;
120  int myNumBuckets;
121  unsigned int *myHistogram;
122  float myCutoffPoint;
123 
124  // for dynamic rebinning of histograms
125  unsigned int* myRebinnedHistogram;
126  unsigned int* myBinRangeTable;
127  int myAllocatedBins;
128  int myNumBins;
129  float myRebinnedCutoffPoint;
130  bool myHasRebinnedHistogram;
131 
132  // for graphs.
133  unsigned int myGraphWidth;
134  unsigned int myGraphHeight;
135  unsigned char *myGraph;
136  TIL_Raster *myDisplayGraph;
137 };
138 
139 #endif
const char * getName() const
Definition: TIL_Histogram.h:43
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
GA_API const UT_StringHolder uv
const GLdouble * v
Definition: glcorearb.h:836
GLuint start
Definition: glcorearb.h:474
GLboolean GLboolean g
Definition: glcorearb.h:1221
png_colorp int int png_uint_16p histogram
Definition: png.h:1797
GLint y
Definition: glcorearb.h:102
GLsizeiptr size
Definition: glcorearb.h:663
GLint GLsizei width
Definition: glcorearb.h:102
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
GLfloat f
Definition: glcorearb.h:1925
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:475
GLuint GLuint end
Definition: glcorearb.h:474
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
GLint GLsizei GLsizei height
Definition: glcorearb.h:102
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
TIL_HistogramType
Definition: TIL_Defines.h:110
GLint GLenum GLint x
Definition: glcorearb.h:408
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLboolean r
Definition: glcorearb.h:1221
#define TIL_API
Definition: TIL_API.h:10