1 /*******************************************************************************
2 * Copyright 2016-2019 Intel Corporation.
3 *
4 * This software and the related documents are Intel copyrighted  materials,  and
5 * your use of  them is  governed by the  express license  under which  they were
6 * provided to you (License).  Unless the License provides otherwise, you may not
7 * use, modify, copy, publish, distribute,  disclose or transmit this software or
8 * the related documents without Intel's prior written permission.
9 *
10 * This software and the related documents  are provided as  is,  with no express
11 * or implied  warranties,  other  than those  that are  expressly stated  in the
12 * License.
13 *******************************************************************************/
14 
15 #if !defined( __IPP_IW_IMAGE_FILTER__ )
16 #define __IPP_IW_IMAGE_FILTER__
17 
18 #include "iw/iw_image.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 // Derivative operator type enumerator
25 typedef enum _IwiDerivativeType
26 {
27     iwiDerivHorFirst = 0,  // Horizontal first derivative
28     iwiDerivHorSecond,     // Horizontal second derivative
29     iwiDerivVerFirst,      // Vertical first derivative
30     iwiDerivVerSecond,     // Vertical second derivative
31     iwiDerivNVerFirst      // Negative vertical first derivative
32 } IwiDerivativeType;
33 
34 /* /////////////////////////////////////////////////////////////////////////////
35 //                   iwiFilter
36 ///////////////////////////////////////////////////////////////////////////// */
37 
38 // Auxiliary parameters structure
39 typedef struct _IwiFilterParams
40 {
41     double              divisor;    // The value by which the computed result is divided for 16s kernel type.
42                                     // If divisor is 0 and the sum of the kernel elements is not 0 then result will be normalized by the sum of the kernel elements
43                                     // Only integer values are supported
44     int                 offset;     // An offset which will be added to the final signed result before converting it to unsigned for 8u and 16u
45     IppRoundMode        roundMode;  // Rounding mode
46     IppHintAlgorithm    algoMode;   // Accuracy mode
47 } IwiFilterParams;
48 
49 // Sets auxiliary parameters to default values
iwiFilter_SetDefaultParams(IwiFilterParams * pParams)50 static IW_INLINE void iwiFilter_SetDefaultParams(
51     IwiFilterParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
52 )
53 {
54     if(pParams)
55     {
56         pParams->divisor    = 0;
57         pParams->offset     = 0;
58         pParams->roundMode  = ippRndNear;
59         pParams->algoMode   = ippAlgHintNone;
60     }
61 }
62 
63 // Performs filtration of an image with an arbitrary kernel
64 // Features support:
65 //      Data types:              k16s(8u,16u,16s), k32f(8u,16u,16s,32f)
66 //      Channel types:           C1,C3,C4
67 //      Inplace mode:            no
68 //      64-bit sizes:            no
69 //      Internal threading:      no
70 //      Manual tiling:           yes
71 //      IwiTile simple tiling:   yes
72 //      IwiTile pipeline tiling: yes
73 // Returns:
74 //      ippStsBorderErr                     border value is illegal
75 //      ippStsDataTypeErr                   data type is illegal
76 //      ippStsNumChannelsErr                channels value is illegal
77 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
78 //      ippStsNotSupportedModeErr           selected function mode is not supported
79 //      ippStsNoMemErr                      failed to allocate memory
80 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
81 //      ippStsNullPtrErr                    unexpected NULL pointer
82 //      ippStsNoErr                         no errors
83 IW_DECL(IppStatus) iwiFilter(
84     const IwiImage         *pSrcImage,      // [in]     Pointer to the source image
85     IwiImage               *pDstImage,      // [in,out] Pointer to the destination image
86     const IwiImage         *pKernel,        // [in]     Pointer to the filter kernel image. Kernel must be continuous, [16s,32f], [C1]
87     const IwiFilterParams  *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
88     IwiBorderType           border,         // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
89     const Ipp64f           *pBorderVal,     // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
90     const IwiTile          *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
91 );
92 
93 /* /////////////////////////////////////////////////////////////////////////////
94 //                   iwiFilterBox
95 ///////////////////////////////////////////////////////////////////////////// */
96 
97 // Auxiliary parameters structure
98 typedef struct _IwiFilterBoxParams
99 {
100     IwiChDescriptor chDesc;     // Special channels processing mode
101 } IwiFilterBoxParams;
102 
103 // Sets auxiliary parameters to default values
iwiFilterBox_SetDefaultParams(IwiFilterBoxParams * pParams)104 static IW_INLINE void iwiFilterBox_SetDefaultParams(
105     IwiFilterBoxParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
106 )
107 {
108     if(pParams)
109     {
110         pParams->chDesc = iwiChDesc_None;
111     }
112 }
113 
114 // Applies box filter to the image
115 // Features support:
116 //      Data types:              8u,16u,16s,32f
117 //      Channel types:           C1,C3,C4,C4M1110
118 //      Inplace mode:            no
119 //      64-bit sizes:            no
120 //      Internal threading:      no
121 //      Manual tiling:           yes
122 //      IwiTile simple tiling:   yes
123 //      IwiTile pipeline tiling: yes
124 // Returns:
125 //      ippStsBorderErr                     border value is illegal
126 //      ippStsDataTypeErr                   data type is illegal
127 //      ippStsNumChannelsErr                channels value is illegal
128 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
129 //      ippStsNotSupportedModeErr           selected function mode is not supported
130 //      ippStsNoMemErr                      failed to allocate memory
131 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
132 //      ippStsNullPtrErr                    unexpected NULL pointer
133 //      ippStsNoErr                         no errors
134 IW_DECL(IppStatus) iwiFilterBox(
135     const IwiImage             *pSrcImage,      // [in]     Pointer to the source image
136     IwiImage                   *pDstImage,      // [in,out] Pointer to the destination image
137     IwiSize                     kernelSize,     // [in]     Size of the filter kernel
138     const IwiFilterBoxParams   *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
139     IwiBorderType               border,         // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
140     const Ipp64f               *pBorderVal,     // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
141     const IwiTile              *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
142 );
143 
144 /**/////////////////////////////////////////////////////////////////////////////
145 //                   iwiFilterSobel
146 ///////////////////////////////////////////////////////////////////////////// */
147 //
148 //                               -1  0  1
149 //              SobelVert (3x3)  -2  0  2
150 //                               -1  0  1
151 //
152 //
153 //                                1  2  1
154 //              SobelHoriz (3x3)  0  0  0
155 //                               -1 -2 -1
156 //
157 //
158 //                                       1 -2  1
159 //              SobelVertSecond (3x3)    2 -4  2
160 //                                       1 -2  1
161 //
162 //
163 //                                       1  2  1
164 //              SobelHorizSecond (3x3)  -2 -4 -2
165 //                                       1  2  1
166 //
167 //                               -1  -2   0   2   1
168 //                               -4  -8   0   8   4
169 //              SobelVert (5x5)  -6 -12   0  12   6
170 //                               -4  -8   0   8   4
171 //                               -1  -2   0   2   1
172 //
173 //                                1   4   6   4   1
174 //                                2   8  12   8   2
175 //              SobelHoriz (5x5)  0   0   0   0   0
176 //                               -2  -8 -12  -8  -4
177 //                               -1  -4  -6  -4  -1
178 //
179 //                                       1   0  -2   0   1
180 //                                       4   0  -8   0   4
181 //              SobelVertSecond (5x5)    6   0 -12   0   6
182 //                                       4   0  -8   0   4
183 //                                       1   0  -2   0   1
184 //
185 //                                       1   4   6   4   1
186 //                                       0   0   0   0   0
187 //              SobelHorizSecond (5x5)  -2  -8 -12  -8  -2
188 //                                       0   0   0   0   0
189 //                                       1   4   6   4   1
190 
191 // Auxiliary parameters structure
192 typedef struct _IwiFilterSobelParams
193 {
194     int reserved;
195 } IwiFilterSobelParams;
196 
197 // Sets auxiliary parameters to default values
iwiFilterSobel_SetDefaultParams(IwiFilterSobelParams * pParams)198 static IW_INLINE void iwiFilterSobel_SetDefaultParams(
199     IwiFilterSobelParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
200 )
201 {
202     (void)pParams;
203 }
204 
205 // Applies Sobel filter of specific type to the source image
206 // Features support:
207 //      Data types:              8u16s,16s,32f
208 //      Channel types:           C1
209 //      Inplace mode:            no
210 //      64-bit sizes:            no
211 //      Internal threading:      no
212 //      Manual tiling:           yes
213 //      IwiTile simple tiling:   yes
214 //      IwiTile pipeline tiling: yes
215 // Returns:
216 //      ippStsMaskSizeErr                   mask value is illegal
217 //      ippStsDataTypeErr                   data type is illegal
218 //      ippStsNumChannelsErr                channels value is illegal
219 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
220 //      ippStsBorderErr                     border value is illegal
221 //      ippStsNotSupportedModeErr           selected function mode is not supported
222 //      ippStsNoMemErr                      failed to allocate memory
223 //      ippStsSizeErr                       size fields values are illegal
224 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
225 //      ippStsNullPtrErr                    unexpected NULL pointer
226 //      ippStsNoErr                         no errors
227 IW_DECL(IppStatus) iwiFilterSobel(
228     const IwiImage             *pSrcImage,  // [in]     Pointer to the source image
229     IwiImage                   *pDstImage,  // [in,out] Pointer to the destination image
230     IwiDerivativeType           opType,     // [in]     Type of derivative from IwiDerivativeType
231     IppiMaskSize                kernelSize, // [in]     Size of the filter kernel: ippMskSize3x3, ippMskSize5x5
232     const IwiFilterSobelParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
233     IwiBorderType               border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
234     const Ipp64f               *pBorderVal, // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
235     const IwiTile              *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
236 );
237 
238 /**/////////////////////////////////////////////////////////////////////////////
239 //                   iwiFilterScharr
240 ///////////////////////////////////////////////////////////////////////////// */
241 //
242 //                                3  0  -3
243 //              ScharrVert       10  0 -10
244 //                                3  0  -3
245 //
246 //
247 //                                3  10  3
248 //              ScharrHoriz       0   0  0
249 //                               -3 -10 -3
250 
251 // Auxiliary parameters structure
252 typedef struct _IwiFilterScharrParams
253 {
254     int reserved;
255 } IwiFilterScharrParams;
256 
257 // Sets auxiliary parameters to default values
iwiFilterScharr_SetDefaultParams(IwiFilterScharrParams * pParams)258 static IW_INLINE void iwiFilterScharr_SetDefaultParams(
259     IwiFilterScharrParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
260 )
261 {
262     (void)pParams;
263 }
264 
265 // Applies Scharr filter of specific type to the source image
266 // Features support:
267 //      Inplace mode:            no
268 //      64-bit sizes:            no
269 //      Internal threading:      no
270 //      Manual tiling:           yes
271 //      IwiTile simple tiling:   yes
272 //      IwiTile pipeline tiling: yes
273 // Returns:
274 //      ippStsMaskSizeErr                   mask value is illegal
275 //      ippStsDataTypeErr                   data type is illegal
276 //      ippStsNumChannelsErr                channels value is illegal
277 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
278 //      ippStsBorderErr                     border value is illegal
279 //      ippStsNotSupportedModeErr           selected function mode is not supported
280 //      ippStsNoMemErr                      failed to allocate memory
281 //      ippStsSizeErr                       size fields values are illegal
282 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
283 //      ippStsNullPtrErr                    unexpected NULL pointer
284 //      ippStsNoErr                         no errors
285 IW_DECL(IppStatus) iwiFilterScharr(
286     const IwiImage              *pSrcImage,  // [in]     Pointer to the source image
287     IwiImage                    *pDstImage,  // [in,out] Pointer to the destination image
288     IwiDerivativeType            opType,     // [in]     Type of derivative from IwiDerivativeType
289     IppiMaskSize                 kernelSize, // [in]     Size of the filter kernel: ippMskSize3x3, ippMskSize5x5
290     const IwiFilterScharrParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
291     IwiBorderType                border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
292     const Ipp64f                *pBorderVal, // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
293     const IwiTile               *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
294 );
295 
296 /**/////////////////////////////////////////////////////////////////////////////
297 //                   iwiFilterLaplacian
298 ///////////////////////////////////////////////////////////////////////////// */
299 //
300 //                                  2  0  2
301 //              Laplacian (3x3)     0 -8  0
302 //                                  2  0  2
303 //
304 //                                2   4   4   4   2
305 //                                4   0  -8   0   4
306 //              Laplacian (5x5)   4  -8 -24  -8   4
307 //                                4   0  -8   0   4
308 //                                2   4   4   4   2
309 
310 // Auxiliary parameters structure
311 typedef struct _IwiFilterLaplacianParams
312 {
313     int reserved;
314 } IwiFilterLaplacianParams;
315 
316 // Sets auxiliary parameters to default values
iwiFilterLaplacian_SetDefaultParams(IwiFilterLaplacianParams * pParams)317 static IW_INLINE void iwiFilterLaplacian_SetDefaultParams(
318     IwiFilterLaplacianParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
319 )
320 {
321     (void)pParams;
322 }
323 
324 // Applies Laplacian filter to the source image
325 // Features support:
326 //      Inplace mode:            no
327 //      64-bit sizes:            no
328 //      Internal threading:      no
329 //      Manual tiling:           yes
330 //      IwiTile simple tiling:   yes
331 //      IwiTile pipeline tiling: yes
332 // Returns:
333 //      ippStsMaskSizeErr                   mask value is illegal
334 //      ippStsDataTypeErr                   data type is illegal
335 //      ippStsNumChannelsErr                channels value is illegal
336 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
337 //      ippStsBorderErr                     border value is illegal
338 //      ippStsNotSupportedModeErr           selected function mode is not supported
339 //      ippStsNoMemErr                      failed to allocate memory
340 //      ippStsSizeErr                       size fields values are illegal
341 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
342 //      ippStsNullPtrErr                    unexpected NULL pointer
343 //      ippStsNoErr                         no errors
344 IW_DECL(IppStatus) iwiFilterLaplacian(
345     const IwiImage                 *pSrcImage,  // [in]     Pointer to the source image
346     IwiImage                       *pDstImage,  // [in,out] Pointer to the destination image
347     IppiMaskSize                    kernelSize, // [in]     Size of the filter kernel: ippMskSize3x3, ippMskSize5x5
348     const IwiFilterLaplacianParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
349     IwiBorderType                   border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
350     const Ipp64f                   *pBorderVal, // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
351     const IwiTile                  *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
352 );
353 
354 /* /////////////////////////////////////////////////////////////////////////////
355 //                   iwiFilterGaussian
356 ///////////////////////////////////////////////////////////////////////////// */
357 
358 // Internal structure for data sharing between function calls
359 typedef struct _IwiFilterGaussianSpec IwiFilterGaussianSpec;
360 
361 // Auxiliary parameters structure
362 typedef struct _IwiFilterGaussianParams
363 {
364     IwiChDescriptor chDesc; // Special channels processing mode
365 } IwiFilterGaussianParams;
366 
367 // Sets auxiliary parameters to default values
iwiFilterGaussian_SetDefaultParams(IwiFilterGaussianParams * pParams)368 static IW_INLINE void iwiFilterGaussian_SetDefaultParams(
369     IwiFilterGaussianParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
370 )
371 {
372     if(pParams)
373     {
374         pParams->chDesc = iwiChDesc_None;
375     }
376 }
377 
378 // Applies Gaussian filter to the source image
379 // Features support:
380 //      Inplace mode:            no
381 //      64-bit sizes:            yes
382 //      Internal threading:      no
383 //      Manual tiling:           yes
384 //      IwiTile simple tiling:   yes
385 //      IwiTile pipeline tiling: yes
386 // Returns:
387 //      ippStsMaskSizeErr                   mask value is illegal
388 //      ippStsDataTypeErr                   data type is illegal
389 //      ippStsNumChannelsErr                channels value is illegal
390 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
391 //      ippStsBorderErr                     border value is illegal
392 //      ippStsNotSupportedModeErr           selected function mode is not supported
393 //      ippStsNoMemErr                      failed to allocate memory
394 //      ippStsSizeErr                       size fields values are illegal
395 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
396 //      ippStsNullPtrErr                    unexpected NULL pointer
397 //      ippStsNoErr                         no errors
398 IW_DECL(IppStatus) iwiFilterGaussian(
399     const IwiImage                 *pSrcImage,  // [in]     Pointer to the source image
400     IwiImage                       *pDstImage,  // [in,out] Pointer to the destination image
401     int                             kernelSize, // [in]     Size of the Gaussian kernel (odd, greater or equal to 3)
402     double                          sigma,      // [in]     Standard deviation of the Gaussian kernel
403     const IwiFilterGaussianParams  *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
404     IwiBorderType                   border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
405     const Ipp64f                   *pBorderVal, // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
406     const IwiTile                  *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
407 );
408 
409 // Free internal data structure
410 IW_DECL(IppStatus) iwiFilterGaussian_Free(
411     IwiFilterGaussianSpec *pSpec        // [in]  Pointer to internal spec structure
412 );
413 
414 // Allocates and initializes internal data structure
415 // Returns:
416 //      ippStsMaskSizeErr                   mask value is illegal
417 //      ippStsDataTypeErr                   data type is illegal
418 //      ippStsNumChannelsErr                channels value is illegal
419 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
420 //      ippStsBorderErr                     border value is illegal
421 //      ippStsNotSupportedModeErr           selected function mode is not supported
422 //      ippStsNoMemErr                      failed to allocate memory
423 //      ippStsSizeErr                       size fields values are illegal
424 //      ippStsNullPtrErr                    unexpected NULL pointer
425 //      ippStsNoErr                         no errors
426 IW_DECL(IppStatus) iwiFilterGaussian_InitAlloc(
427     IwiFilterGaussianSpec         **pSpec,          // [out]    Pointer to pointer to internal spec structure. Structure will be allocated here.
428     IwiSize                         size,           // [in]     Size of the image in pixels
429     IppDataType                     dataType,       // [in]     Image pixel type
430     int                             channels,       // [in]     Number of image channels
431     int                             kernelSize,     // [in]     Size of the Gaussian kernel (odd, greater or equal to 3)
432     double                          sigma,          // [in]     Standard deviation of the Gaussian kernel
433     const IwiFilterGaussianParams  *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
434     IwiBorderType                   border          // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
435 );
436 
437 // Applies Gaussian filter to the source image
438 // Features support:
439 //      Inplace mode:            no
440 //      64-bit sizes:            yes
441 //      Internal threading:      no
442 //      Manual tiling:           yes
443 //      IwiTile simple tiling:   yes
444 //      IwiTile pipeline tiling: yes
445 // Returns:
446 //      ippStsMaskSizeErr                   mask value is illegal
447 //      ippStsDataTypeErr                   data type is illegal
448 //      ippStsNumChannelsErr                channels value is illegal
449 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
450 //      ippStsBorderErr                     border value is illegal
451 //      ippStsContextMatchErr               internal structure is not initialized or of invalid type
452 //      ippStsNoMemErr                      failed to allocate memory
453 //      ippStsSizeErr                       size fields values are illegal
454 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
455 //      ippStsNullPtrErr                    unexpected NULL pointer
456 //      ippStsNoErr                         no errors
457 IW_DECL(IppStatus) iwiFilterGaussian_Process(
458     const IwiFilterGaussianSpec *pSpec,      // [in]     Pointer to internal spec structure
459     const IwiImage              *pSrcImage,  // [in]     Pointer to the source image
460     IwiImage                    *pDstImage,  // [in,out] Pointer to the destination image
461     IwiBorderType                border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderInMem
462     const Ipp64f                *pBorderVal, // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
463     const IwiTile               *pTile       // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
464 );
465 
466 /**/////////////////////////////////////////////////////////////////////////////
467 //                   iwiFilterCanny
468 ///////////////////////////////////////////////////////////////////////////// */
469 
470 // Auxiliary parameters structure
471 typedef struct _IwiFilterCannyParams
472 {
473     IppiDifferentialKernel  kernel;     // Type of differential kernel: ippFilterSobel, ippFilterScharr
474     IppiMaskSize            kernelSize; // Size of the filter kernel: ippFilterSobel: ippMskSize3x3, ippMskSize5x5; ippFilterScharr: ippMskSize3x3
475     IppNormType             norm;       // Normalization mode: ippNormL1, ippNormL2
476 } IwiFilterCannyParams;
477 
478 // Sets auxiliary parameters to default values
iwiFilterCanny_SetDefaultParams(IwiFilterCannyParams * pParams)479 static IW_INLINE void iwiFilterCanny_SetDefaultParams(
480     IwiFilterCannyParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
481 )
482 {
483     if(pParams)
484     {
485         pParams->kernel     = ippFilterSobel;
486         pParams->kernelSize = ippMskSize3x3;
487         pParams->norm       = ippNormL2;
488     }
489 }
490 
491 // Applies Canny edge detector to the source image
492 // Features support:
493 //      Inplace mode:            no
494 //      64-bit sizes:            no
495 //      Internal threading:      no
496 //      Manual tiling:           no
497 //      IwiTile simple tiling:   no
498 //      IwiTile pipeline tiling: no
499 // Returns:
500 //      ippStsMaskSizeErr                   mask value is illegal
501 //      ippStsDataTypeErr                   data type is illegal
502 //      ippStsNumChannelsErr                channels value is illegal
503 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
504 //      ippStsBorderErr                     border value is illegal
505 //      ippStsNoMemErr                      failed to allocate memory
506 //      ippStsSizeErr                       size fields values are illegal
507 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
508 //      ippStsNullPtrErr                    unexpected NULL pointer
509 //      ippStsNoErr                         no errors
510 IW_DECL(IppStatus) iwiFilterCanny(
511     const IwiImage             *pSrcImage,  // [in]     Pointer to the source image
512     IwiImage                   *pDstImage,  // [in,out] Pointer to the destination image
513     Ipp32f                      treshLow,   // [in]     Lower threshold for edges detection
514     Ipp32f                      treshHigh,  // [in]     Upper threshold for edges detection
515     const IwiFilterCannyParams *pAuxParams, // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
516     IwiBorderType               border,     // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
517     const Ipp64f               *pBorderVal  // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
518 );
519 
520 // Auxiliary parameters structure
521 typedef struct _IwiFilterCannyDerivParams
522 {
523     IppNormType norm; // Normalization mode: ippNormL1, ippNormL2
524 } IwiFilterCannyDerivParams;
525 
526 // Sets auxiliary parameters to default values
iwiFilterCannyDeriv_SetDefaultParams(IwiFilterCannyDerivParams * pParams)527 static IW_INLINE void iwiFilterCannyDeriv_SetDefaultParams(
528     IwiFilterCannyDerivParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
529 )
530 {
531     if(pParams)
532     {
533         pParams->norm = ippNormL2;
534     }
535 }
536 
537 // Applies Canny edge detector to the image derivatives
538 // Features support:
539 //      Inplace mode:            no
540 //      64-bit sizes:            no
541 //      Internal threading:      no
542 //      Manual tiling:           no
543 //      IwiTile simple tiling:   no
544 //      IwiTile pipeline tiling: no
545 // Returns:
546 //      ippStsDataTypeErr                   data type is illegal
547 //      ippStsNumChannelsErr                channels value is illegal
548 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
549 //      ippStsNoMemErr                      failed to allocate memory
550 //      ippStsSizeErr                       size fields values are illegal
551 //      ippStsNullPtrErr                    unexpected NULL pointer
552 //      ippStsNoErr                         no errors
553 IW_DECL(IppStatus) iwiFilterCannyDeriv(
554     const IwiImage                  *pSrcImageDx,    // [in]     Pointer to X derivative of the source image
555     const IwiImage                  *pSrcImageDy,    // [in]     Pointer to Y derivative of the source image
556     IwiImage                        *pDstImage,      // [in,out] Pointer to the destination image
557     Ipp32f                           treshLow,       // [in]     Lower threshold for edges detection
558     Ipp32f                           treshHigh,      // [in]     Upper threshold for edges detection
559     const IwiFilterCannyDerivParams *pAuxParams      // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
560 );
561 
562 /**/////////////////////////////////////////////////////////////////////////////
563 //                   iwiFilterMorphology
564 ///////////////////////////////////////////////////////////////////////////// */
565 
566 // Morphology operator type enumerator
567 typedef enum _IwiMorphologyType
568 {
569     iwiMorphErode  = 0, // Erode morphology operation
570     iwiMorphDilate,     // Dilate morphology operation
571     iwiMorphOpen,       // Open morphology operation
572     iwiMorphClose,      // Close morphology operation
573     iwiMorphTophat,     // Top-hat morphology operation
574     iwiMorphBlackhat,   // Black-hat morphology operation
575     iwiMorphGradient    // Gradient morphology operation
576 } IwiMorphologyType;
577 
578 // Auxiliary parameters structure
579 typedef struct _IwiFilterMorphologyParams
580 {
581     int iterations; // Number of repeated morphology operations to apply
582 } IwiFilterMorphologyParams;
583 
584 // Sets auxiliary parameters to default values
iwiFilterMorphology_SetDefaultParams(IwiFilterMorphologyParams * pParams)585 static IW_INLINE void iwiFilterMorphology_SetDefaultParams(
586     IwiFilterMorphologyParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
587 )
588 {
589     if(pParams)
590     {
591         pParams->iterations = 1;
592     }
593 }
594 
595 // Performs morphology filter operation
596 // Features support:
597 //      Inplace mode:            no
598 //      64-bit sizes:            yes
599 //      Internal threading:      no
600 //      Manual tiling:           yes
601 //      IwiTile simple tiling:   yes
602 //      IwiTile pipeline tiling: yes
603 // Returns:
604 //      ippStsBorderErr                     border value is illegal
605 //      ippStsDataTypeErr                   data type is illegal
606 //      ippStsNumChannelsErr                channels value is illegal
607 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
608 //      ippStsNotSupportedModeErr           selected function mode is not supported
609 //      ippStsNoMemErr                      failed to allocate memory
610 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
611 //      ippStsNullPtrErr                    unexpected NULL pointer
612 //      ippStsNoErr                         no errors
613 IW_DECL(IppStatus) iwiFilterMorphology(
614     const IwiImage                  *pSrcImage,     // [in]     Pointer to the source image
615     IwiImage                        *pDstImage,     // [in,out] Pointer to the destination image
616     IwiMorphologyType                morphType,     // [in]     Morphology filter type
617     const IwiImage                  *pMaskImage,    // [in]     Pointer to morphology mask image. Mask must be continuous, 8-bit, 1 channel image
618     const IwiFilterMorphologyParams *pAuxParams,    // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
619     IwiBorderType                    border,        // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
620     const Ipp64f                    *pBorderVal,    // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
621     const IwiTile                   *pTile          // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
622 );
623 
624 // Calculates border size for morphology operation
625 // Returns:
626 //      ippStsNotSupportedModeErr           selected function mode is not supported
627 //      ippStsNullPtrErr                    unexpected NULL pointer
628 //      ippStsNoErr                         no errors
629 IW_DECL(IppStatus) iwiFilterMorphology_GetBorderSize(
630     IwiMorphologyType   morphType,      // [in]  Morphology filter type
631     IwiSize             maskSize,       // [in]  Size of morphology mask
632     IwiBorderSize      *pBorderSize     // [out] Pointer to border size structure
633 );
634 
635 /**/////////////////////////////////////////////////////////////////////////////
636 //                   iwiFilterBilateral
637 ///////////////////////////////////////////////////////////////////////////// */
638 
639 // Auxiliary parameters structure
640 typedef struct _IwiFilterBilateralParams
641 {
642     IppiFilterBilateralType filter;         // Type of bilateral filter: ippiFilterBilateralGauss
643     IppiDistanceMethodType  distMethod;     // Method for definition of distance between pixel intensity: ippDistNormL1
644 } IwiFilterBilateralParams;
645 
646 // Sets auxiliary parameters to default values
iwiFilterBilateral_SetDefaultParams(IwiFilterBilateralParams * pParams)647 static IW_INLINE void iwiFilterBilateral_SetDefaultParams(
648     IwiFilterBilateralParams *pParams      // [in,out] Pointer to the auxiliary parameters structure
649 )
650 {
651     if(pParams)
652     {
653         pParams->filter     = ippiFilterBilateralGauss;
654         pParams->distMethod = ippDistNormL1;
655     }
656 }
657 
658 // Performs bilateral filtering of an image
659 // Features support:
660 //      Inplace mode:            no
661 //      64-bit sizes:            yes
662 //      Internal threading:      yes (check IW_ENABLE_THREADING_LAYER definition)
663 //      Manual tiling:           yes
664 //      IwiTile simple tiling:   yes
665 //      IwiTile pipeline tiling: yes
666 // Returns:
667 //      ippStsSizeErr                       size fields values are illegal
668 //      ippStsBadArgErr                     valSquareSigma or posSquareSigma is less or equal 0
669 //      ippStsMaskSizeErr                   radius is less or equal 0
670 //      ippStsBorderErr                     border value is illegal
671 //      ippStsDataTypeErr                   data type is illegal
672 //      ippStsNumChannelsErr                channels value is illegal
673 //      ippStsNotEvenStepErr                step value is not divisible by size of elements
674 //      ippStsNotSupportedModeErr           filter or distMethod is not supported
675 //      ippStsNoMemErr                      failed to allocate memory
676 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
677 //      ippStsNullPtrErr                    unexpected NULL pointer
678 //      ippStsNoErr                         no errors
679 IW_DECL(IppStatus) iwiFilterBilateral(
680     const IwiImage                 *pSrcImage,      // [in]     Pointer to the source image
681     IwiImage                       *pDstImage,      // [in,out] Pointer to the destination image
682     int                             radius,         // [in]     Radius of circular neighborhood what defines pixels for calculation
683     Ipp32f                          valSquareSigma, // [in]     Square of Sigma for factor function for pixel intensity
684     Ipp32f                          posSquareSigma, // [in]     Square of Sigma for factor function for pixel position
685     const IwiFilterBilateralParams *pAuxParams,     // [in]     Pointer to the auxiliary parameters structure. If NULL - default parameters will be used
686     IwiBorderType                   border,         // [in]     Extrapolation algorithm for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderInMem
687     const Ipp64f                   *pBorderVal,     // [in]     Pointer to array of border values for ippBorderConst. One element for each channel. Can be NULL for any other border
688     const IwiTile                  *pTile           // [in]     Pointer to the IwiTile structure for tiling. If NULL - the whole image will be processed in accordance to size
689 );
690 
691 #ifdef __cplusplus
692 }
693 #endif
694 
695 #endif
696