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