HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_RasterFilter.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: IMG_Filter.h ( IMG Library, C++)
7  *
8  * COMMENTS: Code to apply a simple 2D symmetric separable filter to an
9  * image. This code allows for re-sizing of the image as well as
10  * filtering to the same resolution.
11  */
12 
13 #ifndef __IMG_Filter__
14 #define __IMG_Filter__
15 
16 #include "IMG_API.h"
17 #include <UT/UT_Filter.h>
18 #include "IMG_FileTypes.h"
19 
20 // Private to this class
21 class img_FilterStorage;
22 
23 
25 {
26 public:
27  typedef exint (*fetchFunc)(void *tag, void *buffer, exint scanline);
28 
30  exint inpXres, exint inpYres,
31  exint outXres, exint outYres,
32  fetchFunc inpFetch,
33 
34  UT_FilterType xfilter = UT_FILTER_BOX,
35  float xwidth = 1,
36 
37  UT_FilterType yfilter = UT_FILTER_BOX,
38  float ywidth = 1,
39 
40  IMG_DataType srcType = IMG_UCHAR,
41  IMG_DataType destType = IMG_UCHAR,
42 
43  // We do not do color model conversions in this code
44  IMG_ColorModel colorModel = IMG_RGBA);
45 
47  exint inpXres, exint inpYres,
48  exint outXres, exint outYres,
49  fetchFunc inpFetch,
50 
51  UT_Filter * xfilter,
52  float xwidth,
53 
54  UT_Filter * yfilter,
55  float ywidth,
56 
57  IMG_DataType srcType = IMG_UCHAR,
58  IMG_DataType destType = IMG_UCHAR,
59 
60  // We do not do color model conversions in this code
61  IMG_ColorModel colorModel = IMG_RGBA);
62 
63 
65 
66  void restartFilter();
67  exint nextScanline(exint y, void *buf, void *tag);
68 
69 
70  // This is the constructor for fast approximations of Box, Cone and Gauss
71  // filters. You must use fastApproxBlur() for this version instead of
72  // nextScanline(). restartFilter() is not needed before reusing the filter.
73  // - only single channel data is supported
74  // - different X/Y filter types are not supported (though sizes are)
75  // - data conversion is not supported
76  IMG_RasterFilter( exint xres, exint yres,
77  fetchFunc inpFetch,
79  float xwidth = 1.0f,
80  float ywidth = 1.0f,
82 
83  static void getApproxBlurBound(UT_FilterType type,
84  float xsize,float ysize,
85  exint ix1,exint iy1, exint ix2, exint iy2,
86  exint &x1,exint &y1, exint &x2, exint &y2);
87 
88  // this method does a fast gaussian filter by using 4 successive box
89  // filters (or a cone filter with 2, and an exact box filter). This
90  // is most optimal for larger filter sizes. Small filter sizes have a
91  // considerably more error (<10). 'buf' is a pointer to the entire image
92  // (xres x yres, Format = type, from the constructor)
93  int fastApproxBlur(void *buf, void *tag);
94 
95  // These only apply to the CELLBE version of fast approx blur. They have
96  // no effect on other platforms.
97  bool isRunning();
98  void close();
99 
100 private:
101  exint myInXres, myInYres;
102  exint myOutXres, myOutYres;
103  fetchFunc myFetch;
104 
105  exint myYWindow; // Size of filter window in Y.
106  float myYRadius; // Filter radius as a float
107  float myXScale, myYScale;
108 
109  IMG_DataType myInType;
110  IMG_DataType myOutType;
111  exint myWPP; // Channels per pixel (words)
112 
113  UT_Filter *myYFilter;
114  UT_FilterWindow *myXWeight;
115  UT_FilterWindow myYWeight;
116 
117  void *myInputBuffer;
118  float *myFinal;
119  float *myLoader;
120  float **myActive;
121  exint *myLineBuf;
122 
123  // Extra stuff for the Fast Approximate blur.
124  void filterVerticalFastApprox(exint x, float *tmp1, float *tmp2);
125 
126  bool myFastApprox;
127  int myNumPasses;
128 
129  exint myXRadius;
130  float myXRadiusWeight;
131  float myXArea;
132  exint myXOffset;
133 
134  exint myYIntRadius;
135  float myYRadiusWeight;
136  float myYArea;
137  exint myYOffset;
138 };
139 
140 #endif
GLuint GLfloat GLfloat GLfloat x1
Definition: glew.h:12681
int64 exint
Definition: SYS_Types.h:125
void close() override
UT_FilterType
Definition: UT_FilterType.h:16
#define IMG_API
Definition: IMG_API.h:10
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
GLclampf f
Definition: glew.h:3499
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
GLuint buffer
Definition: glew.h:1680
IMG_DataType
Definition: IMG_FileTypes.h:17
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
GLuint GLfloat GLfloat GLfloat GLfloat y1
Definition: glew.h:12681
IMG_ColorModel
Definition: IMG_FileTypes.h:53
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580