Segmentation

class segmentation.Segmentation(image, imager, time)[source]

Contains all the methods needed for the segmentation a sky/cloud image

image

np.array – The image to segment

imager

Imager – The imager used to take the image

time

datetime.datetime – The time at which the image was captured (UTC+8)

cmask(index, radius, array)[source]

Generates the mask for a given input image. The generated mask is needed to remove occlusions during post-processing steps.

Parameters:
  • index (numpy array) – Array containing the x- and y- co-ordinate of the center of the circular mask.
  • radius (float) – Radius of the circular mask.
  • array (numpy array) – Input sky/cloud image for which the mask is generated.
Returns:

Generated mask image.

Return type:

numpy array

getBRchannel(input_image, mask_image)[source]

Extracts the ratio of red and blue blue channel from an input sky/cloud image. It is used in the clustering step to generate the binary sky/cloud image.

Parameters:
  • input_image (numpy array) – Input sky/cloud image.
  • mask_image (numpy array) – Mask to remove occlusions from the input image. This mask contains boolean values indicating the allowable pixels from an image.
Returns:

Ratio image using red and blue color channels, normalized to [0,255].

Return type:

numpy array

make_cluster_mask(input_matrix, mask_image)[source]

Clusters an input sky/cloud image to generate the binary image and the coverage ratio value.

Parameters:
  • input_matrix (numpy array) – Input matrix that needs to be normalized.
  • mask_image (numpy array) – Mask to remove occlusions from the input image. This mask contains boolean values indicating the allowable pixels from an image.
Returns:

Binary output image, where white denotes cloud pixels and black denotes sky pixels. float: Cloud coverage ratio in the input sky/cloud image. float: The first (out of two) cluster center. float: The second (out of two) cluster center.

Return type:

numpy array

removeSunIfNonCloudy(im_mask)[source]

Removes the circumsolar area from the mask if it is detected as non cloudy.

Parameters:im_mask (numpy array) – Segmentation mask
Returns:Modified segmentation mask.
Return type:numpy array
segment()[source]

Main function for sky/cloud segmentation. Perform all the necessary steps.

showasImage(input_matrix)[source]

Normalizes an input matrix to the range [0,255]. It is useful in displaying the matrix as an image.

Parameters:input_matrix (numpy array) – Input matrix that needs to be normalized.
Returns:Returns the normalized matrix.
Return type:numpy array