File: image.dox

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 (833 lines) | stat: -rw-r--r-- 28,220 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

/*!
\page image_func_hsv HSV

HSV (Hue, Saturation, Value), also known as HSB (hue, saturation, brightness),
is often used by artists because it is more natural to think about a color in
terms of hue and saturation than in terms of additive or subtractive color
components (as in RGB). HSV is a transformation of RGB colorspace; its
components and colorimetry are relative to the RGB colorspace from which it was
derived. Like RGB, HSV also uses 3 values per pixel.

\page image_func_rgb RGB

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB
stores individual values for red, green and blue, and hence the 3 values per
pixel. A combination of these three values produces the gamut of unique colors.

\page image_func_gray GRAY

Grayscale is a single channel color space where pixel value ranges from 0 to 1.
Zero represents black, one represent white and any value between zero & one is
a gray value

\page image_func_ycbcr YCbCr

YCbCr is a family of color spaces used as a part of the color image pipeline in video
and digital photography systems where Y is luma component and Cb & Cr are the blue-difference
and red-difference chroma components.

*/
//=================================================================================
/**

\addtogroup  arrayfire_func
@{

\defgroup image_func_colorspace colorspace
\ingroup colorconv_mat

Colorspace conversion function

\copydoc image_func_rgb
\copydoc image_func_hsv
\copydoc image_func_gray

Supported conversions

| From     | To      |
|:--------:|:-------:|
| AF_RGB   | AF_GRAY |
| AF_GRAY  | AF_RGB  |
| AF_RGB   | AF_HSV  |
| AF_HSV   | AF_RGB  |

=======================================================================

\defgroup image_func_rgb2hsv rgb2hsv
\ingroup colorconv_mat

RGB to HSV colorspace converter

\copydoc image_func_rgb
\copydoc image_func_hsv

=======================================================================

\defgroup image_func_hsv2rgb hsv2rgb
\ingroup colorconv_mat

HSV to RGB colorspace converter

\copydoc image_func_hsv
\copydoc image_func_rgb

=======================================================================

\defgroup image_func_rgb2gray rgb2gray
\ingroup colorconv_mat

RGB to Grayscale colorspace converter

\copydoc image_func_rgb
\copydoc image_func_gray

The grayscale internsity of a pixel is calculated using the
following formula:

    \f$gray = R*rPercent + G*gPercent + B*bPercent\f$

=======================================================================

\defgroup image_func_gray2rgb gray2rgb
\ingroup colorconv_mat

Grayscale to RGB colorspace converter

\copydoc image_func_gray
\copydoc image_func_rgb

The grayscale internsity of a pixel is calculated using the
following formula

       \f$R = rFactor * intensity\f$

       \f$G = gFactor * intensity\f$

       \f$B = bFactor * intensity\f$

=======================================================================

\defgroup image_func_rgb2ycbcr rgb2ycbcr
\ingroup colorconv_mat

RGB to YCbCr colorspace converter

\copydoc image_func_rgb
\copydoc image_func_ycbcr

Input array to this function should be of real data in the range \f$[0,1]\f$.

The following equations are used to convert image from RGB color space to YCbCr color space.

\f$ Y  = 16 + \displaystyle k_r*R + (1 - \displaystyle k_r- \displaystyle k_b)*G + \displaystyle k_b * B \f$

\f$ Cb =  128 + \frac{\displaystyle 1}{\displaystyle 2} * \frac{\displaystyle B - Y\displaystyle
}{\displaystyle 1 - \displaystyle k_b} \f$

\f$ Cr =  128 + \frac{\displaystyle 1}{\displaystyle 2} * \frac{\displaystyle R - Y\displaystyle
}{\displaystyle 1 - \displaystyle k_r} \f$

Output image in YCbCr has following range for their respective channels.

\f$Y -> [16, 219]\f$

\f$Cb-> [16, 240]\f$

\f$Cr-> [16, 240]\f$

Based on the ITU-R BT.xyz[w] standard used, different values of \f$k_b\f$ and \f$k_r\f$ are used
to do the color space conversion. You can change these values by passing the \ref af_ycc_std enum
value.

=======================================================================

\defgroup image_func_ycbcr2rgb ycbcr2rgb
\ingroup colorconv_mat

YCbCr to RGB colorspace converter

\copydoc image_func_ycbcr
\copydoc image_func_rgb

Input array to this function should be of real data with the following range in
their respective channels.

\f$Y -> [16, 219]\f$

\f$Cb-> [16, 240]\f$

\f$Cr-> [16, 240]\f$


The following equations are used to convert image from RGB color space to YCbCr color space.

\f$ R = \frac{\displaystyle Y - \displaystyle 16}{\displaystyle 219}
       + \frac{\displaystyle C_r - \displaystyle 128}{\displaystyle 112} * (\displaystyle 1 - \displaystyle k_r) \f$

\f$ G = \frac{\displaystyle Y - \displaystyle 16}{\displaystyle 219}
       - \frac{\displaystyle C_r - \displaystyle 128}{\displaystyle 112} * (\displaystyle 1 -
\displaystyle k_r) * \frac{\displaystyle k_r}{\displaystyle 1 - \displaystyle k_b - \displaystyle
k_r} - \frac{\displaystyle C_b - \displaystyle 128}{\displaystyle 112} * (\displaystyle 1 -
\displaystyle k_b) * \frac{\displaystyle k_b}{\displaystyle 1 - \displaystyle k_b - \displaystyle
k_r}\f$

\f$ B = \frac{\displaystyle Y - \displaystyle 16}{\displaystyle 219}
       + \frac{\displaystyle C_b - \displaystyle 128}{\displaystyle 112} * (\displaystyle 1 - \displaystyle k_b) \f$

Output image in RGB will have values in range \f$[0, 1]\f$.

Based on the ITU-R BT.xyz[w] standard used, different values of \f$k_b\f$ and \f$k_r\f$ are used
to do the color space conversion. You can change these values by passing the \ref af_ycc_std enum
value.

=======================================================================

\defgroup image_func_histogram histogram
\ingroup hist_mat

\brief Histogram of input data

A histogram is a representation of the distribution of given data. This
representation is essentially a graph consisting of the data range or domain on
one axis and frequency of occurence on the other axis. All the data in the
domain is counted in the appropriate bin. The total number of elements
belonging to each bin is known as the bin's frequency.

The regular histogram function creates bins of equal size between the minimum
and maximum of the input data (min and max are calculated internally). The histogram min-max
function takes input parameters minimum and maximum, and divides the bins into
equal sizes within the range specified by min and max parameters. All values
less than min in the data range are placed in the first (min) bin and all
values greater than max will be placed in the last (max) bin.

=======================================================================

\defgroup image_func_histequal histequal
\ingroup hist_mat

\brief Histogram equalization of input image

Histogram equalization is a method in image processing of contrast adjustment
using the image's histogram.

Data normalization via histogram equalization

=======================================================================

\defgroup image_func_regions regions
\ingroup connected_comps_mat

\brief Find blobs in given image.

Given a binary image (with zero representing background pixels), regions
computes a floating point image where each connected component is labeled
from 1 to N, the total number of components in the image.

A component is defined as one or more nonzero pixels that are connected by
the specified connectivity (either 4-way(\ref AF_CONNECTIVITY_4) or
8-way(\ref AF_CONNECTIVITY_8)) in two dimensions.

\image html regions_8conn.jpg "An example input and output for 8-connectivity"

The default connectivity is \ref AF_CONNECTIVITY_4.

=======================================================================

\defgroup image_func_gauss gaussiankernel
\ingroup utility_mat

\brief Creates a Gaussian Kernel

This function creates a kernel of a specified size that contains a Gaussian
distribution. This distribution is normalized to one. This is most commonly
used when performing a Gaussian blur on an image. The function takes two sets
of arguments, the size of the kernel (width and height in pixels) and the
sigma parameters (for row and column) which effect the distribution of the
weights in the y and x directions, respectively.

Changing sigma causes the weights in each direction to vary. Sigma is calculated
internally as (0.25 * rows + 0.75) for rows and similarly for columns.

=======================================================================

\defgroup image_func_sobel sobel
\ingroup imageflt_mat

\brief Sobel Operators

Sobel operators perform a 2-D spatial gradient measurement on an image
to emphasize the regions of high spatial frequency, namely edges. A more in depth
discussion on it can be found [here](http://en.wikipedia.org/wiki/Sobel_operator).

=======================================================================

\defgroup cv_func_match_template matchTemplate
\ingroup match_mat

\brief Template Matching

Template matching is an image processing technique to find small patches of an image which
match a given template image. A more in depth discussion on the topic can be found
[here](http://en.wikipedia.org/wiki/Template_matching).

=======================================================================

\defgroup image_func_medfilt medfilt
\ingroup imageflt_mat

\brief Median Filter

A median filter is similar to the arbitrary filter except that instead of a weighted sum,
the median value of the pixels covered by the kernel is returned.

=======================================================================

\defgroup image_func_minfilt minfilt
\ingroup imageflt_mat

\brief Find minimum value from a window

minfilt finds the smallest value from a 2D window and assigns it to the current pixel.

=======================================================================

\defgroup image_func_maxfilt maxfilt
\ingroup imageflt_mat

\brief Find maximum value from a window

maxfilt finds the smallest value from a 2D window and assigns it to the current pixel.

=======================================================================

\defgroup image_func_mean_shift meanshift
\ingroup imageflt_mat

\brief Meanshift Filter

A meanshift filter is an edge-preserving smoothing filter commonly used in object
tracking and image segmentation.

This filter replaces each pixel in the image with the mean of the values within a
given given color and spatial radius. The meanshift filter is an iterative algorithm
that continues until a maxium number of iterations is met or until the value of the
means no longer changes.

=======================================================================

\defgroup image_func_bilateral bilateral
\ingroup imageflt_mat

\brief Bilateral Filter

A bilateral filter is a edge-preserving filter that reduces noise in an image.
The intensity of each pixel is replaced by a weighted average of the intensities
of nearby pixels. The weights follow a Gaussian distribution and depend on the
distance as well as the color distance.

The bilateral filter requires the size of the filter (in pixels) and the upper
bound on color values, N, where pixel values range from 0–N inclusively.

The return type of the array is f64 for f64 input, f32 for all other input
types.

=======================================================================

\defgroup image_func_erode erode
\ingroup morph_mat

\brief Erosion(morphological operator) for images

The erosion function is a morphological transformation on an image that requires two inputs.
The first is the image to be morphed, and the second is the mask indicating neighborhood that
must be white in order to preserve each pixel.

In erode, for each pixel, the mask is centered at the pixel. If each pixel of the mask matches
the corresponding pixel on the image, then no change is made. If there is at least one mismatch,
then pixels are changed to the background color (black).

For further reference, see: [Erosion (morphology)](http://en.wikipedia.org/wiki/Erosion_(morphology))

Sample input and output are shown below:

<table border=0>
<tr>
<td> \image html erode_orig.png "Input Image" </td>
<td> \image html mask.png "Mask" </td>
<td> \image html erode_inter.png "Intermediate Result" </td>
<td> \image html erode.png "Output Image" </td>
</tr>
</table>



\defgroup image_func_erode3d erode3d
\ingroup morph_mat

\brief Erosion(morphological operator) for volumes

Erosion for a volume is similar to the way erosion works on an image. Only difference is
that the masking operation is performed on a volume instead of a rectangular region.

For further reference, see: [Erosion (morphology)](http://en.wikipedia.org/wiki/Erosion_(morphology))



\defgroup image_func_dilate dilate
\ingroup morph_mat

\brief Dilation(morphological operator) for images

The dilation function takes two pieces of data as inputs. The first is the input image to be
morphed, and the second is the mask indicating the neighborhood around each pixel to match.

In dilation, for each pixel, the mask is centered at the pixel. If the center pixel of the
mask matches the corresponding pixel on the image, then the mask is accepted. If the center
pixels do not matches, then the mask is ignored and no changes are made.

For further reference, see: [Dilation (morphology)](http://en.wikipedia.org/wiki/Dilation_(morphology))

Sample input and output are shown below:

<table border=0>
<tr>
<td> \image html dilate_orig.png "Input Image" </td>
<td> \image html mask.png "Mask" </td>
<td> \image html dilate_inter.png "Intermediate Result" </td>
<td> \image html dilate.png "Output Image" </td>
</tr>
</table>



\defgroup image_func_dilate3d dilate3d
\ingroup morph_mat

\brief Dilation(morphological operator) for volumes

Dilation for a volume is similar to the way dilation works on an image. Only difference is
that the masking operation is performed on a volume instead of a rectangular region.

For further reference, see: [Dilation (morphology)](http://en.wikipedia.org/wiki/Dilation_(morphology))



\defgroup imageio_func_load loadImage
\ingroup imageio_mat

Load an image from disk to an array

Supported formats include JPG, PNG, PPM and other formats supported by freeimage



\defgroup imageio_func_save saveImage
\ingroup imageio_mat

Save an array to disk as an image

Supported formats include JPG, PNG, PPM and other formats supported by freeimage


\defgroup imageio_func_available isImageIoAvailable
\ingroup imageio_mat

Returns true if ArrayFire was compiled with ImageIO (FreeImage) support


\defgroup imagemem_func_load loadImageMem
\ingroup imageio_mat

Load an image from memory which is stored as a FreeImage stream (FIMEMORY).

Supported formats include JPG, PNG, PPM and other formats supported by freeimage



\defgroup imagemem_func_save saveImageMem
\ingroup imageio_mat

Save an array to memory as an image using FreeImage stream (FIMEMORY).

Supported formats include JPG, PNG, PPM and other formats supported by freeimage


\defgroup imagemem_func_delete deleteImageMem
\ingroup imageio_mat

Delete memory created by saveImageMem and af_save_image_memory function.
This internally calls FreeImage_CloseMemory.

Supported formats include JPG, PNG, PPM and other formats supported by freeimage


\defgroup calc_func_grad grad
\ingroup calc_mat

Calculate the gradients of the input

\p dx is the gradient along the 1st dimension of \p in.
\p dy is the gradient along the 2nd dimension of \p in.

The gradients along the first and second dimensions are calculated simultaneously

\code

array in = randu(dim4(5, 3));
array dx, dy;
grad(dx, dy, in);

// in [5 3 1 1]
//  0.0000     0.2190     0.3835
//  0.1315     0.0470     0.5194
//  0.7556     0.6789     0.8310
//  0.4587     0.6793     0.0346
//  0.5328     0.9347     0.0535
//
// dx [5 3 1 1]
//  0.1315    -0.1719     0.1359
//  0.3778     0.2300     0.2237
//  0.1636     0.3161    -0.2424
// -0.1114     0.1279    -0.3888
//  0.0741     0.2554     0.0189
//
// dy [5 3 1 1]
//  0.2190     0.1917     0.1645
// -0.0845     0.1939     0.4724
// -0.0767     0.0377     0.1521
//  0.2206    -0.2120    -0.6447
//  0.4019    -0.2397    -0.8812

\endcode


\defgroup transform_func_resize resize
\ingroup transform_mat

Resize an input image

Resizing an input image can be done using either \ref AF_INTERP_NEAREST,
\ref AF_INTERP_BILINEAR or \ref AF_INTERP_LOWER, interpolations. Nearest
interpolation will pick the nearest value to the location, bilinear
interpolation will do a weighted interpolation for calculate the new size
and lower interpolation is similar to the nearest, except it will use the
floor function to get the lower neighbor.

This function does not differentiate between images and data. As long as
the array is defined and the output dimensions are not 0, it will resize any
type or size of array.

\code
array in = iota(dim4(5, 3));
af_print(resize(2, in, AF_INTERP_NEAREST));
af_print(resize(2, in, AF_INTERP_BILINEAR));

// in [5 3 1 1]
// 0.0000     5.0000    10.0000
// 1.0000     6.0000    11.0000
// 2.0000     7.0000    12.0000
// 3.0000     8.0000    13.0000
// 4.0000     9.0000    14.0000
//
// resize(2, in, AF_INTERP_NEAREST) [10 6 1 1]
// 0.0000     5.0000     5.0000    10.0000    10.0000    10.0000
// 1.0000     6.0000     6.0000    11.0000    11.0000    11.0000
// 1.0000     6.0000     6.0000    11.0000    11.0000    11.0000
// 2.0000     7.0000     7.0000    12.0000    12.0000    12.0000
// 2.0000     7.0000     7.0000    12.0000    12.0000    12.0000
// 3.0000     8.0000     8.0000    13.0000    13.0000    13.0000
// 3.0000     8.0000     8.0000    13.0000    13.0000    13.0000
// 4.0000     9.0000     9.0000    14.0000    14.0000    14.0000
// 4.0000     9.0000     9.0000    14.0000    14.0000    14.0000
// 4.0000     9.0000     9.0000    14.0000    14.0000    14.0000
//
// resize(2, in, AF_INTERP_BILINEAR) [10 6 1 1]
// 0.0000     2.5000     5.0000     7.5000    10.0000    10.0000
// 0.5000     3.0000     5.5000     8.0000    10.5000    10.5000
// 1.0000     3.5000     6.0000     8.5000    11.0000    11.0000
// 1.5000     4.0000     6.5000     9.0000    11.5000    11.5000
// 2.0000     4.5000     7.0000     9.5000    12.0000    12.0000
// 2.5000     5.0000     7.5000    10.0000    12.5000    12.5000
// 3.0000     5.5000     8.0000    10.5000    13.0000    13.0000
// 3.5000     6.0000     8.5000    11.0000    13.5000    13.5000
// 4.0000     6.5000     9.0000    11.5000    14.0000    14.0000
// 4.0000     6.5000     9.0000    11.5000    14.0000    14.0000

\endcode


\defgroup transform_func_rotate rotate
\ingroup transform_mat

Rotate an input image

The angle theta is in radians.

Rotating an input image can be done using \ref AF_INTERP_NEAREST,
\ref AF_INTERP_BILINEAR or \ref AF_INTERP_LOWER interpolations. Nearest
interpolation will pick the nearest value to the location, whereas bilinear
interpolation will do a weighted interpolation for calculate the new size.

This function does not differentiate between images and data. As long as
the array is defined, it will rotate any type or size of array.

The crop option allows you to choose whether to resize the image.
If crop is set to false, ie. the entire rotated image will be a part of the
array and the new array size will be greater than or equal to the input array
size.
If crop is set to true, then the new array size is same as the input array
size and the data that falls outside the boundaries of the array is discarded.

Any location of the rotated array that does not map to a location of the input
array is set to 0.


\defgroup transform_func_translate translate
\ingroup transform_mat

Translate an input image

Translating an image is moving it along 1st and 2nd dimensions by \p trans0
and \p trans1. Positive values of these will move the data towards negative x
and negative y whereas negative values of these will move the positive right
and positive down. See the example below for more.

To specify an output dimension, use the \p odim0 and odim1 for dim0 and dim1
respectively. The size of 2rd and 3rd dimension is same as input.
If \p odim0 and odim1 and not defined, then the output dimensions are same as
the input dimensions and the data out of bounds will be discarded.

All new values that do not map to a location of the input array are set to 0.

Translate is a special case of the \ref af::transform function.

\code
in [5 3 1 1]
0.0000     5.0000    10.0000
1.0000     6.0000    11.0000
2.0000     7.0000    12.0000
3.0000     8.0000    13.0000
4.0000     9.0000    14.0000

// Moves +1 row up and -1 column left (1 column right)
translate(in, 1, -1, 7, 5, AF_INTERP_NEAREST) [7 5 1 1]
0.0000     1.0000     6.0000    11.0000     0.0000
0.0000     2.0000     7.0000    12.0000     0.0000
0.0000     3.0000     8.0000    13.0000     0.0000
0.0000     4.0000     9.0000    14.0000     0.0000
0.0000     0.0000     0.0000     0.0000     0.0000
0.0000     0.0000     0.0000     0.0000     0.0000
0.0000     0.0000     0.0000     0.0000     0.0000

// Moves -2 row up (2 rows down) and -1 column left (1 column right)
translate(in, -2, -1, 6, 4, AF_INTERP_BILINEAR) [6 4 1 1]
0.0000     0.0000     0.0000     0.0000
0.0000     0.0000     0.0000     0.0000
0.0000     0.0000     5.0000    10.0000
0.0000     1.0000     6.0000    11.0000
0.0000     2.0000     7.0000    12.0000
0.0000     3.0000     8.0000    13.0000

\endcode

\defgroup transform_func_scale scale
\ingroup transform_mat

Scale an input image

Scale is the same functionality as \ref af::resize except that the scale function uses
the transform kernels. The other difference is that scale does not set boundary
values to be the boundary of the input array. Instead these are set to 0.

Scale is a special case of the \ref af::transform function.


\defgroup transform_func_skew skew
\ingroup transform_mat

Skew an input image

Skew function skews the input array along dim0 by \p skew0 and along dim1 by
\p skew1. The skew areguments are in radians.
Skewing the data means the data remains parallel along 1 dimensions but the
other dimensions gets moved along based on the angle.
If both \p skew0 and \p skew1 are specified, then the data will be skewed
along both directions.

Explicit output dimensions can be specified using \p odim0 and \p odim1.

All new values that do not map to a location of the input array are set to 0.

Skew is a special case of the \ref af::transform function.


\defgroup transform_func_transform transform
\ingroup transform_mat

Transform an input image

The transform function uses an affine or perspective transform matrix to tranform an input
image into a new one.

If matrix \p tf is is a 3x2 matrix, an affine transformation will be performed. The matrix
operation is applied to each location (x, y) that is then transformed to (x', y') of the
new array. Hence the transformation is an element-wise operation.

The operation is as below:\n
tf = [r00 r10\n
      r01 r11\n
      t0  t1]

x' = x * r00 + y * r01 + t0;\n
y' = x * r10 + y * r11 + t1;

If matrix \p tf is is a 3x3 matrix, a perspective transformation will be performed.

The operation is as below:\n
tf = [r00 r10 r20\n
      r01 r11 r21\n
      t0  t1  t2]

x' = (x * r00 + y * r01 + t0) / (x * r20 + y * r21 + t2);\n
y' = (x * r10 + y * r11 + t1) / (x * r20 + y * r21 + t2);

The transformation matrix \p tf should always be of type f32.

Interpolation types of \ref AF_INTERP_NEAREST, \ref AF_INTERP_BILINEAR and
AF_INTERP_LOWER are allowed.

Affine transforms can be used for various purposes. \ref af::translate, \ref af::scale and \ref af::skew
are specializations of the transform function.


\defgroup transform_func_coordinates transformcoordinates
\ingroup transform_mat

Transform input coordinates

The transform function uses a perspective transform matrix to transform input
coordinates (given as two dimensions) into a coordinates matrix.

The output is a 4x2 matrix, indicating the coordinates of the 4 bidimensional
transformed points.

=======================================================================

\defgroup image_func_sat SAT
\ingroup imageflt_mat

\brief Summed Area Tables

Given an image \f$ I: (x,y) \mapsto i \f$ where i is pixel intensity at position \f$(x, y)\f$.

\f$S(x, y) = i(x, y) + S(x-1, y) + S(x, y-1) - S(x-1, y-1)\f$

The output array of this function will have \f$ S(x, y) \f$ values at their corresponding locations, \f$(x,y)\f$

=======================================================================

\defgroup image_func_unwrap unwrap
\ingroup image_mod_mat

Generate an array with image windows as columns

unwrap takes in an input image along with the window sizes \p wx and \p
wy, strides \p sx and \p sy, and padding \p px and \p py. This function then
generates a matrix where each windows is an independent column.

The number of columns (rows if is_column is true) in the output array are govenered by the number of
windows that can be fit along x and y directions. Padding is applied along all
4 sides of the matrix with \p px defining the height of the padding along dim
0 and \p py defining the width of the padding along dim 1.

The first column window is always at the top left corner of the input including
padding. If a window cannot fit before the end of the matrix + padding, it is
skipped from the generated matrix.

Padding can take a maximum value of window - 1 repectively for x and y.

For multiple channels (3rd and 4th dimension), the generated matrix contains
the same number of channels as the input matrix. Each channel of the output
matrix corresponds to the same channel of the input.

So the dimensions of the output matrix are:
\code
[(wx * wy),         // Column height
 (No. of windows along dim 0 of input * No. of windows along dim 1 of input), // No. of columns per channel
 input.dims()[2],   // Channels
 input.dims()[3]]   // Volumns
\endcode

When strides are 1, the operation is sliding window. When strides are equal to
the respective window sizes, the option is distinct window. Other stride
values are also allowed.

\code
A [5 5 1 1]
10 15 20 25 30
11 16 21 26 31
12 17 22 27 32
13 18 23 28 33
14 19 24 29 34

// Window 3x3, strides 1x1, padding 0x0
unwrap(A, 3, 3, 1, 1, 0, 0) [9 9 1 1]
10 11 12 15 16 17 20 21 22
11 12 13 16 17 18 21 22 23
12 13 14 17 18 19 22 23 24
15 16 17 20 21 22 25 26 27
16 17 18 21 22 23 26 27 28
17 18 19 22 23 24 27 28 29
20 21 22 25 26 27 30 31 32
21 22 23 26 27 28 31 32 33
22 23 24 27 28 29 32 33 34

// Window 3x3, strides 1x1, padding 1x1
unwrap(A, 3, 3, 1, 1, 1, 1) [9 25 1 1]
 0  0  0  0  0  0 10 11 12 13  0 15 16 17 18  0 20 21 22 23  0 25 26 27 28
 0  0  0  0  0 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 0  0  0  0  0 11 12 13 14  0 16 17 18 19  0 21 22 23 24  0 26 27 28 29  0
 0 10 11 12 13  0 15 16 17 18  0 20 21 22 23  0 25 26 27 28  0 30 31 32 33
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
11 12 13 14  0 16 17 18 19  0 21 22 23 24  0 26 27 28 29  0 31 32 33 34  0
 0 15 16 17 18  0 20 21 22 23  0 25 26 27 28  0 30 31 32 33  0  0  0  0  0
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  0  0  0  0  0
16 17 18 19  0 21 22 23 24  0 26 27 28 29  0 31 32 33 34  0  0  0  0  0  0

// Window 3x3, strides 3x3 ("distinct"), padding 0x0
unwrap(A, 3, 3, 3, 3, 0, 0) [9 1 1 1]
   10
   11
   12
   15
   16
   17
   20
   21
   22

// Window 3x3, strides 3x3 ("distinct"), padding 2x2
unwrap(A, 3, 3, 3, 3, 2, 2) [9 9 1 1]
    0     0     0     0    16    19     0    31    34
    0     0     0     0    17     0     0    32     0
    0     0     0    15    18     0    30    33     0
    0     0     0     0    21    24     0     0     0
    0     0     0     0    22     0     0     0     0
    0     0     0    20    23     0     0     0     0
    0    11    14     0    26    29     0     0     0
    0    12     0     0    27     0     0     0     0
   10    13     0    25    28     0     0     0     0
\endcode


=======================================================================

\defgroup image_func_wrap wrap
\ingroup image_mod_mat

Wrap takes an unwrapped image (see \ref unwrap()) and converts it back to an image.

The inputs to this function should be the same as the inputs used to generate the unwrapped image.
@}
*/