loadImage

Functions
loadImage
Complete List of ArrayFire Functions ArrayFire Functions by Category » Input and Output functions » | Reading and writing images

Load an image from disk to an array. More...

## Functions
AFAPI array | loadimage (const char *filename, const bool is_color=false)
| C++ Interface for loading an image. More...
AFAPI array | loadImage (const char *filename, const bool is_color=false)
| C++ Interface for loading an image. More...
AFAPI array | loadImageNative (const char *filename)
| C++ Interface for loading an image as its original type. More...
AFAPI af_err | af_load_image (af_array *out, const char *filename, const bool isColor)
| C Interface for loading an image. More...
AFAPI af_err | af_load_image_native (af_array *out, const char *filename)
| C Interface for loading an image as is original type. More...

## Detailed Description

Load an image from disk to an array.

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

## Function Documentation

## ◆ af_load_image()

AFAPI af_err af_load_image | ( | af_array * | out,
|  | const char * | filename,
|  | const bool | isColor
| ) |  |

C Interface for loading an image.

Parameters

  [out] | out | will contain the image
  [in] | filename | is name of file to be loaded
  [in] | isColor | boolean denoting if the image should be loaded as 1 channel or 3 channel

Returns
  AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.

## ◆ af_load_image_native()

AFAPI af_err af_load_image_native | ( | af_array * | out,
|  | const char * | filename
| ) |  |

C Interface for loading an image as is original type.

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

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

Parameters

  [out] | out | contains them image
  [in] | filename | is name of file to be loaded

Returns
  AF_SUCCESS if successful

## ◆ loadImage()

AFAPI array af::loadImage | ( | const char * | filename,
|  | const bool | is_color = `false`
| ) |  |

C++ Interface for loading an image.

Parameters

  [in] | filename | is name of file to be loaded
  [in] | is_color | boolean denoting if the image should be loaded as 1 channel or 3 channel

Returns
  image loaded as af::array()

Examples:
  computer_vision/fast.cpp, computer_vision/harris.cpp, computer_vision/matching.cpp, computer_vision/susan.cpp, graphics/histogram.cpp, image_processing/adaptive_thresholding.cpp, image_processing/binary_thresholding.cpp, image_processing/brain_segmentation.cpp, image_processing/edge.cpp, image_processing/filters.cpp, image_processing/image_demo.cpp, image_processing/image_editing.cpp, image_processing/morphing.cpp, image_processing/optical_flow.cpp, image_processing/pyramids.cpp, and machine_learning/kmeans.cpp.

## ◆ loadimage()

AFAPI array af::loadimage | ( | const char * | filename,
|  | const bool | is_color = `false`
| ) |  |

C++ Interface for loading an image.

Parameters

  [in] | filename | is name of file to be loaded
  [in] | is_color | boolean denoting if the image should be loaded as 1 channel or 3 channel

Returns
  image loaded as af::array()

Deprecated:
  Use loadImage instead

## ◆ loadImageNative()

AFAPI array af::loadImageNative | ( | const char * | filename | ) |

C++ Interface for loading an image as its original type.

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

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

Parameters

  [in] | filename | is name of file to be loaded

Returns
  image loaded as af::array()