def shadow_mask_array(image_difference_array, threshold=-5500, filter_size=13, morphing_size=0): # TODO: Is it 0 in morphing_size?? is not 10?? ''' This method returns a mask for the given array, it stacks all the bands into one and filters values that match the threshold. The new array will be filled with 0 when the values are above the threshold and 1 when the values are bellow the threshold. We assume that shadows will have darker values when compared to the reference array. ''' shadows = filter_median((numpy.sum(image_difference_array[3:, :, :], axis=0) < threshold).astype(numpy.int), filter_size) if morphing_size: shadows = morph_dilation(shadows, morphing_size) return shadows
def cloud_mask_array(image_difference_array, threshold=30000, filter_size=13, morphing_size=0): # TODO: Is it 0 in morphing_size?? is not 10?? ''' This method returns a mask for the given array, it stacks all the bands into one and filters values that match the threshold. The new array will be filled with 0 when the values are below the threshold and 1 when the values are above the threshold. We assume that clouds will have brighter values when compared to the reference array. ''' clouds = filter_median((numpy.sum(image_difference_array, axis=0) > threshold).astype(numpy.int), filter_size) if morphing_size: clouds = morph_dilation(clouds, morphing_size) return clouds
def cloud_shadow_mask_array(image_array, image_difference_array, solar_zenith, solar_azimuth, resolution): ''' This method creates a mask for clouds and shadows using a reference array. ''' clouds = cloud_mask_array(image_difference_array) shadows = shadow_mask_array(image_difference_array) inbetween = calculate_cloud_shadow(clouds, shadows, solar_zenith, solar_azimuth, resolution) image_mask_array = outside_mask_array(image_array, outside_value=255) pixel_sizes = [250, 150, 50] number_of_sizes = len(pixel_sizes) for pixel_size in pixel_sizes: numpy.putmask(image_mask_array, morph_dilation(clouds, pixel_size) == 1, FMASK_CLOUD * 10 + number_of_sizes) number_of_sizes = number_of_sizes - 1 numpy.putmask(image_mask_array, inbetween == 1, FMASK_CLOUD_SHADOW) numpy.putmask(image_mask_array, clouds == 1, FMASK_CLOUD) return image_mask_array
def shadow_mask_array( image_difference_array, threshold=-5500, filter_size=13, morphing_size=0): # TODO: Is it 0 in morphing_size?? is not 10?? ''' This method returns a mask for the given array, it stacks all the bands into one and filters values that match the threshold. The new array will be filled with 0 when the values are above the threshold and 1 when the values are bellow the threshold. We assume that shadows will have darker values when compared to the reference array. ''' shadows = filter_median((numpy.sum(image_difference_array[3:, :, :], axis=0) < threshold).astype(numpy.int), filter_size) if morphing_size: shadows = morph_dilation(shadows, morphing_size) return shadows
def cloud_mask_array( image_difference_array, threshold=30000, filter_size=13, morphing_size=0): # TODO: Is it 0 in morphing_size?? is not 10?? ''' This method returns a mask for the given array, it stacks all the bands into one and filters values that match the threshold. The new array will be filled with 0 when the values are below the threshold and 1 when the values are above the threshold. We assume that clouds will have brighter values when compared to the reference array. ''' clouds = filter_median( (numpy.sum(image_difference_array, axis=0) > threshold).astype( numpy.int), filter_size) if morphing_size: clouds = morph_dilation(clouds, morphing_size) return clouds