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_IWPP_IMAGE_OP__ )
16 #define __IPP_IWPP_IMAGE_OP__
17 
18 #include "iw/iw_image_op.h"
19 #include "iw++/iw_image.hpp"
20 
21 namespace ipp
22 {
23 
24 /**/////////////////////////////////////////////////////////////////////////////
25 //                   iwiCopy
26 ///////////////////////////////////////////////////////////////////////////// */
27 
28 // Auxiliary parameters class
29 // C API descriptions has more details
30 class IwiCopyParams: public ::IwiCopyParams
31 {
32 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiCopyParams,iwiCopy_SetDefaultParams)33     IW_BASE_PARAMS_CONSTRUCTORS(IwiCopyParams, iwiCopy_SetDefaultParams)
34     IwiCopyParams() {}
35 };
36 
37 // Copies image data to destination image with masking.
38 // If mask is NULL, then calls iwiCopy function.
39 // For masked operation, the function writes pixel values in the destination buffer only if the spatially corresponding
40 // mask array value is non-zero.
41 // C API descriptions has more details.
42 // Throws:
43 //      ippStsNotSupportedModeErr           selected function mode is not supported
44 //      ippStsSizeErr                       size fields values are illegal
45 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
46 //      ippStsNullPtrErr                    unexpected NULL pointer
47 // Returns:
48 //      ippStsNoErr                         no errors
iwiCopy(const IwiImage & srcImage,IwiImage & dstImage,const IwiImage & maskImage=IwiImage (),const IwiCopyParams & auxParams=IwiCopyParams (),const IwiTile & tile=IwiTile ())49 IW_DECL_CPP(IppStatus) iwiCopy(
50     const IwiImage      &srcImage,                      // [in]     Reference to the source image
51     IwiImage            &dstImage,                      // [in,out] Reference to the destination image
52     const IwiImage      &maskImage   = IwiImage(),      // [in]     Reference to the mask image. Mask must be 8-bit, 1 channel image
53     const IwiCopyParams &auxParams   = IwiCopyParams(), // [in]     Reference to the auxiliary parameters structure
54     const IwiTile       &tile        = IwiTile()        // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
55 )
56 {
57     IppStatus ippStatus = ::iwiCopy(&srcImage, &dstImage, &maskImage, &auxParams, &tile);
58     OWN_ERROR_CHECK(ippStatus)
59     return ippStatus;
60 }
61 
62 /**/////////////////////////////////////////////////////////////////////////////
63 //                   iwiCopyChannel
64 ///////////////////////////////////////////////////////////////////////////// */
65 
66 // Auxiliary parameters class
67 // C API descriptions has more details
68 class IwiCopyChannelParams: public ::IwiCopyChannelParams
69 {
70 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiCopyChannelParams,iwiCopyChannel_SetDefaultParams)71     IW_BASE_PARAMS_CONSTRUCTORS(IwiCopyChannelParams, iwiCopyChannel_SetDefaultParams)
72     IwiCopyChannelParams() {}
73 };
74 
75 // Copies selected channel from one image to another.
76 // C API descriptions has more details.
77 // Throws:
78 //      ippStsDataTypeErr                   data type is illegal
79 //      ippStsNumChannelsErr                channels value is illegal
80 //      ippStsSizeErr                       size fields values are illegal
81 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer
82 //      ippStsNullPtrErr                    unexpected NULL pointer
83 // Returns:
84 //      ippStsNoErr                         no errors
iwiCopyChannel(const IwiImage & srcImage,int srcChannel,IwiImage & dstImage,int dstChannel,const IwiCopyChannelParams & auxParams=IwiCopyChannelParams (),const IwiTile & tile=IwiTile ())85 IW_DECL_CPP(IppStatus) iwiCopyChannel(
86     const IwiImage             &srcImage,                               // [in]     Reference to the source image
87     int                         srcChannel,                             // [in]     Source channel to copy from (starting from 0)
88     IwiImage                   &dstImage,                               // [in,out] Reference to the destination image
89     int                         dstChannel,                             // [in]     Destination channel to copy to (starting from 0)
90     const IwiCopyChannelParams &auxParams   = IwiCopyChannelParams(),   // [in]     Reference to the auxiliary parameters structure
91     const IwiTile              &tile        = IwiTile()                 // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
92 )
93 {
94     IppStatus ippStatus = ::iwiCopyChannel(&srcImage, srcChannel, &dstImage, dstChannel, &auxParams, &tile);
95     OWN_ERROR_CHECK(ippStatus)
96     return ippStatus;
97 }
98 
99 /**/////////////////////////////////////////////////////////////////////////////
100 //                   iwiSplitChannels
101 ///////////////////////////////////////////////////////////////////////////// */
102 
103 // Auxiliary parameters class
104 // C API descriptions has more details
105 class IwiSplitChannelsParams: public ::IwiSplitChannelsParams
106 {
107 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSplitChannelsParams,iwiSplitChannels_SetDefaultParams)108     IW_BASE_PARAMS_CONSTRUCTORS(IwiSplitChannelsParams, iwiSplitChannels_SetDefaultParams)
109     IwiSplitChannelsParams() {}
110 };
111 
112 // Splits multi-channel image into array of single channel images.
113 // C API descriptions has more details.
114 // Throws:
115 //      ippStsDataTypeErr                   data type is illegal
116 //      ippStsNumChannelsErr                channels value is illegal
117 //      ippStsSizeErr                       size fields values are illegal
118 //      ippStsNullPtrErr                    unexpected NULL pointer
119 // Returns:
120 //      ippStsNoErr                         no errors
iwiSplitChannels(const IwiImage & srcImage,IwiImageArray dstImages,const IwiSplitChannelsParams & auxParams=IwiSplitChannelsParams (),const IwiTile & tile=IwiTile ())121 IW_DECL_CPP(IppStatus) iwiSplitChannels(
122     const IwiImage               &srcImage,                                 // [in]     Reference to the source image
123           IwiImageArray           dstImages,                                // [in,out] The array object of destination images. Uninitialized images will be skipped
124     const IwiSplitChannelsParams &auxParams  = IwiSplitChannelsParams(),    // [in]     Reference to the auxiliary parameters structure
125     const IwiTile                &tile       = IwiTile()                    // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
126 )
127 {
128     ::IwiImage* const pDstImages[] = {&dstImages.imArray[0], &dstImages.imArray[1], &dstImages.imArray[2], &dstImages.imArray[3]};
129     IppStatus ippStatus = ::iwiSplitChannels(&srcImage, pDstImages, &auxParams, &tile);
130     OWN_ERROR_CHECK(ippStatus)
131     return ippStatus;
132 }
133 
134 /**/////////////////////////////////////////////////////////////////////////////
135 //                   iwiMergeChannels
136 ///////////////////////////////////////////////////////////////////////////// */
137 
138 // Auxiliary parameters class
139 // C API descriptions has more details
140 class IwiMergeChannelsParams: public ::IwiMergeChannelsParams
141 {
142 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiMergeChannelsParams,iwiMergeChannels_SetDefaultParams)143     IW_BASE_PARAMS_CONSTRUCTORS(IwiMergeChannelsParams, iwiMergeChannels_SetDefaultParams)
144     IwiMergeChannelsParams() {}
145 };
146 
147 // Merges array of single channel images into one multi-channel image.
148 // C API descriptions has more details.
149 // Throws:
150 //      ippStsDataTypeErr                   data type is illegal
151 //      ippStsNumChannelsErr                channels value is illegal
152 //      ippStsSizeErr                       size fields values are illegal
153 //      ippStsNullPtrErr                    unexpected NULL pointer
154 // Returns:
155 //      ippStsNoErr                         no errors
iwiMergeChannels(const IwiImageArray & srcImages,IwiImage & dstImage,const IwiMergeChannelsParams & auxParams=IwiMergeChannelsParams (),const IwiTile & tile=IwiTile ())156 IW_DECL_CPP(IppStatus) iwiMergeChannels(
157     const IwiImageArray          &srcImages,                                // [in]     Reference to the array object of source images. Uninitialized images will be skipped
158     IwiImage                     &dstImage,                                 // [in,out] Reference to the destination image
159     const IwiMergeChannelsParams &auxParams  = IwiMergeChannelsParams(),    // [in]     Reference to the auxiliary parameters structure
160     const IwiTile                &tile       = IwiTile()                    // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
161 )
162 {
163     const ::IwiImage* const pSrcImages[] = {&srcImages.imArray[0], &srcImages.imArray[1], &srcImages.imArray[2], &srcImages.imArray[3]};
164     IppStatus ippStatus = ::iwiMergeChannels(pSrcImages, &dstImage, &auxParams, &tile);
165     OWN_ERROR_CHECK(ippStatus)
166     return ippStatus;
167 }
168 
169 /**/////////////////////////////////////////////////////////////////////////////
170 //                   iwiCreateBorder
171 ///////////////////////////////////////////////////////////////////////////// */
172 
173 // Auxiliary parameters class
174 // C API descriptions has more details
175 class IwiCreateBorderParams: public ::IwiCreateBorderParams
176 {
177 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiCreateBorderParams,iwiCreateBorder_SetDefaultParams)178     IW_BASE_PARAMS_CONSTRUCTORS(IwiCreateBorderParams, iwiCreateBorder_SetDefaultParams)
179     IwiCreateBorderParams() {}
180 };
181 
182 // Copies image data to destination image and constructs border of specified size.
183 // Destination image must have enough memory for a border according to inMemSize member.
184 // C API descriptions has more details.
185 // Throws:
186 //      ippStsNotSupportedModeErr           selected function mode is not supported
187 //      ippStsSizeErr                       1) size fields values are illegal
188 //                                          2) border.top or border.left are greater than corresponding inMemSize values of destination image
189 //                                          3) dst_width  + dst_inMemSize.right  < min_width  + border.right
190 //                                          4) dst_height + dst_inMemSize.bottom < min_height + border.bottom
191 //      ippStsNullPtrErr                    unexpected NULL pointer
192 // Returns:
193 //      ippStsNoErr                         no errors
iwiCreateBorder(const IwiImage & srcImage,IwiImage & dstImage,IwiBorderSize borderSize,IwiBorderType border,const IwiCreateBorderParams & auxParams=IwiCreateBorderParams (),const IwiTile & tile=IwiTile ())194 IW_DECL_CPP(IppStatus) iwiCreateBorder(
195     const IwiImage                 &srcImage,                                   // [in]     Reference to the source image
196     IwiImage                       &dstImage,                                   // [in,out] Reference to the destination image actual data start
197     IwiBorderSize                   borderSize,                                 // [in]     Size of border to reconstruct
198     IwiBorderType                   border,                                     // [in]     Extrapolation algorithm and value for out of image pixels: ippBorderConst, ippBorderRepl, ippBorderMirror, ippBorderWrap
199     const IwiCreateBorderParams    &auxParams   = IwiCreateBorderParams(),      // [in]     Reference to the auxiliary parameters structure
200     const IwiTile                  &tile        = IwiTile()                     // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
201 )
202 {
203     IppStatus ippStatus = ::iwiCreateBorder(&srcImage, &dstImage, borderSize, border.m_type, border.m_value, &auxParams, &tile);
204     OWN_ERROR_CHECK(ippStatus)
205     return ippStatus;
206 }
207 
208 /**/////////////////////////////////////////////////////////////////////////////
209 //                   iwiSet
210 ///////////////////////////////////////////////////////////////////////////// */
211 
212 // Auxiliary parameters class
213 // C API descriptions has more details
214 class IwiSetParams: public ::IwiSetParams
215 {
216 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSetParams,iwiSet_SetDefaultParams)217     IW_BASE_PARAMS_CONSTRUCTORS(IwiSetParams, iwiSet_SetDefaultParams)
218     IwiSetParams() {}
219 };
220 
221 // Sets each channel of the image to the specified values with masking.
222 // If mask is NULL, then calls iwiSet function.
223 // For masked operation, the function writes pixel values in the destination buffer only if the spatially corresponding
224 // mask array value is non-zero.
225 // C API descriptions has more details.
226 // Throws:
227 //      ippStsDataTypeErr                   data type is illegal
228 //      ippStsNumChannelsErr                channels value is illegal
229 //      ippStsSizeErr                       size fields values are illegal
230 //      ippStsNullPtrErr                    unexpected NULL pointer
231 // Returns:
232 //      ippStsNoErr                         no errors
iwiSet(IwValueFloat values,IwiImage & dstImage,const IwiImage & maskImage=IwiImage (),const IwiSetParams & auxParams=IwiSetParams (),const IwiTile & tile=IwiTile ())233 IW_DECL_CPP(IppStatus) iwiSet(
234     IwValueFloat        values,                         // [in]     Values to set to
235     IwiImage           &dstImage,                       // [in,out] Reference to the destination image
236     const IwiImage     &maskImage   = IwiImage(),       // [in]     Reference to the mask image. Mask must be 8-bit, 1 channel image
237     const IwiSetParams &auxParams   = IwiSetParams(),   // [in]     Reference to the auxiliary parameters structure
238     const IwiTile      &tile        = IwiTile()         // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
239 )
240 {
241     IppStatus ippStatus = ::iwiSet(values, values.ValuesNum(), &dstImage, &maskImage, &auxParams, &tile);
242     OWN_ERROR_CHECK(ippStatus)
243     return ippStatus;
244 }
245 
246 /**/////////////////////////////////////////////////////////////////////////////
247 //                   iwiSetChannel
248 ///////////////////////////////////////////////////////////////////////////// */
249 
250 // Auxiliary parameters class
251 // C API descriptions has more details
252 class IwiSetChannelParams: public ::IwiSetChannelParams
253 {
254 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSetChannelParams,iwiSetChannel_SetDefaultParams)255     IW_BASE_PARAMS_CONSTRUCTORS(IwiSetChannelParams, iwiSetChannel_SetDefaultParams)
256     IwiSetChannelParams() {}
257 };
258 
259 // Sets selected channel of the multi-channel image to the specified value.
260 // C API descriptions has more details.
261 // Throws:
262 //      ippStsDataTypeErr                   data type is illegal
263 //      ippStsNumChannelsErr                channels value is illegal
264 //      ippStsSizeErr                       size fields values are illegal
265 //      ippStsNullPtrErr                    unexpected NULL pointer
266 // Returns:
267 //      ippStsNoErr                         no errors
iwiSetChannel(double value,IwiImage & dstImage,int channelNum,const IwiSetChannelParams & auxParams=IwiSetChannelParams (),const IwiTile & tile=IwiTile ())268 IW_DECL_CPP(IppStatus) iwiSetChannel(
269     double                      value,                                  // [in]     Value to set to
270     IwiImage                   &dstImage,                               // [in,out] Reference to the destination image
271     int                         channelNum,                             // [in]     Number of channel to be set (starting from 0)
272     const IwiSetChannelParams  &auxParams   = IwiSetChannelParams(),    // [in]     Reference to the auxiliary parameters structure
273     const IwiTile              &tile        = IwiTile()                 // [in,out] Reference to the IwiTile object for tiling. By default no tiling is used
274 )
275 {
276     IppStatus ippStatus = ::iwiSetChannel(value, &dstImage, channelNum, &auxParams, &tile);
277     OWN_ERROR_CHECK(ippStatus)
278     return ippStatus;
279 }
280 
281 /**/////////////////////////////////////////////////////////////////////////////
282 //                   iwiAdd
283 ///////////////////////////////////////////////////////////////////////////// */
284 
285 // Auxiliary parameters class
286 // C API descriptions has more details
287 class IwiAddParams: public ::IwiAddParams
288 {
289 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiAddParams,iwiAdd_SetDefaultParams)290     IW_BASE_PARAMS_CONSTRUCTORS(IwiAddParams, iwiAdd_SetDefaultParams)
291     IwiAddParams(int _scaleFactor = 0, IwiChDescriptor _chDesc = iwiChDesc_None)
292     {
293         this->scaleFactor = _scaleFactor;
294         this->chDesc      = _chDesc;
295     }
296 };
297 
298 // Performs addition of one image to another and writes result to the output.
299 // C API descriptions has more details.
300 // Throws:
301 //      ippStsDataTypeErr                   data type is illegal
302 //      ippStsNumChannelsErr                channels value is illegal
303 //      ippStsSizeErr                       size fields values are illegal
304 //      ippStsNullPtrErr                    unexpected NULL pointer
305 // Returns:
306 //      ippStsNoErr                         no errors
iwiAdd(const IwiImage & addend1,const IwiImage & addend2,IwiImage & dstImage,const IwiAddParams & auxParams=IwiAddParams (),const IwiTile & tile=IwiTile ())307 IW_DECL_CPP(IppStatus) iwiAdd(
308     const IwiImage      &addend1,                      // [in]     Reference to the first addend image
309     const IwiImage      &addend2,                      // [in]     Reference to the second addend image
310     IwiImage            &dstImage,                      // [in,out] Reference to the result image (can be same as the second addend)
311     const IwiAddParams  &auxParams  = IwiAddParams(),   // [in]     Reference to the auxiliary parameters structure
312     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
313 )
314 {
315     IppStatus ippStatus = ::iwiAdd(&addend1, &addend2, &dstImage, &auxParams, &tile);
316     OWN_ERROR_CHECK(ippStatus)
317     return ippStatus;
318 }
319 
320 /**/////////////////////////////////////////////////////////////////////////////
321 //                   iwiAddC
322 ///////////////////////////////////////////////////////////////////////////// */
323 
324 // Auxiliary parameters class
325 // C API descriptions has more details
326 class IwiAddCParams: public ::IwiAddCParams
327 {
328 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiAddCParams,iwiAddC_SetDefaultParams)329     IW_BASE_PARAMS_CONSTRUCTORS(IwiAddCParams, iwiAddC_SetDefaultParams)
330     IwiAddCParams(int _scaleFactor = 0, IwiChDescriptor _chDesc = iwiChDesc_None)
331     {
332         this->scaleFactor = _scaleFactor;
333         this->chDesc      = _chDesc;
334     }
335 };
336 
337 // Performs addition of the constant to the image another and writes result to the output.
338 // C API descriptions has more details.
339 // Returns:
340 //      ippStsDataTypeErr                   data type is illegal
341 //      ippStsNumChannelsErr                channels value is illegal
342 //      ippStsSizeErr                       size fields values are illegal
343 //      ippStsNullPtrErr                    unexpected NULL pointer
344 //      ippStsNoErr                         no errors
iwiAddC(IwValueFloat addend,const IwiImage & addendImage,IwiImage & dstImage,const IwiAddCParams & auxParams=IwiAddCParams (),const IwiTile & tile=IwiTile ())345 IW_DECL_CPP(IppStatus) iwiAddC(
346     IwValueFloat         addend,                        // [in]     Addends. One element for each channel
347     const IwiImage      &addendImage,                   // [in]     Reference to the addend image
348     IwiImage            &dstImage,                      // [in,out] Reference to the difference image (can be same as addend image)
349     const IwiAddCParams &auxParams  = IwiAddCParams(),  // [in]     Reference to the auxiliary parameters structure
350     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
351 )
352 {
353     IppStatus ippStatus = ::iwiAddC(addend, addend.ValuesNum(), &addendImage, &dstImage, &auxParams, &tile);
354     OWN_ERROR_CHECK(ippStatus)
355     return ippStatus;
356 }
357 
358 /**/////////////////////////////////////////////////////////////////////////////
359 //                   iwiSub
360 ///////////////////////////////////////////////////////////////////////////// */
361 
362 // Auxiliary parameters class
363 // C API descriptions has more details
364 class IwiSubParams: public ::IwiSubParams
365 {
366 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSubParams,iwiSub_SetDefaultParams)367     IW_BASE_PARAMS_CONSTRUCTORS(IwiSubParams, iwiSub_SetDefaultParams)
368     IwiSubParams(int _scaleFactor = 0, IwiChDescriptor _chDesc = iwiChDesc_None)
369     {
370         this->scaleFactor = _scaleFactor;
371         this->chDesc      = _chDesc;
372     }
373 };
374 
375 // Performs subtraction of the first image from the second image and writes result to the output.
376 // C API descriptions has more details.
377 // Throws:
378 //      ippStsDataTypeErr                   data type is illegal
379 //      ippStsNumChannelsErr                channels value is illegal
380 //      ippStsSizeErr                       size fields values are illegal
381 //      ippStsNullPtrErr                    unexpected NULL pointer
382 // Returns:
383 //      ippStsNoErr                         no errors
iwiSub(const IwiImage & subtrahend,const IwiImage & minuend,IwiImage & dstImage,const IwiSubParams & auxParams=IwiSubParams (),const IwiTile & tile=IwiTile ())384 IW_DECL_CPP(IppStatus) iwiSub(
385     const IwiImage      &subtrahend,                    // [in]     Reference to the subtrahend image
386     const IwiImage      &minuend,                       // [in]     Reference to the minuend image
387     IwiImage            &dstImage,                      // [in,out] Reference to the difference image (can be same as minuend)
388     const IwiSubParams  &auxParams  = IwiSubParams(),   // [in]     Reference to the auxiliary parameters structure
389     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
390 )
391 {
392     IppStatus ippStatus = ::iwiSub(&subtrahend, &minuend, &dstImage, &auxParams, &tile);
393     OWN_ERROR_CHECK(ippStatus)
394     return ippStatus;
395 }
396 
397 /**/////////////////////////////////////////////////////////////////////////////
398 //                   iwiSubC
399 ///////////////////////////////////////////////////////////////////////////// */
400 
401 // Auxiliary parameters class
402 // C API descriptions has more details
403 class IwiSubCParams: public ::IwiSubCParams
404 {
405 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSubCParams,iwiSubC_SetDefaultParams)406     IW_BASE_PARAMS_CONSTRUCTORS(IwiSubCParams, iwiSubC_SetDefaultParams)
407     IwiSubCParams(int _scaleFactor = 0, IwiChDescriptor _chDesc = iwiChDesc_None)
408     {
409         this->scaleFactor = _scaleFactor;
410         this->chDesc      = _chDesc;
411     }
412 };
413 
414 // Performs subtraction of the constant from the image and writes result to the output.
415 // C API descriptions has more details.
416 // Returns:
417 //      ippStsDataTypeErr                   data type is illegal
418 //      ippStsNumChannelsErr                channels value is illegal
419 //      ippStsSizeErr                       size fields values are illegal
420 //      ippStsNullPtrErr                    unexpected NULL pointer
421 //      ippStsNoErr                         no errors
iwiSubC(IwValueFloat subtrahend,const IwiImage & minuendImage,IwiImage & dstImage,const IwiSubCParams & auxParams=IwiSubCParams (),const IwiTile & tile=IwiTile ())422 IW_DECL_CPP(IppStatus) iwiSubC(
423     IwValueFloat         subtrahend,                    // [in]     Subtrahends. One element for each channel
424     const IwiImage      &minuendImage,                  // [in]     Reference to the minuend image
425     IwiImage            &dstImage,                      // [in,out] Reference to the difference image (can be same as minuend)
426     const IwiSubCParams &auxParams  = IwiSubCParams(),  // [in]     Reference to the auxiliary parameters structure
427     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
428 )
429 {
430     IppStatus ippStatus = ::iwiSubC(subtrahend, subtrahend.ValuesNum(), &minuendImage, &dstImage, &auxParams, &tile);
431     OWN_ERROR_CHECK(ippStatus)
432     return ippStatus;
433 }
434 
435 /**/////////////////////////////////////////////////////////////////////////////
436 //                   iwiMul
437 ///////////////////////////////////////////////////////////////////////////// */
438 
439 // Auxiliary parameters class
440 // C API descriptions has more details
441 class IwiMulParams: public ::IwiMulParams
442 {
443 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiMulParams,iwiMul_SetDefaultParams)444     IW_BASE_PARAMS_CONSTRUCTORS(IwiMulParams, iwiMul_SetDefaultParams)
445     IwiMulParams(int _scaleFactor = 0, IppHintAlgorithm _algoMode = ippAlgHintNone, IwiChDescriptor _chDesc = iwiChDesc_None)
446     {
447         this->algoMode          = _algoMode;
448         this->scaleFactor       = _scaleFactor;
449         this->chDesc            = _chDesc;
450     }
451 };
452 
453 // Performs multiplication of one image by another and writes result to the output
454 // C API descriptions has more details.
455 // Throws:
456 //      ippStsDataTypeErr                   data type is illegal
457 //      ippStsNumChannelsErr                channels value is illegal
458 //      ippStsSizeErr                       size fields values are illegal
459 //      ippStsNullPtrErr                    unexpected NULL pointer
460 // Returns:
461 //      ippStsNoErr                         no errors
iwiMul(const IwiImage & factor1,const IwiImage & factor2,IwiImage & dstImage,const IwiMulParams & auxParams=IwiMulParams (),const IwiTile & tile=IwiTile ())462 IW_DECL_CPP(IppStatus) iwiMul(
463     const IwiImage     &factor1,                        // [in]     Reference to the first factor image
464     const IwiImage     &factor2,                        // [in]     Reference to the second factor image
465     IwiImage           &dstImage,                       // [in,out] Reference to the product image (can be same as the second factor)
466     const IwiMulParams &auxParams   = IwiMulParams(),   // [in]     Reference to the auxiliary parameters structure
467     const IwiTile      &tile        = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
468 )
469 {
470     IppStatus ippStatus = ::iwiMul(&factor1, &factor2, &dstImage, &auxParams, &tile);
471     OWN_ERROR_CHECK(ippStatus)
472     return ippStatus;
473 }
474 
475 /**/////////////////////////////////////////////////////////////////////////////
476 //                   iwiMulC
477 ///////////////////////////////////////////////////////////////////////////// */
478 
479 // Auxiliary parameters class
480 // C API descriptions has more details
481 class IwiMulCParams: public ::IwiMulCParams
482 {
483 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiMulCParams,iwiMulC_SetDefaultParams)484     IW_BASE_PARAMS_CONSTRUCTORS(IwiMulCParams, iwiMulC_SetDefaultParams)
485     IwiMulCParams(int _scaleFactor = 0, IppHintAlgorithm _algoMode = ippAlgHintNone, IppRoundMode _round = ippRndNear, IwiChDescriptor _chDesc = iwiChDesc_None)
486     {
487         this->roundMode   = _round;
488         this->algoMode    = _algoMode;
489         this->scaleFactor = _scaleFactor;
490         this->chDesc      = _chDesc;
491     }
492 };
493 
494 // Performs multiplication of one image by constant and writes result to the output.
495 // C API descriptions has more details.
496 // Returns:
497 //      ippStsDataTypeErr                   data type is illegal
498 //      ippStsNumChannelsErr                channels value is illegal
499 //      ippStsSizeErr                       size fields values are illegal
500 //      ippStsNullPtrErr                    unexpected NULL pointer
501 //      ippStsNoErr                         no errors
iwiMulC(IwValueFloat factor,const IwiImage & factorImage,IwiImage & dstImage,const IwiMulCParams & auxParams=IwiMulCParams (),const IwiTile & tile=IwiTile ())502 IW_DECL_CPP(IppStatus) iwiMulC(
503     IwValueFloat         factor,                        // [in]     Factors. One element for each channel
504     const IwiImage      &factorImage,                   // [in]     Reference to the factor image
505     IwiImage            &dstImage,                      // [in,out] Reference to the product image (can be same as factor image)
506     const IwiMulCParams &auxParams  = IwiMulCParams(),  // [in]     Reference to the auxiliary parameters structure
507     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
508 )
509 {
510     IppStatus ippStatus = ::iwiMulC(factor, factor.ValuesNum(), &factorImage, &dstImage, &auxParams, &tile);
511     OWN_ERROR_CHECK(ippStatus)
512     return ippStatus;
513 }
514 
515 /**/////////////////////////////////////////////////////////////////////////////
516 //                   iwiDiv
517 ///////////////////////////////////////////////////////////////////////////// */
518 
519 // Auxiliary parameters class
520 // C API descriptions has more details
521 class IwiDivParams: public ::IwiDivParams
522 {
523 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiDivParams,iwiDiv_SetDefaultParams)524     IW_BASE_PARAMS_CONSTRUCTORS(IwiDivParams, iwiDiv_SetDefaultParams)
525     IwiDivParams(int _scaleFactor = 0, IppHintAlgorithm _algoMode = ippAlgHintNone, IwiChDescriptor _chDesc = iwiChDesc_None)
526     {
527         this->algoMode          = _algoMode;
528         this->scaleFactor       = _scaleFactor;
529         this->chDesc            = _chDesc;
530     }
531 };
532 
533 // Performs division of the second image by the first image and writes result to the output.
534 // C API descriptions has more details.
535 // Throws:
536 //      ippStsDataTypeErr                   data type is illegal
537 //      ippStsNumChannelsErr                channels value is illegal
538 //      ippStsSizeErr                       size fields values are illegal
539 //      ippStsNullPtrErr                    unexpected NULL pointer
540 // Returns:
541 //      ippStsNoErr                         no errors
iwiDiv(const IwiImage & denominator,const IwiImage & numerator,IwiImage & dstImage,const IwiDivParams & auxParams=IwiDivParams (),const IwiTile & tile=IwiTile ())542 IW_DECL_CPP(IppStatus) iwiDiv(
543     const IwiImage     &denominator,                    // [in]     Reference to the denominator image
544     const IwiImage     &numerator,                      // [in]     Reference to the numerator image
545     IwiImage           &dstImage,                       // [in,out] Reference to the fraction image (can be same as numerator)
546     const IwiDivParams &auxParams   = IwiDivParams(),   // [in]     Reference to the auxiliary parameters structure
547     const IwiTile      &tile        = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
548 )
549 {
550     IppStatus ippStatus = ::iwiDiv(&denominator, &numerator, &dstImage, &auxParams, &tile);
551     OWN_ERROR_CHECK(ippStatus)
552     return ippStatus;
553 }
554 
555 /**/////////////////////////////////////////////////////////////////////////////
556 //                   iwiDivC
557 ///////////////////////////////////////////////////////////////////////////// */
558 
559 // Auxiliary parameters class
560 // C API descriptions has more details
561 class IwiDivCParams: public ::IwiDivCParams
562 {
563 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiDivCParams,iwiDivC_SetDefaultParams)564     IW_BASE_PARAMS_CONSTRUCTORS(IwiDivCParams, iwiDivC_SetDefaultParams)
565     IwiDivCParams(int _scaleFactor = 0, IppHintAlgorithm _algoMode = ippAlgHintNone, IppRoundMode _round = ippRndNear, IwiChDescriptor _chDesc = iwiChDesc_None)
566     {
567         this->roundMode   = _round;
568         this->algoMode    = _algoMode;
569         this->scaleFactor = _scaleFactor;
570         this->chDesc      = _chDesc;
571     }
572 };
573 
574 // Performs division of the second image by constant and writes result to the output.
575 // C API descriptions has more details.
576 // Returns:
577 //      ippStsDataTypeErr                   data type is illegal
578 //      ippStsNumChannelsErr                channels value is illegal
579 //      ippStsSizeErr                       size fields values are illegal
580 //      ippStsNullPtrErr                    unexpected NULL pointer
581 //      ippStsNoErr                         no errors
iwiDivC(IwValueFloat denominator,const IwiImage & numeratorImage,IwiImage & dstImage,const IwiDivCParams & auxParams=IwiDivCParams (),const IwiTile & tile=IwiTile ())582 IW_DECL_CPP(IppStatus) iwiDivC(
583     IwValueFloat         denominator,                   // [in]     Denominators. One element for each channel
584     const IwiImage      &numeratorImage,                // [in]     Reference to the numerator image
585     IwiImage            &dstImage,                      // [in,out] Reference to the fraction image (can be same as numerator)
586     const IwiDivCParams &auxParams  = IwiDivCParams(),  // [in]     Reference to the auxiliary parameters structure
587     const IwiTile       &tile       = IwiTile()         // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
588 )
589 {
590     IppStatus ippStatus = ::iwiDivC(denominator, denominator.ValuesNum(), &numeratorImage, &dstImage, &auxParams, &tile);
591     OWN_ERROR_CHECK(ippStatus)
592     return ippStatus;
593 }
594 
595 /**/////////////////////////////////////////////////////////////////////////////
596 //                   iwiSwapChannels
597 ///////////////////////////////////////////////////////////////////////////// */
598 
599 // Auxiliary parameters class
600 // C API descriptions has more details
601 class IwiSwapChannelsParams: public ::IwiSwapChannelsParams
602 {
603 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiSwapChannelsParams,iwiSwapChannels_SetDefaultParams)604     IW_BASE_PARAMS_CONSTRUCTORS(IwiSwapChannelsParams, iwiSwapChannels_SetDefaultParams)
605     IwiSwapChannelsParams(IwiChDescriptor _chDesc = iwiChDesc_None)
606     {
607         this->chDesc = _chDesc;
608     }
609 };
610 
611 // Swaps image channels according to the destination order parameter.
612 // C API descriptions has more details.
613 // Throws:
614 //      ippStsChannelOrderErr               destination order is out of the range
615 //      ippStsDataTypeErr                   data type is illegal
616 //      ippStsNumChannelsErr                channels value is illegal
617 //      ippStsSizeErr                       size fields values are illegal
618 //      ippStsNullPtrErr                    unexpected NULL pointer
619 // Returns:
620 //      ippStsNoErr                         no errors
iwiSwapChannels(const IwiImage & srcImage,IwiImage & dstImage,const IwValueInt & dstOrder,double value=IwValueMax,const IwiSwapChannelsParams & auxParams=IwiSwapChannelsParams (),const IwiTile & tile=IwiTile ())621 IW_DECL_CPP(IppStatus) iwiSwapChannels(
622     const IwiImage              &srcImage,                              // [in]     Reference to the source image
623     IwiImage                    &dstImage,                              // [in,out] Reference to the destination image
624     const IwValueInt            &dstOrder,                              // [in]     Destination image channels order: dst[channel] = src[dstOrder[channel]]
625     double                       value      = IwValueMax,               // [in]     Value to fill the destination channel if number of destination channels is bigger than number of source channels
626     const IwiSwapChannelsParams &auxParams  = IwiSwapChannelsParams(),  // [in]     Reference to the auxiliary parameters structure
627     const IwiTile               &tile       = IwiTile()                 // [in]     Reference to the IwiTile structure for tiling. By default no tiling is used
628 )
629 {
630     IppStatus ippStatus   = ::iwiSwapChannels(&srcImage, &dstImage, dstOrder, value, &auxParams, &tile);
631     OWN_ERROR_CHECK(ippStatus)
632     return ippStatus;
633 }
634 
635 /**/////////////////////////////////////////////////////////////////////////////
636 //                   iwiScale
637 ///////////////////////////////////////////////////////////////////////////// */
638 
639 // Auxiliary parameters class
640 // C API descriptions has more details
641 class IwiScaleParams: public ::IwiScaleParams
642 {
643 public:
IW_BASE_PARAMS_CONSTRUCTORS(IwiScaleParams,iwiScale_SetDefaultParams)644     IW_BASE_PARAMS_CONSTRUCTORS(IwiScaleParams, iwiScale_SetDefaultParams)
645     IwiScaleParams(IppHintAlgorithm _algoMode = ippAlgHintNone)
646     {
647         this->algoMode = _algoMode;
648     }
649 };
650 
651 // Converts image from one data type to another with specified scaling and shifting
652 // DST = saturate(SRC*mulVal + addVal)
653 // C API descriptions has more details.
654 // Throws:
655 //      ippStsDataTypeErr                   data type is illegal
656 //      ippStsSizeErr                       size fields values are illegal
657 //      ippStsInplaceModeNotSupportedErr    doesn't support output into the source buffer. If data types are different
658 //      ippStsNullPtrErr                    unexpected NULL pointer
659 // Returns:
660 //      ippStsNoErr                         no errors
iwiScale(const IwiImage & srcImage,IwiImage & dstImage,Ipp64f mulVal,Ipp64f addVal,const IwiScaleParams & auxParams=IwiScaleParams (),const IwiTile & tile=IwiTile ())661 IW_DECL_CPP(IppStatus) iwiScale(
662     const IwiImage         &srcImage,                       // [in]     Reference to the source image
663     IwiImage               &dstImage,                       // [in,out] Reference to the destination image
664     Ipp64f                  mulVal,                         // [in]     Multiplier
665     Ipp64f                  addVal,                         // [in]     Addend
666     const IwiScaleParams   &auxParams   = IwiScaleParams(), // [in]     Reference to the auxiliary parameters structure
667     const IwiTile          &tile        = IwiTile()         // [in]     Reference to the IwiTile object for tiling. By default no tiling is used
668 )
669 {
670     IppStatus ippStatus = ::iwiScale(&srcImage, &dstImage, mulVal, addVal, &auxParams, &tile);
671     OWN_ERROR_CHECK(ippStatus)
672     return ippStatus;
673 }
674 
675 // Returns multiplication and addend values for iwiScale function to perform accurate data range scaling between two data types
676 // Data range for float values is considered to be from 0 to 1
677 // Throws:
678 //      ippStsDataTypeErr                   data type is illegal
679 // Returns:
680 //      ippStsNoErr                         no errors
iwiScale_GetScaleVals(IppDataType srcType,IppDataType dstType,Ipp64f & mulVal,Ipp64f & addVal)681 IW_DECL_CPP(IppStatus) iwiScale_GetScaleVals(
682     IppDataType srcType,    // [in]     Source data type
683     IppDataType dstType,    // [in]     Destination data type
684     Ipp64f     &mulVal,     // [out]    Pointer to multiplier
685     Ipp64f     &addVal      // [out]    Pointer to addend
686 )
687 {
688     IppStatus ippStatus = ::iwiScale_GetScaleVals(srcType, dstType, &mulVal, &addVal);
689     OWN_ERROR_CHECK(ippStatus)
690     return ippStatus;
691 }
692 
693 }
694 
695 #endif
696