File: image.h

package info (click to toggle)
arrayfire 3.3.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 109,016 kB
  • sloc: cpp: 127,909; lisp: 6,878; python: 3,923; ansic: 1,051; sh: 347; makefile: 338; xml: 175
file content (1352 lines) | stat: -rw-r--r-- 52,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
/*******************************************************
 * Copyright (c) 2014, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

#pragma once
#include <af/defines.h>
#include <af/features.h>

#ifdef __cplusplus
namespace af
{
class array;

/**
   C++ Interface for calculating the gradients

   \param[out] dx the gradient along first dimension
   \param[out] dy the gradient along second dimension
   \param[in] in is the input array

   \ingroup calc_func_grad
*/
AFAPI void grad(array& dx, array& dy, const array& in);

/**
    C++ Interface for loading an image

    \param[in] filename is name of file to be loaded
    \param[in] is_color boolean denoting if the image should be loaded as 1 channel or 3 channel
    \return image loaded as \ref af::array()

    \ingroup imageio_func_load
*/
AFAPI array loadImage(const char* filename, const bool is_color=false);

/**
    C++ Interface for saving an image

    \param[in] filename is name of file to be loaded
    \param[in] in is the arrayfire array to be saved as an image

    \ingroup imageio_func_save
*/
AFAPI void saveImage(const char* filename, const array& in);

#if AF_API_VERSION >= 31
/**
    C++ Interface for loading an image from memory

    \param[in] ptr is the location of the image data in memory. This is the pointer
    created by saveImage.
    \return image loaded as \ref af::array()

    \note The pointer used is a void* cast of the FreeImage type FIMEMORY which is
    created using the FreeImage_OpenMemory API. If the user is opening a FreeImage
    stream external to ArrayFire, that pointer can be passed to this function as well.

    \ingroup imagemem_func_load
*/
AFAPI array loadImageMem(const void *ptr);
#endif

#if AF_API_VERSION >= 31
/**
    C++ Interface for saving an image to memory

    \param[in] in is the arrayfire array to be saved as an image
    \param[in] format is the type of image to create in memory. The enum borrows from
    the FREE_IMAGE_FORMAT enum of FreeImage. Other values not included in imageFormat
    but included in FREE_IMAGE_FORMAT can also be passed to this function.

    \return a void* pointer which is a type cast of the FreeImage type FIMEMORY* pointer.

    \note Ensure that \ref deleteImageMem is called on this pointer. Otherwise there will
    be memory leaks

    \ingroup imagemem_func_save
*/
AFAPI void* saveImageMem(const array& in, const imageFormat format = AF_FIF_PNG);
#endif

#if AF_API_VERSION >= 31
/**
    C++ Interface for deleting memory created by \ref saveImageMem or
    \ref af_save_image_memory

    \param[in] ptr is the pointer to the FreeImage stream created by saveImageMem.

    \ingroup imagemem_func_delete
*/
AFAPI void deleteImageMem(void *ptr);
#endif

#if AF_API_VERSION >= 32
/**
    C++ Interface for loading an image as its original type

    This load image function allows you to load images as u8, u16 or f32
    depending on the type of input image as shown by the table below.

     Bits per Color (Gray/RGB/RGBA Bits Per Pixel) | Array Type  | Range
    -----------------------------------------------|-------------|---------------
      8 ( 8/24/32  BPP)                            | u8          | 0 - 255
     16 (16/48/64  BPP)                            | u16         | 0 - 65535
     32 (32/96/128 BPP)                            | f32         | 0 - 1

    \param[in] filename is name of file to be loaded
    \return image loaded as \ref af::array()

    \ingroup imageio_func_load
*/
AFAPI array loadImageNative(const char* filename);
#endif

#if AF_API_VERSION >= 32
/**
    C++ Interface for saving an image without modifications

    This function only accepts u8, u16, f32 arrays. These arrays are saved to
    images without any modifications.

    You must also note that note all image type support 16 or 32 bit images.

    The best options for 16 bit images are PNG, PPM and TIFF.
    The best option for 32 bit images is TIFF.
    These allow lossless storage.

    The images stored have the following properties:

     Array Type  | Bits per Color (Gray/RGB/RGBA Bits Per Pixel) | Range
    -------------|-----------------------------------------------|---------------
     u8          |  8 ( 8/24/32  BPP)                            | 0 - 255
     u16         | 16 (16/48/64  BPP)                            | 0 - 65535
     f32         | 32 (32/96/128 BPP)                            | 0 - 1

    \param[in] filename is name of file to be saved
    \param[in] in is the array to be saved. Should be u8 for saving 8-bit image,
    u16 for 16-bit image, and f32 for 32-bit image.

    \ingroup imageio_func_save
*/
AFAPI void saveImageNative(const char* filename, const array& in);
#endif

#if AF_API_VERSION >= 33
/**
    Function to check if Image IO is available

    \returns true if ArrayFire was commpiled with ImageIO support, false otherwise.
    \ingroup imageio_func_available
*/
AFAPI bool isImageIOAvailable();
#endif

/**
    C++ Interface for resizing an image to specified dimensions

    \param[in] in is input image
    \param[in] odim0 is the size for the first output dimension
    \param[in] odim1 is the size for the second output dimension
    \param[in] method is the interpolation type (Nearest by default)
    \return the resized image of specified by \p odim0 and \p odim1

    \ingroup transform_func_resize
*/
AFAPI array resize(const array& in, const dim_t odim0, const dim_t odim1, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for resizing an image to specified scales

    \param[in] scale0 is scale used for first input dimension
    \param[in] scale1 is scale used for second input dimension
    \param[in] in is input image
    \param[in] method is the interpolation type (Nearest by default)
    \return the image scaled by the specified by \p scale0 and \p scale1

    \ingroup transform_func_resize
*/
AFAPI array resize(const float scale0, const float scale1, const array& in, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for resizing an image to specified scale

    \param[in] scale is scale used for both input dimensions
    \param[in] in is input image
    \param[in] method is the interpolation type (Nearest by default)
    \return the image scaled by the specified by \p scale

    \ingroup transform_func_resize
*/
AFAPI array resize(const float scale, const array& in, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for rotating an image

    \param[in] in is input image
    \param[in] theta is the degree (in radians) by which the input is rotated
    \param[in] crop if true the output is cropped original dimensions. If false the output dimensions scale based on \p theta
    \param[in] method is the interpolation type (Nearest by default)
    \return the image rotated by \p theta

    \ingroup transform_func_rotate
*/
AFAPI array rotate(const array& in, const float theta, const bool crop=true, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for transforming an image

    \param[in] in is input image
    \param[in] transform is transformation matrix
    \param[in] odim0 is the first output dimension
    \param[in] odim1 is the second output dimension
    \param[in] method is the interpolation type (Nearest by default)
    \param[in] inverse if true applies inverse transform, if false applies forward transoform
    \return the transformed image

    \ingroup transform_func_transform
*/
AFAPI array transform(const array& in, const array& transform, const dim_t odim0 = 0, const dim_t odim1 = 0, const interpType method=AF_INTERP_NEAREST, const bool inverse=true);

#if AF_API_VERSION >= 33
/**
    C++ Interface for transforming coordinates

    \param[in] tf is transformation matrix
    \param[in] d0 is the first input dimension
    \param[in] d1 is the second input dimension
    \return the transformed coordinates

    \ingroup transform_func_coordinates
*/
AFAPI array transformCoordinates(const array& tf, const float d0, const float d1);
#endif

/**
    C++ Interface for translating an image

    \param[in] in is input image
    \param[in] trans0 is amount by which the first dimension is translated
    \param[in] trans1 is amount by which the second dimension is translated
    \param[in] odim0 is the first output dimension
    \param[in] odim1 is the second output dimension
    \param[in] method is the interpolation type (Nearest by default)
    \return the translated image

    \ingroup transform_func_translate
*/
AFAPI array translate(const array& in, const float trans0, const float trans1, const dim_t odim0 = 0, const dim_t odim1 = 0, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for scaling an image

    \param[in] in is input image
    \param[in] scale0 is amount by which the first dimension is scaled
    \param[in] scale1 is amount by which the second dimension is scaled
    \param[in] odim0 is the first output dimension
    \param[in] odim1 is the second output dimension
    \param[in] method is the interpolation type (Nearest by default)
    \return the scaled image

    \ingroup transform_func_scale
*/
AFAPI array scale(const array& in, const float scale0, const float scale1, const dim_t odim0 = 0, const dim_t odim1 = 0, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for skewing an image

    \param[in] in is input image
    \param[in] skew0 is amount by which the first dimension is skewed
    \param[in] skew1 is amount by which the second dimension is skewed
    \param[in] odim0 is the first output dimension
    \param[in] odim1 is the second output dimension
    \param[in] inverse if true applies inverse transform, if false applies forward transoform
    \param[in] method is the interpolation type (Nearest by default)
    \return the skewed image

    \ingroup transform_func_skew
*/
AFAPI array skew(const array& in, const float skew0, const float skew1, const dim_t odim0 = 0, const dim_t odim1 = 0, const bool inverse=true, const interpType method=AF_INTERP_NEAREST);

/**
    C++ Interface for bilateral filter

    \param[in]  in array is the input image
    \param[in]  spatial_sigma is the spatial variance parameter that decides the filter window
    \param[in]  chromatic_sigma is the chromatic variance parameter
    \param[in]  is_color indicates if the input \p in is color image or grayscale
    \return     the processed image

    \ingroup image_func_bilateral
*/
AFAPI array bilateral(const array &in, const float spatial_sigma, const float chromatic_sigma, const bool is_color=false);

/**
   C++ Interface for histogram

   \snippet test/histogram.cpp ex_image_hist_minmax

   \param[in]  in is the input array
   \param[in]  nbins  Number of bins to populate between min and max
   \param[in]  minval minimum bin value (accumulates -inf to min)
   \param[in]  maxval minimum bin value (accumulates max to +inf)
   \return     histogram array of type u32

   \ingroup image_func_histogram
 */
AFAPI array histogram(const array &in, const unsigned nbins, const double minval, const double maxval);

/**
   C++ Interface for histogram

   \snippet test/histogram.cpp ex_image_hist_nominmax

   \param[in]  in is the input array
   \param[in]  nbins  Number of bins to populate between min and max
   \return     histogram array of type u32

   \ingroup image_func_histogram
 */
AFAPI array histogram(const array &in, const unsigned nbins);

/**
    C++ Interface for mean shift

    \param[in]  in array is the input image
    \param[in]  spatial_sigma is the spatial variance parameter that decides the filter window
    \param[in]  chromatic_sigma is the chromatic variance parameter
    \param[in]  iter is the number of iterations filter operation is performed
    \param[in]  is_color indicates if the input \p in is color image or grayscale
    \return     the processed image

    \ingroup image_func_mean_shift
*/
AFAPI array meanShift(const array& in, const float spatial_sigma, const float chromatic_sigma, const unsigned iter, const bool is_color=false);

/**
    C++ Interface for median filter

    \snippet test/medfilt.cpp ex_image_medfilt

    \param[in]  in array is the input image
    \param[in]  wind_length is the kernel height
    \param[in]  wind_width is the kernel width
    \param[in]  edge_pad value will decide what happens to border when running
                filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
    \return     the processed image

    \ingroup image_func_medfilt
*/
AFAPI array medfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);

/**
    C++ Interface for minimum filter

    \param[in]  in array is the input image
    \param[in]  wind_length is the kernel height
    \param[in]  wind_width is the kernel width
    \param[in]  edge_pad value will decide what happens to border when running
                filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
    \return     the processed image

    \ingroup image_func_minfilt
*/
AFAPI array minfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);

/**
    C++ Interface for maximum filter

    \param[in]  in array is the input image
    \param[in]  wind_length is the kernel height
    \param[in]  wind_width is the kernel width
    \param[in]  edge_pad value will decide what happens to border when running
                filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
    \return     the processed image

    \ingroup image_func_maxfilt
*/
AFAPI array maxfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);

/**
    C++ Interface for image dilation (max filter)

    \param[in]  in array is the input image
    \param[in]  mask is the neighborhood window
    \return     the dilated image

    \note if \p mask is all ones, this function behaves like max filter

    \ingroup image_func_dilate
*/
AFAPI array dilate(const array& in, const array& mask);

/**
    C++ Interface for 3D image dilation

    \param[in]  in array is the input volume
    \param[in]  mask is the neighborhood delta volume
    \return     the dilated volume

    \ingroup image_func_dilate3d
*/
AFAPI array dilate3(const array& in, const array& mask);

/**
    C++ Interface for image erosion (min filter)

    \param[in]  in array is the input image
    \param[in]  mask is the neighborhood window
    \return     the eroded image

    \note This function can be used as min filter by using a mask of all ones

    \ingroup image_func_erode
*/
AFAPI array erode(const array& in, const array& mask);

/**
    C++ Interface for 3d for image erosion

    \param[in]  in array is the input volume
    \param[in]  mask is the neighborhood delta volume
    \return     the eroded volume

    \ingroup image_func_erode3d
*/
AFAPI array erode3(const array& in, const array& mask);

/**
    C++ Interface for getting regions in an image

    Below given are sample input and output for each type of connectivity value for \p type

    <table border="0">
    <tr>
    <td> Example for \p type == \ref AF_CONNECTIVITY_8 </td>
    <td> Example for \p type == \ref AF_CONNECTIVITY_4 </td>
    </tr>
    <tr>
    <td>
        \snippet test/regions.cpp ex_image_regions
    </td>
    <td>
        \snippet test/regions.cpp ex_image_regions_4conn
    </td>
    </tr>
    </table>

    \param[in]  in array should be binary image of type \ref b8
    \param[in]  connectivity can take one of the following [\ref AF_CONNECTIVITY_4 | \ref AF_CONNECTIVITY_8]
    \param[in]  type is type of output array
    \return     returns array with labels indicating different regions. Throws exceptions if any issue occur.

    \ingroup image_func_regions
*/
AFAPI array regions(const array& in, const af::connectivity connectivity=AF_CONNECTIVITY_4, const dtype type=f32);

/**
   C++ Interface for extracting sobel gradients

   \param[out] dx is derivative along horizontal direction
   \param[out] dy is derivative along vertical direction
   \param[in]  img is an array with image data
   \param[in]  ker_size sobel kernel size or window size

   \note If \p img is 3d array, a batch operation will be performed.

   \ingroup image_func_sobel
 */
AFAPI void sobel(array &dx, array &dy, const array &img, const unsigned ker_size=3);

/**
   C++ Interface for sobel filtering

   \param[in]  img is an array with image data
   \param[in]  ker_size sobel kernel size or window size
   \param[in]  isFast = true uses \f$G=G_x+G_y\f$, otherwise \f$G=\sqrt (G_x^2+G_y^2)\f$
   \return     an array with sobel gradient values

   \note If \p img is 3d array, a batch operation will be performed.

   \ingroup image_func_sobel
 */
AFAPI array sobel(const array &img, const unsigned ker_size=3, const bool isFast=false);

/**
   C++ Interface for RGB to gray conversion

   \param[in]  in is an array in the RGB colorspace
   \param[in]  rPercent is percentage of red channel value contributing to grayscale intensity
   \param[in]  gPercent is percentage of green channel value contributing to grayscale intensity
   \param[in]  bPercent is percentage of blue channel value contributing to grayscale intensity
   \return     array in Grayscale colorspace

   \note \p in must be three dimensional for RGB to Grayscale conversion.

   \ingroup image_func_rgb2gray
 */
AFAPI array rgb2gray(const array& in, const float rPercent=0.2126f, const float gPercent=0.7152f, const float bPercent=0.0722f);

/**
   C++ Interface for gray to RGB conversion

   \param[in]  in is an array in the Grayscale colorspace
   \param[in]  rFactor is percentage of intensity value contributing to red channel
   \param[in]  gFactor is percentage of intensity value contributing to green channel
   \param[in]  bFactor is percentage of intensity value contributing to blue channel
   \return     array in RGB colorspace

   \note \p in must be two dimensional for Grayscale to RGB conversion.

   \ingroup image_func_gray2rgb
 */
AFAPI array gray2rgb(const array& in, const float rFactor=1.0, const float gFactor=1.0, const float bFactor=1.0);

/**
   C++ Interface for histogram equalization

   \snippet test/histogram.cpp ex_image_histequal

   \param[in]  in is the input array, non-normalized input (!! assumes values [0-255] !!)
   \param[in]  hist target histogram to approximate in output (based on number of bins)
   \return     data with histogram approximately equal to histogram

   \note \p in must be two dimensional.

   \ingroup image_func_histequal
 */
AFAPI array histEqual(const array& in, const array& hist);

/**
   C++ Interface for generating gausian kernels

   \param[in]  rows number of rows of the kernel
   \param[in]  cols number of columns of the kernel
   \param[in]  sig_r (default 0) (calculated internally as 0.25 * rows + 0.75)
   \param[in]  sig_c (default 0) (calculated internally as 0.25 * cols + 0.75)
   \return     an array with values generated using gaussian function

   \ingroup image_func_gauss
 */
AFAPI array gaussianKernel(const int rows, const int cols, const double sig_r = 0, const double sig_c = 0);

/**
   C++ Interface for converting HSV to RGB

   \param[in]  in is an array in the HSV colorspace
   \return     array in RGB colorspace

   \note \p in must be three dimensional

   \ingroup image_func_hsv2rgb
 */
AFAPI array hsv2rgb(const array& in);

/**
   C++ Interface for converting RGB to HSV

   \param[in]  in is an array in the RGB colorspace
   \return     array in HSV colorspace

   \note \p in must be three dimensional

   \ingroup image_func_rgb2hsv
 */
AFAPI array rgb2hsv(const array& in);

/**
   C++ Interface wrapper for colorspace conversion

   \param[in]  image is the input array
   \param[in]  to is the target array colorspace
   \param[in]  from is the input array colorspace
   \return     array in target colorspace

   \note  \p image must be 3 dimensional for \ref AF_HSV to \ref AF_RGB, \ref AF_RGB to
   \ref AF_HSV, & \ref AF_RGB to \ref AF_GRAY transformations. For \ref AF_GRAY to \ref AF_RGB
   transformation, 2D array is expected.

   \ingroup image_func_colorspace
 */
AFAPI array colorSpace(const array& image, const CSpace to, const CSpace from);

#if AF_API_VERSION >= 31
/**
   C++ Interface wrapper for unwrap

   \param[in]  in is the input image (or set of images)
   \param[in]  wx is the block window size along 0th-dimension between [1, input.dims[0] + px]
   \param[in]  wy is the block window size along 1st-dimension between [1, input.dims[1] + py]
   \param[in]  sx is the stride along 0th-dimension
   \param[in]  sy is the stride along 1st-dimension
   \param[in]  px is the padding along 0th-dimension between [0, wx). Padding is applied both before and after.
   \param[in]  py is the padding along 1st-dimension between [0, wy). Padding is applied both before and after.
   \param[in]  is_column specifies the layout for the unwrapped patch. If is_column is false, the unrapped patch is laid out as a row.
   \returns    an array with the image blocks as rows or columns

   \ingroup image_func_unwrap
*/
AFAPI array unwrap(const array& in, const dim_t wx, const dim_t wy,
                   const dim_t sx, const dim_t sy, const dim_t px=0, const dim_t py=0,
                   const bool is_column = true);
#endif

#if AF_API_VERSION >= 31
/**
   C++ Interface wrapper for wrap

   \param[in]  in is the input image (or set of images)
   \param[in]  ox is the 0th-dimension of output
   \param[in]  oy is the ist-dimension of output
   \param[in]  wx is the block window size along 0th-dimension between
   \param[in]  wy is the block window size along 1st-dimension between
   \param[in]  sx is the stride along 0th-dimension
   \param[in]  sy is the stride along 1st-dimension
   \param[in]  px is the padding used along 0th-dimension between [0, wx).
   \param[in]  py is the padding used along 1st-dimension between [0, wy).
   \param[in]  is_column specifies the layout for the unwrapped patch. If is_column is false, the rows are treated as patches
   \returns    an array of images after converting rows or columns into image windows

   \ingroup image_func_wrap
*/
AFAPI array wrap(const array& in,
                 const dim_t ox, const dim_t oy,
                 const dim_t wx, const dim_t wy,
                 const dim_t sx, const dim_t sy,
                 const dim_t px = 0, const dim_t py = 0,
                 const bool is_column = true);
#endif

#if AF_API_VERSION >= 31
/**
   C++ Interface wrapper for summed area tables

   \param[in]  in is the input array
   \returns the summed area table of input image

   \ingroup image_func_sat
*/
AFAPI array sat(const array& in);
#endif

#if AF_API_VERSION >= 31
/**
   C++ Interface for converting YCbCr to RGB

   \param[in]  in is an array in the YCbCr colorspace
   \param[in]  standard specifies the ITU-R BT "xyz" standard which determines the Kb, Kr values
   used in colorspace conversion equation
   \return     array in RGB colorspace

   \note \p in must be three dimensional and values should lie in the range [0,1]

   \ingroup image_func_ycbcr2rgb
 */
AFAPI array ycbcr2rgb(const array& in, const YCCStd standard=AF_YCC_601);
#endif

#if AF_API_VERSION >= 31
/**
   C++ Interface for converting RGB to YCbCr

   \param[in]  in is an array in the RGB colorspace
   \param[in]  standard specifies the ITU-R BT "xyz" standard which determines the Kb, Kr values
   used in colorspace conversion equation
   \return     array in YCbCr colorspace

   \note \p in must be three dimensional and values should lie in the range [0,1]

   \ingroup image_func_rgb2ycbcr
 */
AFAPI array rgb2ycbcr(const array& in, const YCCStd standard=AF_YCC_601);
#endif

}
#endif

#ifdef __cplusplus
extern "C" {
#endif

    /**
        C Interface for calculating the gradients

        \param[out] dx the gradient along first dimension
        \param[out] dy the gradient along second dimension
        \param[in]  in is the input array
        \return     \ref AF_SUCCESS if the color transformation is successful,
        otherwise an appropriate error code is returned.

        \ingroup calc_func_grad
    */
    AFAPI af_err af_gradient(af_array *dx, af_array *dy, const af_array in);

    /**
        C Interface for loading an image

        \param[out] out will contain the image
        \param[in] filename is name of file to be loaded
        \param[in] isColor boolean denoting if the image should be loaded as 1 channel or 3 channel
        \return     \ref AF_SUCCESS if the color transformation is successful,
        otherwise an appropriate error code is returned.

        \ingroup imageio_func_load
    */
    AFAPI af_err af_load_image(af_array *out, const char* filename, const bool isColor);

    /**
        C Interface for saving an image

        \param[in] filename is name of file to be loaded
        \param[in] in is the arrayfire array to be saved as an image
        \return     \ref AF_SUCCESS if the color transformation is successful,
        otherwise an appropriate error code is returned.

        \ingroup imageio_func_save
    */
    AFAPI af_err af_save_image(const char* filename, const af_array in);

#if AF_API_VERSION >= 31
    /**
        C Interface for loading an image from memory

        \param[out] out is an array that will contain the image
        \param[in] ptr is the FIMEMORY pointer created by either saveImageMem function, the
        af_save_image_memory function, or the FreeImage_OpenMemory API.
        \return     \ref AF_SUCCESS if successful

        \ingroup imagemem_func_load
    */
    AFAPI af_err af_load_image_memory(af_array *out, const void* ptr);
#endif

#if AF_API_VERSION >= 31
    /**
        C Interface for saving an image to memory using FreeImage

        \param[out] ptr is the FIMEMORY pointer created by FreeImage.
        \param[in] in is the arrayfire array to be saved as an image
        \param[in] format is the type of image to create in memory. The enum borrows from
        the FREE_IMAGE_FORMAT enum of FreeImage. Other values not included in af_image_format
        but included in FREE_IMAGE_FORMAT can also be passed to this function.
        \return     \ref AF_SUCCESS if successful.

        \ingroup imagemem_func_save
    */
    AFAPI af_err af_save_image_memory(void** ptr, const af_array in, const af_image_format format);
#endif

#if AF_API_VERSION >= 31
    /**
        C Interface for deleting an image from memory

        \param[in] ptr is the FIMEMORY pointer created by either saveImageMem function, the
        af_save_image_memory function, or the FreeImage_OpenMemory API.
        \return     \ref AF_SUCCESS if successful

        \ingroup imagemem_func_delete
    */
    AFAPI af_err af_delete_image_memory(void* ptr);
#endif

#if AF_API_VERSION >= 32
    /**
        C Interface for loading an image as is original type

        This load image function allows you to load images as u8, u16 or f32
        depending on the type of input image as shown by the table below.

         Bits per Color (Gray/RGB/RGBA Bits Per Pixel) | Array Type  | Range
        -----------------------------------------------|-------------|---------------
          8 ( 8/24/32  BPP)                            | u8          | 0 - 255
         16 (16/48/64  BPP)                            | u16         | 0 - 65535
         32 (32/96/128 BPP)                            | f32         | 0 - 1

        \param[out] out contains them image
        \param[in] filename is name of file to be loaded
        \return     \ref AF_SUCCESS if successful

        \ingroup imageio_func_load
    */
    AFAPI af_err af_load_image_native(af_array *out, const char* filename);
#endif

#if AF_API_VERSION >= 32
    /**
        C Interface for saving an image without modifications

        This function only accepts u8, u16, f32 arrays. These arrays are saved to
        images without any modifications.

        You must also note that note all image type support 16 or 32 bit images.

        The best options for 16 bit images are PNG, PPM and TIFF.
        The best option for 32 bit images is TIFF.
        These allow lossless storage.

        The images stored have the following properties:

         Array Type  | Bits per Color (Gray/RGB/RGBA Bits Per Pixel) | Range
        -------------|-----------------------------------------------|---------------
         u8          |  8 ( 8/24/32  BPP)                            | 0 - 255
         u16         | 16 (16/48/64  BPP)                            | 0 - 65535
         f32         | 32 (32/96/128 BPP)                            | 0 - 1

        \param[in] filename is name of file to be saved
        \param[in] in is the array to be saved. Should be u8 for saving 8-bit image,
        u16 for 16-bit image, and f32 for 32-bit image.

        \return     \ref AF_SUCCESS if successful

        \ingroup imageio_func_save
    */
    AFAPI af_err af_save_image_native(const char* filename, const af_array in);
#endif

#if AF_API_VERSION >= 33
    /**
        Function to check if Image IO is available

        \param[out] out is true if ArrayFire was commpiled with ImageIO support,
        false otherwise.

        \return     \ref AF_SUCCESS if successful

        \ingroup imageio_func_available
    */
    AFAPI af_err af_is_image_io_available(bool *out);
#endif

    /**
       C Interface for resizing an image to specified dimensions

       \param[out] out will contain the resized image of specified by \p odim0 and \p odim1
       \param[in] in is input image
       \param[in] odim0 is the size for the first output dimension
       \param[in] odim1 is the size for the second output dimension
       \param[in] method is the interpolation type (Nearest by default)

       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup transform_func_resize
    */
    AFAPI af_err af_resize(af_array *out, const af_array in, const dim_t odim0, const dim_t odim1, const af_interp_type method);

    /**
       C Interface for transforming an image

       \param[out] out will contain the transformed image
       \param[in] in is input image
       \param[in] transform is transformation matrix
       \param[in] odim0 is the first output dimension
       \param[in] odim1 is the second output dimension
       \param[in] method is the interpolation type (Nearest by default)
       \param[in] inverse if true applies inverse transform, if false applies forward transoform
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup transform_func_transform
    */
    AFAPI af_err af_transform(af_array *out, const af_array in, const af_array transform,
                              const dim_t odim0, const dim_t odim1,
                              const af_interp_type method, const bool inverse);

#if AF_API_VERSION >= 33
    /**
       C Interface for transforming an image
       C++ Interface for transforming coordinates

       \param[out] out the transformed coordinates
       \param[in] tf is transformation matrix
       \param[in] d0 is the first input dimension
       \param[in] d1 is the second input dimension

       \ingroup transform_func_coordinates
    */
    AFAPI af_err af_transform_coordinates(af_array *out, const af_array tf, const float d0, const float d1);
#endif

    /**
       C Interface for rotating an image

       \param[out] out will contain the image \p in rotated by \p theta
       \param[in] in is input image
       \param[in] theta is the degree (in radians) by which the input is rotated
       \param[in] crop if true the output is cropped original dimensions. If false the output dimensions scale based on \p theta
       \param[in] method is the interpolation type (Nearest by default)
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup transform_func_rotate
    */
    AFAPI af_err af_rotate(af_array *out, const af_array in, const float theta,
                           const bool crop, const af_interp_type method);
   /**
      C Interface for translate an image

      \param[out] out will contain the translated image
      \param[in] in is input image
      \param[in] trans0 is amount by which the first dimension is translated
      \param[in] trans1 is amount by which the second dimension is translated
      \param[in] odim0 is the first output dimension
      \param[in] odim1 is the second output dimension
      \param[in] method is the interpolation type (Nearest by default)
      \return     \ref AF_SUCCESS if the color transformation is successful,
      otherwise an appropriate error code is returned.

      \ingroup transform_func_translate
   */
    AFAPI af_err af_translate(af_array *out, const af_array in, const float trans0, const float trans1,
                              const dim_t odim0, const dim_t odim1, const af_interp_type method);
    /**
       C Interface for scaling an image

       \param[out] out will contain the scaled image
       \param[in] in is input image
       \param[in] scale0 is amount by which the first dimension is scaled
       \param[in] scale1 is amount by which the second dimension is scaled
       \param[in] odim0 is the first output dimension
       \param[in] odim1 is the second output dimension
       \param[in] method is the interpolation type (Nearest by default)
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup transform_func_scale
    */
    AFAPI af_err af_scale(af_array *out, const af_array in, const float scale0, const float scale1,
                          const dim_t odim0, const dim_t odim1, const af_interp_type method);
    /**
       C Interface for skewing an image

       \param[out] out will contain the skewed image
       \param[in] in is input image
       \param[in] skew0 is amount by which the first dimension is skewed
       \param[in] skew1 is amount by which the second dimension is skewed
       \param[in] odim0 is the first output dimension
       \param[in] odim1 is the second output dimension
       \param[in] inverse if true applies inverse transform, if false applies forward transoform
       \param[in] method is the interpolation type (Nearest by default)
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup transform_func_skew
    */
    AFAPI af_err af_skew(af_array *out, const af_array in, const float skew0, const float skew1,
                         const dim_t odim0, const dim_t odim1, const af_interp_type method,
                         const bool inverse);

    /**
       C Interface for histogram

       \param[out] out (type u32) is the histogram for input array in
       \param[in]  in is the input array
       \param[in]  nbins  Number of bins to populate between min and max
       \param[in]  minval minimum bin value (accumulates -inf to min)
       \param[in]  maxval minimum bin value (accumulates max to +inf)
       \return     \ref AF_SUCCESS if the histogram is successfully created,
       otherwise an appropriate error code is returned.

       \ingroup image_func_histogram
     */
    AFAPI af_err af_histogram(af_array *out, const af_array in, const unsigned nbins, const double minval, const double maxval);

    /**
        C Interface for image dilation (max filter)

        \param[out] out array is the dilated image
        \param[in]  in array is the input image
        \param[in]  mask is the neighborhood window
        \return     \ref AF_SUCCESS if the dilated successfully,
        otherwise an appropriate error code is returned.

        \note if \p mask is all ones, this function behaves like max filter

        \ingroup image_func_dilate
    */
    AFAPI af_err af_dilate(af_array *out, const af_array in, const af_array mask);

    /**
        C Interface for 3d image dilation

        \param[out] out array is the dilated volume
        \param[in]  in array is the input volume
        \param[in]  mask is the neighborhood delta volume
        \return     \ref AF_SUCCESS if the dilated successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_dilate3d
    */
    AFAPI af_err af_dilate3(af_array *out, const af_array in, const af_array mask);

    /**
        C Interface for image erosion (min filter)

        \param[out] out array is the eroded image
        \param[in]  in array is the input image
        \param[in]  mask is the neighborhood window
        \return     \ref AF_SUCCESS if the eroded successfully,
        otherwise an appropriate error code is returned.

        \note if \p mask is all ones, this function behaves like min filter

        \ingroup image_func_erode
    */
    AFAPI af_err af_erode(af_array *out, const af_array in, const af_array mask);

    /**
        C Interface for 3D image erosion

        \param[out] out array is the eroded volume
        \param[in]  in array is the input volume
        \param[in]  mask is the neighborhood delta volume
        \return     \ref AF_SUCCESS if the eroded successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_erode3d
    */
    AFAPI af_err af_erode3(af_array *out, const af_array in, const af_array mask);

    /**
        C Interface for bilateral filter

        \param[out] out array is the processed image
        \param[in]  in array is the input image
        \param[in]  spatial_sigma is the spatial variance parameter that decides the filter window
        \param[in]  chromatic_sigma is the chromatic variance parameter
        \param[in]  isColor indicates if the input \p in is color image or grayscale
        \return     \ref AF_SUCCESS if the filter is applied successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_bilateral
    */
    AFAPI af_err af_bilateral(af_array *out, const af_array in, const float spatial_sigma, const float chromatic_sigma, const bool isColor);

    /**
        C Interface for mean shift

        \param[out] out array is the processed image
        \param[in]  in array is the input image
        \param[in]  spatial_sigma is the spatial variance parameter that decides the filter window
        \param[in]  chromatic_sigma is the chromatic variance parameter
        \param[in]  iter is the number of iterations filter operation is performed
        \param[in]  is_color indicates if the input \p in is color image or grayscale
        \return     \ref AF_SUCCESS if the filter is applied successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_mean_shift
    */
    AFAPI af_err af_mean_shift(af_array *out, const af_array in, const float spatial_sigma, const float chromatic_sigma, const unsigned iter, const bool is_color);

    /**
        C Interface for median filter

        \param[out] out array is the processed image
        \param[in]  in array is the input image
        \param[in]  wind_length is the kernel height
        \param[in]  wind_width is the kernel width
        \param[in]  edge_pad value will decide what happens to border when running
                    filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
        \return     \ref AF_SUCCESS if the median filter is applied successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_medfilt
    */
    AFAPI af_err af_medfilt(af_array *out, const af_array in, const dim_t wind_length, const dim_t wind_width, const af_border_type edge_pad);

    /**
        C Interface for minimum filter

        \param[out] out array is the processed image
        \param[in]  in array is the input image
        \param[in]  wind_length is the kernel height
        \param[in]  wind_width is the kernel width
        \param[in]  edge_pad value will decide what happens to border when running
                    filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
        \return     \ref AF_SUCCESS if the minimum filter is applied successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_minfilt
    */
    AFAPI af_err af_minfilt(af_array *out, const af_array in, const dim_t wind_length, const dim_t wind_width, const af_border_type edge_pad);

    /**
       C Interface for maximum filter

       \param[out] out array is the processed image
       \param[in]  in array is the input image
       \param[in]  wind_length is the kernel height
       \param[in]  wind_width is the kernel width
       \param[in]  edge_pad value will decide what happens to border when running
       filter in their neighborhood. It takes one of the values [\ref AF_PAD_ZERO | \ref AF_PAD_SYM]
       \return     \ref AF_SUCCESS if the maximum filter is applied successfully,
       otherwise an appropriate error code is returned.

       \ingroup image_func_maxfilt
    */
    AFAPI af_err af_maxfilt(af_array *out, const af_array in, const dim_t wind_length, const dim_t wind_width, const af_border_type edge_pad);

    /**
        C Interface for regions in an image

        \param[out] out array will have labels indicating different regions
        \param[in]  in array should be binary image of type \ref b8
        \param[in]  connectivity can take one of the following [\ref AF_CONNECTIVITY_4 | \ref AF_CONNECTIVITY_8]
        \param[in]  ty is type of output array
        \return     \ref AF_SUCCESS if the regions are identified successfully,
        otherwise an appropriate error code is returned.

        \ingroup image_func_regions
    */
    AFAPI af_err af_regions(af_array *out, const af_array in, const af_connectivity connectivity, const af_dtype ty);

    /**
       C Interface for getting sobel gradients

       \param[out] dx is derivative along horizontal direction
       \param[out] dy is derivative along vertical direction
       \param[in]  img is an array with image data
       \param[in]  ker_size sobel kernel size or window size
       \return     \ref AF_SUCCESS if sobel derivatives are computed successfully,
       otherwise an appropriate error code is returned.

       \note If \p img is 3d array, a batch operation will be performed.

       \ingroup image_func_sobel
    */
    AFAPI af_err af_sobel_operator(af_array *dx, af_array *dy, const af_array img, const unsigned ker_size);

    /**
       C Interface for converting RGB to gray

       \param[out] out is an array in target color space
       \param[in]  in is an array in the RGB color space
       \param[in]  rPercent is percentage of red channel value contributing to grayscale intensity
       \param[in]  gPercent is percentage of green channel value contributing to grayscale intensity
       \param[in]  bPercent is percentage of blue channel value contributing to grayscale intensity
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be three dimensional for RGB to Grayscale conversion.

       \ingroup image_func_rgb2gray
    */
    AFAPI af_err af_rgb2gray(af_array* out, const af_array in, const float rPercent, const float gPercent, const float bPercent);

    /**
       C Interface for converting gray to RGB

       \param[out] out is an array in target color space
       \param[in]  in is an array in the Grayscale color space
       \param[in]  rFactor is percentage of intensity value contributing to red channel
       \param[in]  gFactor is percentage of intensity value contributing to green channel
       \param[in]  bFactor is percentage of intensity value contributing to blue channel
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be two dimensional for Grayscale to RGB conversion.

       \ingroup image_func_gray2rgb
    */
    AFAPI af_err af_gray2rgb(af_array* out, const af_array in, const float rFactor, const float gFactor, const float bFactor);

    /**
       C Interface for histogram equalization

       \param[out] out is an array with data that has histogram approximately equal to histogram
       \param[in]  in is the input array, non-normalized input (!! assumes values [0-255] !!)
       \param[in]  hist target histogram to approximate in output (based on number of bins)
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be two dimensional.

       \ingroup image_func_histequal
    */
    AFAPI af_err af_hist_equal(af_array *out, const af_array in, const af_array hist);

    /**
       C Interface generating gaussian kernels

       \param[out] out is an array with values generated using gaussian function
       \param[in]  rows number of rows of the gaussian kernel
       \param[in]  cols number of columns of the gaussian kernel
       \param[in]  sigma_r (default 0) (calculated internally as 0.25 * rows + 0.75)
       \param[in]  sigma_c (default 0) (calculated internally as 0.25 * cols + 0.75)
       \return     \ref AF_SUCCESS if gaussian distribution values are generated successfully,
       otherwise an appropriate error code is returned.

       \ingroup image_func_gauss
    */
    AFAPI af_err af_gaussian_kernel(af_array *out,
                                    const int rows, const int cols,
                                    const double sigma_r, const double sigma_c);

    /**
       C Interface for converting HSV to RGB

       \param[out] out is an array in the RGB color space
       \param[in]  in is an array in the HSV color space
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be three dimensional

       \ingroup image_func_hsv2rgb
    */
    AFAPI af_err af_hsv2rgb(af_array* out, const af_array in);

    /**
       C Interface for converting RGB to HSV

       \param[out] out is an array in the HSV color space
       \param[in]  in is an array in the RGB color space
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be three dimensional

       \ingroup image_func_rgb2hsv
    */
    AFAPI af_err af_rgb2hsv(af_array* out, const af_array in);

    /**
       C Interface wrapper for color space conversion

       \param[out] out is an array in target color space
       \param[in]  image is the input array
       \param[in]  to is the target array color space \param[in]
       from is the input array color space
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code
       is returned.

       \note  \p image must be 3 dimensional for \ref AF_HSV to \ref AF_RGB, \ref
       AF_RGB to \ref AF_HSV, & \ref AF_RGB to \ref AF_GRAY transformations.
       For \ref AF_GRAY to \ref AF_RGB transformation, 2D array is expected.

       \ingroup image_func_colorspace
    */
    AFAPI af_err af_color_space(af_array *out, const af_array image, const af_cspace_t to, const af_cspace_t from);

#if AF_API_VERSION >= 31
    /**
       C Interface wrapper for unwrap

       \param[out] out is an array with image blocks as rows or columns.
       \param[in]  in is the input image (or set of images)
       \param[in]  wx is the block window size along 0th-dimension between [1, input.dims[0] + px]
       \param[in]  wy is the block window size along 1st-dimension between [1, input.dims[1] + py]
       \param[in]  sx is the stride along 0th-dimension
       \param[in]  sy is the stride along 1st-dimension
       \param[in]  px is the padding along 0th-dimension between [0, wx). Padding is applied both before and after.
       \param[in]  py is the padding along 1st-dimension between [0, wy). Padding is applied both before and after.
       \param[in]  is_column specifies the layout for the unwrapped patch. If is_column is false, the unrapped patch is laid out as a row.
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \ingroup image_func_unwrap
    */
    AFAPI af_err af_unwrap(af_array *out, const af_array in, const dim_t wx, const dim_t wy,
                           const dim_t sx, const dim_t sy, const dim_t px, const dim_t py,
                           const bool is_column);
#endif

#if AF_API_VERSION >= 31
    /**
       C Interface wrapper for wrap

       \param[out] out is an array after converting
       \param[in]  in is the input array
       \param[in]  ox is the 0th-dimension of \p out
       \param[in]  oy is the ist-dimension of \p out
       \param[in]  wx is the block window size along 0th-dimension between
       \param[in]  wy is the block window size along 1st-dimension between
       \param[in]  sx is the stride along 0th-dimension
       \param[in]  sy is the stride along 1st-dimension
       \param[in]  px is the padding used along 0th-dimension between [0, wx).
       \param[in]  py is the padding used along 1st-dimension between [0, wy).
       \param[in]  is_column specifies the layout for the unwrapped patch. If is_column is false, the rows are treated as the patches
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note The padding used in \ref af_unwrap is calculated from the provided parameters

       \ingroup image_func_wrap
    */
    AFAPI af_err af_wrap(af_array *out,
                         const af_array in,
                         const dim_t ox, const dim_t oy,
                         const dim_t wx, const dim_t wy,
                         const dim_t sx, const dim_t sy,
                         const dim_t px, const dim_t py,
                         const bool is_column);
#endif

#if AF_API_VERSION >= 31
    /**
       C Interface wrapper for summed area tables

       \param[out] out is the summed area table on input image(s)
       \param[in]  in is the input array
       \return \ref AF_SUCCESS if the sat computation is successful,
       otherwise an appropriate error code is returned.

       \ingroup image_func_sat
    */
    AFAPI af_err af_sat(af_array *out, const af_array in);
#endif

#if AF_API_VERSION >= 31
    /**
       C Interface for converting YCbCr to RGB

       \param[out] out is an array in the RGB color space
       \param[in]  in is an array in the YCbCr color space
       \param[in]  standard specifies the ITU-R BT "xyz" standard which determines the Kb, Kr values
       used in colorspace conversion equation
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be three dimensional and values should lie in the range [0,1]

       \ingroup image_func_ycbcr2rgb
    */
    AFAPI af_err af_ycbcr2rgb(af_array* out, const af_array in, const af_ycc_std standard);
#endif

#if AF_API_VERSION >= 31
    /**
       C Interface for converting RGB to YCbCr

       \param[out] out is an array in the YCbCr color space
       \param[in]  in is an array in the RGB color space
       \param[in]  standard specifies the ITU-R BT "xyz" standard which determines the Kb, Kr values
       used in colorspace conversion equation
       \return     \ref AF_SUCCESS if the color transformation is successful,
       otherwise an appropriate error code is returned.

       \note \p in must be three dimensional and values should lie in the range [0,1]

       \ingroup image_func_rgb2ycbcr
    */
    AFAPI af_err af_rgb2ycbcr(af_array* out, const af_array in, const af_ycc_std standard);
#endif
#ifdef __cplusplus
}
#endif