
/*!
\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.
@}
*/
