MahalanobisDistance¶
Qualified name: CDC.color_models.MahalanobisDistance
- class MahalanobisDistance(*, reference_pixels, bands_to_use=None, transform=None)[source]¶
Bases:
BaseDistance
A multivariate normal distribution used to describe the color of a set of pixels.
Methods
Calculate the color distance using mahalanobis for each pixel in the image to the reference.
Calculate covariance and average.
Create a class instance from a reference image and an annotated mask.
Create a class instance from a list of pixel values before bands_to_use and transforms are applied.
Get correct bands to use from supplied alpha channel number and the number of bands in input.
Save raw, transformed and selected bands reference pixels to csv files.
Save pixel values to csv file with tab delimiter.
Print the statistics to screen.
Attributes
Reference pixel values
Raw pixel values as reference
Transformed reference pixel values
Covariance of the reference pixels.
Average of the reference pixels.
- Parameters:
reference_pixels (np.ndarray)
transform (BaseTransform | None)
- classmethod from_image_annotation(*, reference, annotated, bands_to_use=None, alpha_channel=-1, transform=None, **kwargs)¶
Create a class instance from a reference image and an annotated mask.
- Parameters:
- Return type:
- classmethod from_pixel_values(*, pixel_values, bands_to_use=None, alpha_channel=-1, transform=None, **kwargs)¶
Create a class instance from a list of pixel values before bands_to_use and transforms are applied.
- Parameters:
- Return type:
- calculate_distance(image)[source]¶
Calculate the color distance using mahalanobis for each pixel in the image to the reference.
- get_bands_to_use(alpha_channel, number_of_bands)¶
Get correct bands to use from supplied alpha channel number and the number of bands in input.
- save_pixel_values(output_location, channel_names_in=None, channel_names_out=None)¶
Save raw, transformed and selected bands reference pixels to csv files.
- save_pixel_values_to_file(filename, values, header=None, raw=True)¶
Save pixel values to csv file with tab delimiter.