HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "TIL_Defines.h"
16 #include <UT/UT_NonCopyable.h>
17 #include <UT/UT_String.h>
18 #include <UT/UT_Vector2.h>
19 
20 class TIL_Raster;
21 
23 {
24 public:
25 
26  TIL_Histogram();
27  virtual ~TIL_Histogram();
28 
30 
31  // setup.
32  void setRaster(const TIL_Raster *generate_from,
33  int comp = -1);
34  void setMaxBuckets(int max);
35 
36  void generate(TIL_HistogramType type,
37  bool usehue = true,
38  bool primary = true,
39  bool uvmode = false,
40  float uvpos = 0.0f);
41 
42  // query the generated histogram.
43  int isHistogram() const;
44  int isGraph() const;
45 
46  const char *getName() const { return myGraphName; }
47  void getXAxis(UT_String &label, int &limited_range,
48  float &start, float &end,
49  int &floatval, int &usesbwpoints,
50  int &usehue) const;
51  void getYAxis(UT_String &label, int &limited_range,
52  float &start, float &end,
53  int &floatval, int &usesbwpoints,
54  int &usehue) const;
55 
56  void getBWPoints(float &black, float &white) const;
57 
58  unsigned int getHistogramSize(bool rebinned = true) const;
59  const unsigned int *getHistogram(bool rebinned = true) const;
60  float getCutoffPoint() const;
61 
62  bool getUVPos(float &pos, int &dir) const;
63 
64  void getGraphDimensions(int &width, int &height) const;
65  const TIL_Raster *getGraph() const;
66  unsigned int getGraphCount(int x, int y) const;
67 
68  // if hue is undefined, it will be set to -1 (normally it is [0, 360) ).
69  static void RGBtoHSV(float r, float g, float b,
70  float &h, float &s, float &v);
71  static void HSVtoRGB(float h, float s, float v,
72  float &r, float &g, float &b);
73 
74  void rebin(const float histwidth);
75  void getRangeForBar(int bar, float& start, float& end);
76 
77 private:
78  void reset();
79  void scanRange(float &min, float &max);
80  void scanHistogram(float &min, float &max);
81  static void scanHistogram( unsigned int const* histogram, int num_buckets,
82  float &start, float &end, float& cutoff_point
83  );
84 
85  // both these methods return a map from size to max buckets if the size
86  // is too big. Otherwise (the size is less than the max) returns null.
87  // You must delete [] this map! myHistogram or myGraph will point the
88  // alloc'd mem. size = -1 allocs the max amount of mem for the hist/graph.
89  unsigned int *allocHistogram(int size = -1);
90  unsigned int *allocGraph(int width, int depth = -1);
91 
92  void convertGraphToRaster(int use_huex, int use_huey,
93  int cindex);
94 
95  void generateRawHist();
96  void generateHSVHist(int which);
97 
98  void generateRaw(int uv, bool uvmode, float uvpos);
99  void generateHSV(int which, int uv,
100  bool uvmode, float uvpos);
101  void generateHueGraph(int which);
102 
103 private:
104  const TIL_Raster * myRaster;
105  int myComponent;
106  int myGraphType;
107 
108  TIL_HistogramType myType;
109  const char *myGraphName;
110  const char *myXLabel;
111  const char *myYLabel;
112  float myXStart, myXEnd;
113  float myYStart, myYEnd;
114  int myXFloat, myYFloat;
115  int myXHue, myYHue;
116  int myXLimited, myYLimited;
117  int myWhitePointAxis;
118  bool myUVMode;
119  float myUVPos;
120 
121  // for histograms.
122  int myMaxBuckets;
123  int myNumBuckets;
124  unsigned int *myHistogram;
125  float myCutoffPoint;
126 
127  // for dynamic rebinning of histograms
128  unsigned int* myRebinnedHistogram;
129  unsigned int* myBinRangeTable;
130  int myAllocatedBins;
131  int myNumBins;
132  float myRebinnedCutoffPoint;
133  bool myHasRebinnedHistogram;
134 
135  // for graphs.
136  unsigned int myGraphWidth;
137  unsigned int myGraphHeight;
138  unsigned char *myGraph;
139  TIL_Raster *myDisplayGraph;
140 };
141 
142 #endif
OIIO_API std::vector< imagesize_t > histogram(const ImageBuf &src, int channel=0, int bins=256, float min=0.0f, float max=1.0f, bool ignore_empty=false, ROI roi={}, int nthreads=0)
const char * getName() const
Definition: TIL_Histogram.h:46
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
GA_API const UT_StringHolder uv
const GLdouble * v
Definition: glcorearb.h:837
GLuint start
Definition: glcorearb.h:475
GLboolean GLboolean g
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLint y
Definition: glcorearb.h:103
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
GLfloat f
Definition: glcorearb.h:1926
GLboolean reset
Definition: glad.h:5138
GLuint GLuint end
Definition: glcorearb.h:475
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:476
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
TIL_HistogramType
Definition: TIL_Defines.h:121
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLint GLsizei width
Definition: glcorearb.h:103
GLboolean r
Definition: glcorearb.h:1222
type
Definition: core.h:1059
#define TIL_API
Definition: TIL_API.h:10