My Project
image.h
Go to the documentation of this file.
1/*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10#pragma once
11#include <af/defines.h>
12#include <af/features.h>
13
14#ifdef __cplusplus
15namespace af
16{
17class array;
18
28AFAPI void grad(array& dx, array& dy, const array& in);
29
39AFAPI array loadImage(const char* filename, const bool is_color=false);
40
49AFAPI void saveImage(const char* filename, const array& in);
50
51#if AF_API_VERSION >= 31
65AFAPI array loadImageMem(const void *ptr);
66#endif
67
68#if AF_API_VERSION >= 31
84AFAPI void* saveImageMem(const array& in, const imageFormat format = AF_FIF_PNG);
85#endif
86
87#if AF_API_VERSION >= 31
96AFAPI void deleteImageMem(void *ptr);
97#endif
98
99#if AF_API_VERSION >= 32
117AFAPI array loadImageNative(const char* filename);
118#endif
119
120#if AF_API_VERSION >= 32
147AFAPI void saveImageNative(const char* filename, const array& in);
148#endif
149
150#if AF_API_VERSION >= 33
158#endif
159
171AFAPI array resize(const array& in, const dim_t odim0, const dim_t odim1, const interpType method=AF_INTERP_NEAREST);
172
184AFAPI array resize(const float scale0, const float scale1, const array& in, const interpType method=AF_INTERP_NEAREST);
185
196AFAPI array resize(const float scale, const array& in, const interpType method=AF_INTERP_NEAREST);
197
209AFAPI array rotate(const array& in, const float theta, const bool crop=true, const interpType method=AF_INTERP_NEAREST);
210
224AFAPI 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);
225
226#if AF_API_VERSION >= 33
237AFAPI array transformCoordinates(const array& tf, const float d0, const float d1);
238#endif
239
253AFAPI 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);
254
268AFAPI 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);
269
284AFAPI 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);
285
297AFAPI array bilateral(const array &in, const float spatial_sigma, const float chromatic_sigma, const bool is_color=false);
298
312AFAPI array histogram(const array &in, const unsigned nbins, const double minval, const double maxval);
313
325AFAPI array histogram(const array &in, const unsigned nbins);
326
339AFAPI array meanShift(const array& in, const float spatial_sigma, const float chromatic_sigma, const unsigned iter, const bool is_color=false);
340
355AFAPI array medfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);
356
369AFAPI array minfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);
370
383AFAPI array maxfilt(const array& in, const dim_t wind_length = 3, const dim_t wind_width = 3, const borderType edge_pad = AF_PAD_ZERO);
384
396AFAPI array dilate(const array& in, const array& mask);
397
407AFAPI array dilate3(const array& in, const array& mask);
408
420AFAPI array erode(const array& in, const array& mask);
421
431AFAPI array erode3(const array& in, const array& mask);
432
461
474AFAPI void sobel(array &dx, array &dy, const array &img, const unsigned ker_size=3);
475
488AFAPI array sobel(const array &img, const unsigned ker_size=3, const bool isFast=false);
489
503AFAPI array rgb2gray(const array& in, const float rPercent=0.2126f, const float gPercent=0.7152f, const float bPercent=0.0722f);
504
518AFAPI array gray2rgb(const array& in, const float rFactor=1.0, const float gFactor=1.0, const float bFactor=1.0);
519
533AFAPI array histEqual(const array& in, const array& hist);
534
546AFAPI array gaussianKernel(const int rows, const int cols, const double sig_r = 0, const double sig_c = 0);
547
559
571
586AFAPI array colorSpace(const array& image, const CSpace to, const CSpace from);
587
588#if AF_API_VERSION >= 31
604AFAPI array unwrap(const array& in, const dim_t wx, const dim_t wy,
605 const dim_t sx, const dim_t sy, const dim_t px=0, const dim_t py=0,
606 const bool is_column = true);
607#endif
608
609#if AF_API_VERSION >= 31
628 const dim_t ox, const dim_t oy,
629 const dim_t wx, const dim_t wy,
630 const dim_t sx, const dim_t sy,
631 const dim_t px = 0, const dim_t py = 0,
632 const bool is_column = true);
633#endif
634
635#if AF_API_VERSION >= 31
644AFAPI array sat(const array& in);
645#endif
646
647#if AF_API_VERSION >= 31
660AFAPI array ycbcr2rgb(const array& in, const YCCStd standard=AF_YCC_601);
661#endif
662
663#if AF_API_VERSION >= 31
676AFAPI array rgb2ycbcr(const array& in, const YCCStd standard=AF_YCC_601);
677#endif
678
679}
680#endif
681
682#ifdef __cplusplus
683extern "C" {
684#endif
685
698
710 AFAPI af_err af_load_image(af_array *out, const char* filename, const bool isColor);
711
722 AFAPI af_err af_save_image(const char* filename, const af_array in);
723
724#if AF_API_VERSION >= 31
736#endif
737
738#if AF_API_VERSION >= 31
751 AFAPI af_err af_save_image_memory(void** ptr, const af_array in, const af_image_format format);
752#endif
753
754#if AF_API_VERSION >= 31
765#endif
766
767#if AF_API_VERSION >= 32
786 AFAPI af_err af_load_image_native(af_array *out, const char* filename);
787#endif
788
789#if AF_API_VERSION >= 32
818 AFAPI af_err af_save_image_native(const char* filename, const af_array in);
819#endif
820
821#if AF_API_VERSION >= 33
833#endif
834
849 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);
850
867 const dim_t odim0, const dim_t odim1,
868 const af_interp_type method, const bool inverse);
869
870#if AF_API_VERSION >= 33
882 AFAPI af_err af_transform_coordinates(af_array *out, const af_array tf, const float d0, const float d1);
883#endif
884
898 AFAPI af_err af_rotate(af_array *out, const af_array in, const float theta,
899 const bool crop, const af_interp_type method);
915 AFAPI af_err af_translate(af_array *out, const af_array in, const float trans0, const float trans1,
916 const dim_t odim0, const dim_t odim1, const af_interp_type method);
932 AFAPI af_err af_scale(af_array *out, const af_array in, const float scale0, const float scale1,
933 const dim_t odim0, const dim_t odim1, const af_interp_type method);
950 AFAPI af_err af_skew(af_array *out, const af_array in, const float skew0, const float skew1,
951 const dim_t odim0, const dim_t odim1, const af_interp_type method,
952 const bool inverse);
953
967 AFAPI af_err af_histogram(af_array *out, const af_array in, const unsigned nbins, const double minval, const double maxval);
968
982 AFAPI af_err af_dilate(af_array *out, const af_array in, const af_array mask);
983
995 AFAPI af_err af_dilate3(af_array *out, const af_array in, const af_array mask);
996
1010 AFAPI af_err af_erode(af_array *out, const af_array in, const af_array mask);
1011
1023 AFAPI af_err af_erode3(af_array *out, const af_array in, const af_array mask);
1024
1038 AFAPI af_err af_bilateral(af_array *out, const af_array in, const float spatial_sigma, const float chromatic_sigma, const bool isColor);
1039
1054 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);
1055
1070 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);
1071
1086 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);
1087
1102 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);
1103
1117
1132 AFAPI af_err af_sobel_operator(af_array *dx, af_array *dy, const af_array img, const unsigned ker_size);
1133
1149 AFAPI af_err af_rgb2gray(af_array* out, const af_array in, const float rPercent, const float gPercent, const float bPercent);
1150
1166 AFAPI af_err af_gray2rgb(af_array* out, const af_array in, const float rFactor, const float gFactor, const float bFactor);
1167
1182
1197 const int rows, const int cols,
1198 const double sigma_r, const double sigma_c);
1199
1213
1227
1245 AFAPI af_err af_color_space(af_array *out, const af_array image, const af_cspace_t to, const af_cspace_t from);
1246
1247#if AF_API_VERSION >= 31
1265 AFAPI af_err af_unwrap(af_array *out, const af_array in, const dim_t wx, const dim_t wy,
1266 const dim_t sx, const dim_t sy, const dim_t px, const dim_t py,
1267 const bool is_column);
1268#endif
1269
1270#if AF_API_VERSION >= 31
1293 const af_array in,
1294 const dim_t ox, const dim_t oy,
1295 const dim_t wx, const dim_t wy,
1296 const dim_t sx, const dim_t sy,
1297 const dim_t px, const dim_t py,
1298 const bool is_column);
1299#endif
1300
1301#if AF_API_VERSION >= 31
1313#endif
1314
1315#if AF_API_VERSION >= 31
1330 AFAPI af_err af_ycbcr2rgb(af_array* out, const af_array in, const af_ycc_std standard);
1331#endif
1332
1333#if AF_API_VERSION >= 31
1348 AFAPI af_err af_rgb2ycbcr(af_array* out, const af_array in, const af_ycc_std standard);
1349#endif
1350#ifdef __cplusplus
1351}
1352#endif
A multi dimensional data container.
Definition: array.h:27
af_dtype
Definition: defines.h:195
@ f32
32-bit floating point values
Definition: defines.h:196
af_border_type
Definition: defines.h:232
@ AF_PAD_ZERO
Out of bound values are 0.
Definition: defines.h:236
af_image_format
Definition: defines.h:343
@ AF_FIF_PNG
FreeImage Enum for Portable Network Graphics File.
Definition: defines.h:348
long long dim_t
Definition: defines.h:50
af_err
Definition: defines.h:63
void * af_array
Definition: defines.h:222
af_ycc_std
Definition: defines.h:288
@ AF_YCC_601
ITU-R BT.601 (formerly CCIR 601) standard.
Definition: defines.h:289
#define AFAPI
Definition: defines.h:31
af_interp_type
Definition: defines.h:224
@ AF_INTERP_NEAREST
Nearest Interpolation.
Definition: defines.h:225
af_cspace_t
Definition: defines.h:295
af_connectivity
Definition: defines.h:244
@ AF_CONNECTIVITY_4
Connectivity includes neighbors, North, East, South and West of current pixel.
Definition: defines.h:248
AFAPI void grad(array &dx, array &dy, const array &in)
C++ Interface for calculating the gradients.
AFAPI af_err af_gradient(af_array *dx, af_array *dy, const af_array in)
C Interface for calculating the gradients.
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 bilateral filter.
AFAPI array bilateral(const array &in, const float spatial_sigma, const float chromatic_sigma, const bool is_color=false)
C++ Interface for bilateral filter.
AFAPI af_err af_color_space(af_array *out, const af_array image, const af_cspace_t to, const af_cspace_t from)
C Interface wrapper for color space conversion.
AFAPI array colorSpace(const array &image, const CSpace to, const CSpace from)
C++ Interface wrapper for colorspace conversion.
AFAPI array dilate3(const array &in, const array &mask)
C++ Interface for 3D image dilation.
AFAPI af_err af_dilate3(af_array *out, const af_array in, const af_array mask)
C Interface for 3d image dilation.
AFAPI array dilate(const array &in, const array &mask)
C++ Interface for image dilation (max filter)
AFAPI af_err af_dilate(af_array *out, const af_array in, const af_array mask)
C Interface for image dilation (max filter)
AFAPI array erode3(const array &in, const array &mask)
C++ Interface for 3d for image erosion.
AFAPI af_err af_erode3(af_array *out, const af_array in, const af_array mask)
C Interface for 3D image erosion.
AFAPI af_err af_erode(af_array *out, const af_array in, const af_array mask)
C Interface for image erosion (min filter)
AFAPI array erode(const array &in, const array &mask)
C++ Interface for image erosion (min filter)
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 generating gaussian kernels.
AFAPI array gaussianKernel(const int rows, const int cols, const double sig_r=0, const double sig_c=0)
C++ Interface for generating gausian kernels.
AFAPI af_err af_gray2rgb(af_array *out, const af_array in, const float rFactor, const float gFactor, const float bFactor)
C Interface for converting gray to RGB.
AFAPI array gray2rgb(const array &in, const float rFactor=1.0, const float gFactor=1.0, const float bFactor=1.0)
C++ Interface for gray to RGB conversion.
AFAPI af_err af_hist_equal(af_array *out, const af_array in, const af_array hist)
C Interface for histogram equalization.
AFAPI array histEqual(const array &in, const array &hist)
C++ Interface for histogram equalization.
AFAPI af_err af_histogram(af_array *out, const af_array in, const unsigned nbins, const double minval, const double maxval)
C Interface for histogram.
AFAPI array histogram(const array &in, const unsigned nbins, const double minval, const double maxval)
C++ Interface for histogram.
AFAPI af_err af_hsv2rgb(af_array *out, const af_array in)
C Interface for converting HSV to RGB.
AFAPI array hsv2rgb(const array &in)
C++ Interface for converting HSV to RGB.
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 maximum filter.
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 maximum filter.
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 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 mean shift.
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 median filter.
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 median filter.
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 minimum filter.
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 minimum filter.
AFAPI af_err af_regions(af_array *out, const af_array in, const af_connectivity connectivity, const af_dtype ty)
C Interface for regions in an image.
AFAPI array regions(const array &in, const af::connectivity connectivity=AF_CONNECTIVITY_4, const dtype type=f32)
C++ Interface for getting regions in an image.
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 RGB to gray.
AFAPI array rgb2gray(const array &in, const float rPercent=0.2126f, const float gPercent=0.7152f, const float bPercent=0.0722f)
C++ Interface for RGB to gray conversion.
AFAPI af_err af_rgb2hsv(af_array *out, const af_array in)
C Interface for converting RGB to HSV.
AFAPI array rgb2hsv(const array &in)
C++ Interface for converting RGB to HSV.
AFAPI array rgb2ycbcr(const array &in, const YCCStd standard=AF_YCC_601)
C++ Interface for converting RGB to YCbCr.
AFAPI af_err af_rgb2ycbcr(af_array *out, const af_array in, const af_ycc_std standard)
C Interface for converting RGB to YCbCr.
AFAPI array sat(const array &in)
C++ Interface wrapper for summed area tables.
AFAPI af_err af_sat(af_array *out, const af_array in)
C Interface wrapper for summed area tables.
AFAPI af_err af_sobel_operator(af_array *dx, af_array *dy, const af_array img, const unsigned ker_size)
C Interface for getting sobel gradients.
AFAPI void sobel(array &dx, array &dy, const array &img, const unsigned ker_size=3)
C++ Interface for extracting sobel gradients.
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)
C Interface wrapper for 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)
C++ Interface wrapper for unwrap.
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)
C++ Interface wrapper for 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)
C Interface wrapper for wrap.
AFAPI array ycbcr2rgb(const array &in, const YCCStd standard=AF_YCC_601)
C++ Interface for converting YCbCr to RGB.
AFAPI af_err af_ycbcr2rgb(af_array *out, const af_array in, const af_ycc_std standard)
C Interface for converting YCbCr to RGB.
AFAPI af_err af_is_image_io_available(bool *out)
Function to check if Image IO is available.
AFAPI bool isImageIOAvailable()
Function to check if Image IO is available.
AFAPI array loadImage(const char *filename, const bool is_color=false)
C++ Interface for loading an image.
AFAPI array loadImageNative(const char *filename)
C++ Interface for loading an image as its original type.
AFAPI af_err af_load_image(af_array *out, const char *filename, const bool isColor)
C Interface for loading an image.
AFAPI af_err af_load_image_native(af_array *out, const char *filename)
C Interface for loading an image as is original type.
AFAPI af_err af_save_image(const char *filename, const af_array in)
C Interface for saving an image.
AFAPI void saveImageNative(const char *filename, const array &in)
C++ Interface for saving an image without modifications.
AFAPI void saveImage(const char *filename, const array &in)
C++ Interface for saving an image.
AFAPI af_err af_save_image_native(const char *filename, const af_array in)
C Interface for saving an image without modifications.
AFAPI void deleteImageMem(void *ptr)
C++ Interface for deleting memory created by saveImageMem or af_save_image_memory.
AFAPI af_err af_delete_image_memory(void *ptr)
C Interface for deleting an image from memory.
AFAPI array loadImageMem(const void *ptr)
C++ Interface for loading an image from memory.
AFAPI af_err af_load_image_memory(af_array *out, const void *ptr)
C Interface for loading an image from memory.
AFAPI void * saveImageMem(const array &in, const imageFormat format=AF_FIF_PNG)
C++ Interface for saving an image to memory.
AFAPI af_err af_save_image_memory(void **ptr, const af_array in, const af_image_format format)
C Interface for saving an image to memory using FreeImage.
AFAPI array inverse(const array &in, const matProp options=AF_MAT_NONE)
C++ Interface for inverting a matrix.
AFAPI af_err af_transform_coordinates(af_array *out, const af_array tf, const float d0, const float d1)
C Interface for transforming an image C++ Interface for transforming coordinates.
AFAPI array transformCoordinates(const array &tf, const float d0, const float d1)
C++ Interface for transforming coordinates.
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 resizing an image to specified dimensions.
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 dimensions.
AFAPI array rotate(const array &in, const float theta, const bool crop=true, const interpType method=AF_INTERP_NEAREST)
C++ Interface for rotating an image.
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 rotating an image.
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 scaling an image.
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 scaling an image.
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 skewing an image.
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 skewing an image.
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)
C Interface for transforming an image.
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)
C++ Interface for transforming an image.
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 translating an image.
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 translate an image.
Definition: algorithm.h:15
af_connectivity connectivity
Definition: defines.h:404
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:329