image.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 
9 #pragma once
10 
11 #include "defines.h"
12 #include <string>
13 
18  typedef enum {
19  af_rgb = 0,
23  } af_cspace_t;
24 
25 namespace af {
26 
27  class array;
610  AFAPI array gaussiankernel(int rows, int cols, double sigma_r = 0, double sigma_c = 0);
611 
640  AFAPI array filter(const array& image, const array& kernel);
641 
671  AFAPI array medfilt(const array& image, const unsigned height=3, const unsigned width=3);
672 
702  AFAPI array minfilt(const array& image, const unsigned height=3, const unsigned width=3);
703 
734  AFAPI array maxfilt(const array& image, const unsigned height=3, const unsigned width=3);
735 
753  AFAPI array erode(const array& image, const array& mask);
754 
773  AFAPI array dilate(const array& image, const array& mask);
774 
803  AFAPI array resize(const float scale, const array& image, const char method='L');
804 
819  AFAPI array resize(const float scale_x,
820  const float scale_y,
821  const array& image,
822  const char method='L');
823 
837  AFAPI array resize(const unsigned height,
838  const unsigned width,
839  const array& image,
840  const char method='L');
841 
865  AFAPI array transform(const array& image, const array& transform,
866  const unsigned oh=0, const unsigned ow=0, const bool inverse = true);
891  AFAPI array rotate(const array& image, const float theta = 0,
892  const bool iscrop = true, const bool recenter = true);
915  AFAPI array translate(const array& image, const float trans_x, const float trans_y,
916  const unsigned oh=0, const unsigned ow=0);
941  AFAPI array scale(const array& image, const float scale_x, const float scale_y,
942  const unsigned oh=0, const unsigned ow=0);
966  AFAPI array skew(const array& image, const float skew_x, const float skew_y,
967  const unsigned oh=0, const unsigned ow=0, const bool inverse = false);
984  AFAPI array transform_coord(const array& vertices, const array& transform);
1005  AFAPI array rotate_coord(const array& vertices, const unsigned axis, const float theta);
1039  AFAPI array bilateral(const array& image, const float space, const float color);
1040 
1076  AFAPI array meanshift(const array& image, const float space, const float color, const int iter=5);
1077 
1098  AFAPI array colorspace(const array& image, const af_cspace_t to, const af_cspace_t from);
1099 
1119  AFAPI array histogram(const array& data, unsigned nbins);
1120 
1131  AFAPI array histogram(const array& data, unsigned nbins, float min, float max);
1132 
1150  AFAPI array histequal(const array& data, const array& histogram);
1151 
1168  AFAPI array regions(const array& image, const unsigned connectivity=8);
1169 
1186  AFAPI array areas(const array& regions);
1187 
1205  AFAPI array centroids(const array& regions);
1206 
1239  AFAPI array loadimage(const char* filename, bool iscolor = false);
1240 
1266  AFAPI void saveimage(const char* filename, const af::array& img);
1267 
1274 } // namespace af
1275 
1276 
1277 
1278 
1279 
1280 
1281 #ifdef __cplusplus
1282 extern "C" {
1283 #endif
1284 
1304  AFAPI afError af_rotate_S(float* d_out,
1305  unsigned xo, unsigned yo,
1306  const float* d_in,
1307  unsigned xi, unsigned yi,
1308  float theta, unsigned batch);
1332  AFAPI afError af_resize_S(const unsigned mO, const unsigned nO,
1334  float* d_out,
1335  const unsigned mI, const unsigned nI,
1336  const float* d_in,
1337  const unsigned channels, const int type=1);
1339  AFAPI afError af_resize_D(const unsigned mO, const unsigned nO,
1340  double* d_out,
1341  const unsigned mI, const unsigned nI,
1342  const double* d_in,
1343  const unsigned channels, const int type=1);
1344 
1370  AFAPI afError af_erode_B(bool *d_out,
1372  unsigned in_ndims, const unsigned *in_dims, const bool *d_in,
1373  unsigned nhood_ndims, const unsigned *nhood_dims, const bool *h_nhood,
1374  unsigned batch);
1375 
1377  AFAPI afError af_erode_S(float *d_out,
1378  unsigned in_ndims, const unsigned *in_dims, const float *d_in,
1379  unsigned nhood_ndims, const unsigned *nhood_dims, const float *h_nhood,
1380  unsigned batch);
1381 
1382 
1384  AFAPI afError af_erode_D(double *d_out,
1385  unsigned in_ndims, const unsigned *in_dims, const double *d_in,
1386  unsigned nhood_ndims, const unsigned *nhood_dims, const double *h_nhood,
1387  unsigned batch);
1388 
1414  AFAPI afError af_dilate_B(bool *d_out,
1416  unsigned in_ndims, const unsigned *in_dims, const bool *d_in,
1417  unsigned nhood_ndims, const unsigned *nhood_dims, const bool *d_nhood,
1418  unsigned batch);
1419 
1421  AFAPI afError af_dilate_S(float *d_out,
1422  unsigned in_ndims, const unsigned *in_dims, const float *d_in,
1423  unsigned nhood_ndims, const unsigned *nhood_dims, const float *d_nhood,
1424  unsigned batch);
1425 
1427  AFAPI afError af_dilate_D(double *d_out,
1428  unsigned in_ndims, const unsigned *in_dims, const double *d_in,
1429  unsigned nhood_ndims, const unsigned *nhood_dims, const double *d_nhood,
1430  unsigned batch);
1450  //Single Precision, Affine Coordinate Transform
1451  AFAPI afError af_transform_coord_S(float* d_dst,
1452  const float* d_src, const unsigned* dims,
1453  const float* d_tf, const unsigned* hdims,
1454  unsigned batch);
1455 
1456  //Double Precision, Affine Coordinate Transform
1457  AFAPI afError af_transform_coord_D(double* d_dst,
1458  const double* d_src, const unsigned* dims,
1459  const double* d_tf, const unsigned* hdims,
1460  unsigned batch);
1465  AFAPI afError af_transform_S(float* d_out,
1466  const float* d_in, const unsigned* idims,
1467  const float* d_tf, const unsigned* odims,
1468  unsigned nimages, unsigned ntranforms,
1469  const bool inverse);
1470 
1471  AFAPI afError af_transform_D(double* d_out,
1472  const double* d_in, const unsigned* idims,
1473  const float* d_tf, const unsigned* odims,
1474  unsigned nimages, unsigned ntranforms,
1475  const bool inverse);
1476 
1477  AFAPI afError af_transform_I(int* d_out,
1478  const int* d_in, const unsigned* idims,
1479  const float* d_tf, const unsigned* odims,
1480  unsigned nimages, unsigned ntranforms,
1481  const bool inverse);
1482 
1483  AFAPI afError af_transform_U(unsigned* d_out,
1484  const unsigned* d_in, const unsigned* idims,
1485  const float* d_tf, const unsigned* odims,
1486  unsigned nimages, unsigned ntranforms,
1487  const bool inverse);
1488 
1489  AFAPI afError af_transform_B(bool* d_out,
1490  const bool* d_in, const unsigned* idims,
1491  const float* d_tf, const unsigned* odims,
1492  unsigned nimages, unsigned ntranforms,
1493  const bool inverse);
1513  AFAPI afError af_bilateral_S(float* d_out,
1515  const float* d_in,
1516  unsigned mI, unsigned nI,
1517  const float space,
1518  const float color,
1519  int channels);
1545  AFAPI afError af_meanshift_S(float* d_out,
1547  const float* d_in,
1548  unsigned mI, unsigned nI,
1549  const float space,
1550  const float color,
1551  const int iter,
1552  int channels);
1577  AFAPI afError af_histogram_S(float* d_hist,
1579  unsigned length, const float* d_data,
1580  unsigned nbins , const float* h_bins,
1581  unsigned nsets, unsigned ngfor);
1582 
1598  AFAPI afError af_histminmax_S(float* d_hist,
1600  unsigned len, const float* d_data,
1601  unsigned bins, const float* h_data,
1602  unsigned nsets, unsigned ngfor,
1603  float min, float max);
1628  AFAPI afError af_histequalize_S(float* d_out,
1630  unsigned length, const float* d_data,
1631  unsigned nbins , const float* d_bins);
1653  AFAPI afError af_regions_B(float *d_out,
1655  const unsigned nx,
1656  const unsigned ny,
1657  const bool *d_in,
1658  unsigned conn);
1680  AFAPI afError af_medfilt_B(char* d_out,
1682  unsigned m, unsigned n, const char* d_in,
1683  const unsigned* h_W);
1685  AFAPI afError af_medfilt_c(unsigned char* d_out,
1686  unsigned m, unsigned n, const unsigned char* d_in,
1687  const unsigned* h_W);
1689  AFAPI afError af_medfilt_I(int* d_out,
1690  unsigned m, unsigned n, const int* d_in,
1691  const unsigned* h_W);
1693  AFAPI afError af_medfilt_U(unsigned* d_out,
1694  unsigned m, unsigned n, const unsigned* d_in,
1695  const unsigned* h_W);
1697  AFAPI afError af_medfilt_S(float* d_out,
1698  unsigned m, unsigned n, const float* d_in,
1699  const unsigned* h_W);
1701  AFAPI afError af_medfilt_D(double* d_out,
1702  unsigned m, unsigned n, const double* d_in,
1703  const unsigned* h_W);
1708 #ifdef __cplusplus
1709 }
1710 #endif
afError af_transform_B(bool *d_out, const bool *d_in, const unsigned *idims, const float *d_tf, const unsigned *odims, unsigned nimages, unsigned ntranforms, const bool inverse)
array inverse(const array &in)
Matrix inversion.
af_cspace_t
Colorspace Transform Enum.
Definition: image.h:18
afError af_transform_I(int *d_out, const int *d_in, const unsigned *idims, const float *d_tf, const unsigned *odims, unsigned nimages, unsigned ntranforms, const bool inverse)
afError af_transform_D(double *d_out, const double *d_in, const unsigned *idims, const float *d_tf, const unsigned *odims, unsigned nimages, unsigned ntranforms, const bool inverse)
array bilateral(const array &image, const float space, const float color)
Bilateral filtering.
afError af_erode_S(float *d_out, unsigned in_ndims, const unsigned *in_dims, const float *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const float *h_nhood, unsigned batch)
Single precision, Image Erosion.
afError af_bilateral_S(float *d_out, const float *d_in, unsigned mI, unsigned nI, const float space, const float color, int channels)
Bilateral filtering.
afError af_erode_D(double *d_out, unsigned in_ndims, const unsigned *in_dims, const double *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const double *h_nhood, unsigned batch)
Double precision, Image Erosion.
array gaussiankernel(int rows, int cols, double sigma_r=0, double sigma_c=0)
Generate kernels.
afError af_medfilt_B(char *d_out, unsigned m, unsigned n, const char *d_in, const unsigned *h_W)
Median filtering of a matrix using the specified window (or a 3 x 3 default window).
array scale(const array &image, const float scale_x, const float scale_y, const unsigned oh=0, const unsigned ow=0)
afError af_dilate_D(double *d_out, unsigned in_ndims, const unsigned *in_dims, const double *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const double *d_nhood, unsigned batch)
Double precision, Image Dilation.
array colorspace(const array &image, const af_cspace_t to, const af_cspace_t from)
array transform(const array &image, const array &transform, const unsigned oh=0, const unsigned ow=0, const bool inverse=true)
Image in HSV.
Definition: image.h:20
array transform_coord(const array &vertices, const array &transform)
afError
Definition: defines.h:10
array resize(const float scale, const array &image, const char method='L')
Resize an image based on a scaling factor (uniform)
array regions(const array &image, const unsigned connectivity=8)
GPU array container.
Definition: array.h:411
Image in RGB format.
Definition: image.h:19
array rotate_coord(const array &vertices, const unsigned axis, const float theta)
array min(const array &x, const array &y)
Minimum between x and y at every position.
afError af_transform_coord_S(float *d_dst, const float *d_src, const unsigned *dims, const float *d_tf, const unsigned *hdims, unsigned batch)
afError af_medfilt_c(unsigned char *d_out, unsigned m, unsigned n, const unsigned char *d_in, const unsigned *h_W)
Medfilt: 8-bit unsigned int.
void saveimage(const char *filename, const af::array &img)
Save an image to disk.
afError af_histminmax_S(float *d_hist, unsigned len, const float *d_data, unsigned bins, const float *h_data, unsigned nsets, unsigned ngfor, float min, float max)
Form a non-normalized histogram from input matrix, using the specified minimum and maximum range for ...
array minfilt(const array &image, const unsigned height=3, const unsigned width=3)
Minimum filtering within window (default 3x3)
array histequal(const array &data, const array &histogram)
afError af_transform_S(float *d_out, const float *d_in, const unsigned *idims, const float *d_tf, const unsigned *odims, unsigned nimages, unsigned ntranforms, const bool inverse)
Grayscale Image.
Definition: image.h:21
array rotate(const array &image, const float theta=0, const bool iscrop=true, const bool recenter=true)
array meanshift(const array &image, const float space, const float color, const int iter=5)
Meanshift filtering.
array histogram(const array &data, unsigned nbins)
Histogram takes in the input array data and computes the minimum and maximum of the range...
array erode(const array &image, const array &mask)
#define AFAPI
Definition: defines.h:45
afError af_dilate_S(float *d_out, unsigned in_ndims, const unsigned *in_dims, const float *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const float *d_nhood, unsigned batch)
Single precision, Image Dilation.
handle image(const af::array &X)
array translate(const array &image, const float trans_x, const float trans_y, const unsigned oh=0, const unsigned ow=0)
array max(const array &x, const array &y)
Maximum between x and y at every position.
afError af_medfilt_D(double *d_out, unsigned m, unsigned n, const double *d_in, const unsigned *h_W)
Medfilt: double-precision data.
array areas(const array &regions)
afError af_medfilt_S(float *d_out, unsigned m, unsigned n, const float *d_in, const unsigned *h_W)
Medfilt: single-precision data.
afError af_histequalize_S(float *d_out, unsigned length, const float *d_data, unsigned nbins, const float *d_bins)
Equalize a given vector or matrix based on a given histogram.
afError af_medfilt_I(int *d_out, unsigned m, unsigned n, const int *d_in, const unsigned *h_W)
Medfilt: int data.
afError af_regions_B(float *d_out, const unsigned nx, const unsigned ny, const bool *d_in, unsigned conn)
Uniquely label connected components in a binary image.
afError af_histogram_S(float *d_hist, unsigned length, const float *d_data, unsigned nbins, const float *h_bins, unsigned nsets, unsigned ngfor)
Form a non-normalized histogram from input matrix.
Image in YCRCB format.
Definition: image.h:22
afError af_rotate_S(float *d_out, unsigned xo, unsigned yo, const float *d_in, unsigned xi, unsigned yi, float theta, unsigned batch)
Rotate a given image by a specified amount.
array loadimage(const char *filename, bool iscolor=false)
Load an image from disk.
array medfilt(const array &image, const unsigned height=3, const unsigned width=3)
Median filtering within window (default 3x3)
array filter(const array &image, const array &kernel)
Image Filtering.
array dilate(const array &image, const array &mask)
array maxfilt(const array &image, const unsigned height=3, const unsigned width=3)
Maximum filtering within window (default 3x3)
afError af_transform_U(unsigned *d_out, const unsigned *d_in, const unsigned *idims, const float *d_tf, const unsigned *odims, unsigned nimages, unsigned ntranforms, const bool inverse)
afError af_resize_S(const unsigned mO, const unsigned nO, float *d_out, const unsigned mI, const unsigned nI, const float *d_in, const unsigned channels, const int type=1)
Image resizing.
afError af_resize_D(const unsigned mO, const unsigned nO, double *d_out, const unsigned mI, const unsigned nI, const double *d_in, const unsigned channels, const int type=1)
Image resize, double precision.
afError af_erode_B(bool *d_out, unsigned in_ndims, const unsigned *in_dims, const bool *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const bool *h_nhood, unsigned batch)
Erode an Image.
afError af_transform_coord_D(double *d_dst, const double *d_src, const unsigned *dims, const double *d_tf, const unsigned *hdims, unsigned batch)
array centroids(const array &regions)
afError af_dilate_B(bool *d_out, unsigned in_ndims, const unsigned *in_dims, const bool *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const bool *d_nhood, unsigned batch)
Dilate an image.
afError af_medfilt_U(unsigned *d_out, unsigned m, unsigned n, const unsigned *d_in, const unsigned *h_W)
Medfilt: unsigned int data.
array skew(const array &image, const float skew_x, const float skew_y, const unsigned oh=0, const unsigned ow=0, const bool inverse=false)
afError af_meanshift_S(float *d_out, const float *d_in, unsigned mI, unsigned nI, const float space, const float color, const int iter, int channels)
Meanshift filtering.