asi_core.transform

This module implements image transformations that can be applied to all-sky images.

Functions

check_image_array_dimensions(array, height, width)

Determines the dimensions (N, H, W, C) of an input array representing

resize_image_batch(image_batch, resize)

Resize a batch of images.

resize_image(image, resize)

Resize a single image.

mask_image_batch(image_batch, camera_mask[, ...])

Applies a camera mask to a batch of images.

mask_image(image, camera_mask[, assign_to_masked_pxls])

Applies a camera mask to a single image.

asi_index_cropping(asi, crop_x, crop_y[, channel_first])

Crops a given array along the x and y dimensions.

asi_undistortion(asi, lookup_table)

Undistorts ASI array according to mapping in lookup_table.

get_zenith_cropping(elevation_matrix[, min_ele])

Generates a cropping mask based on the maximum elevation angle.

get_mask_cropping(camera_mask)

Crops ASI array according to camera mask.

Module Contents

asi_core.transform.check_image_array_dimensions(array, height, width)

Determines the dimensions (N, H, W, C) of an input array representing a single image or a batch of images.

Parameters:
  • array – np.ndarray, the input array to analyze.

  • height – int, the known height of the images.

  • width – int, the known width of the images.

Returns:

tuple (N, H, W, C) where N and/or C may be None.

asi_core.transform.resize_image_batch(image_batch, resize)

Resize a batch of images.

Parameters:
  • image_batch – np.array of shape [N, H, W], [N, H, W, 1], or [N, H, W, C].

  • resize – tuple (H, W) representing the desired dimensions.

Returns:

np.array of resized batch.

asi_core.transform.resize_image(image, resize)

Resize a single image.

Parameters:
  • image – np.array of shape [HxW], [HxWx1], or [HxWxC].

  • resize – tuple (H, W) representing the desired dimensions.

Returns:

np.array of resized image.

asi_core.transform.mask_image_batch(image_batch, camera_mask, assign_to_masked_pxls=0)

Applies a camera mask to a batch of images.

Parameters:
  • image_batch – np.array of images [NxHxWxC] or [NxHxW].

  • camera_mask – np.array of camera mask [HxW].

  • assign_to_masked_pxls – value to assign to masked-out pixels.

Returns:

np.array of same shape as batch where non-masked region is set to zero.

asi_core.transform.mask_image(image, camera_mask, assign_to_masked_pxls=0)

Applies a camera mask to a single image.

Parameters:
  • batch – np.array of images [NxHxWxC] or [NxHxW].

  • camera_mask – np.array of camera mask [HxW].

  • assign_to_masked_pxls – value to assign to masked-out pixels.

Returns:

np.array of same shape as batch where non-masked region is set to zero.

asi_core.transform.asi_index_cropping(asi, crop_x, crop_y, channel_first=False)

Crops a given array along the x and y dimensions.

Parameters:
  • asi – The input image to be cropped.

  • crop_x – The x-coordinates of the crop.

  • crop_y – The y-coordinates of the crop.

  • channel_first – Whether the color channel of the input image is the first dimension.

Returns:

The cropped array

asi_core.transform.asi_undistortion(asi, lookup_table)

Undistorts ASI array according to mapping in lookup_table.

Parameters:
  • asi – np.array of image(s) [NxWxHxC] or [WxHxC]

  • look_up_table – dict lookup_table[‘mapx’]: ndarray [W’xH’] lookup_table[‘mapy’]: ndarray [W’xH’]

Returns:

np.array of undistorted asi [NxW’xH’xC] (or [W’xH’xC])

asi_core.transform.get_zenith_cropping(elevation_matrix, min_ele=0)

Generates a cropping mask based on the maximum elevation angle.

Parameters:
  • elevation_matrix – ndarray A matrix of elevation values for each pixel.

  • min_ele – float, optional The minimum elevation angle in degrees. Defaults to 0.

Returns:

crop_mask_x (slice)

The x-coordinate slice for cropping.

crop_mask_y (slice)

The y-coordinate slice for cropping.

asi_core.transform.get_mask_cropping(camera_mask)

Crops ASI array according to camera mask.

Parameters:

camera_mask – ndarray of camera mask [WxH] (binary -> 1 eqauls mask pixel)

Returns:

crop_mask_x (slice)

The x-coordinate slice for cropping.

crop_mask_y (slice)

The y-coordinate slice for cropping.