Image

Collection of image Ivy functions.

ivy.bilinear_resample(x, warp, f=None)[source]

Performs bilinearly re-sampling on input image.

Parameters
  • x (array) – Input image [batch_shape,h,w,dims].

  • warp (array) – Warp array [batch_shape,num_samples,2]

  • f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

Image after bilinear re-sampling.

ivy.float_img_to_uint8_img(x, f=None)[source]

Converts an image of floats into a bit-cast 4-channel image of uint8s, which can be saved to disk.

Parameters
  • x (array) – Input float image [batch_shape,h,w].

  • f (ml_framework, optional) – Machine learning library. Inferred from inputs if None.

Returns

The new encoded uint8 image [batch_shape,h,w,4] .

ivy.gradient_image(x, f=None)[source]

Computes image gradients (dy, dx) for each channel.

Parameters
  • x (array) – Input image [batch_shape, h, w, d] .

  • f (ml_framework, optional) – Machine learning library. Inferred from inputs if None.

Returns

Gradient images dy [batch_shape,h,w,d] and dx [batch_shape,h,w,d] .

ivy.random_crop(x, crop_size, batch_shape=None, image_dims=None, f=None)[source]

Randomly crops the input images.

Parameters
  • x (array) – Input images to crop [batch_shape,h,w,f]

  • crop_size (sequence of ints) – The 2D crop size.

  • batch_shape (sequence of ints, optional) – Shape of batch. Inferred from inputs if None.

  • image_dims (sequence of ints, optional) – Image dimensions. Inferred from inputs in None.

  • f (ml_framework, optional) – Machine learning library. Inferred from inputs if None.

Returns

The new cropped image [batch_shape,nh,nw,f]

ivy.stack_images(images, desired_aspect_ratio=(1, 1), f=None)[source]

Stacks a group of images into a combined windowed image, fitting the desired aspect ratio as closely as possible.

Parameters
  • images (sequence of arrays) – Sequence of image arrays to be stacked [batch_shape,height,width,dims] .

  • desired_aspect_ratio (sequence of ints) – Desired aspect ratio of stacked image.

  • f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

Stacked image, suitable for viewing in a single window.

ivy.uint8_img_to_float_img(x, f=None)[source]

Converts an image of uint8 values into a bit-cast float image.

Parameters
  • x (array) – Input uint8 image [batch_shape,h,w,4].

  • f (ml_framework, optional) – Machine learning library. Inferred from inputs if None.

Returns

The new float image [batch_shape,h,w]