paidiverpy.colour_layer#
__init__.py for colour_layer module.
Submodules#
Classes#
ColourLayer class. |
Package Contents#
- class paidiverpy.colour_layer.ColourLayer(parameters: dict[str, object], config_params: dict[str, object] | paidiverpy.config.config_params.ConfigParams | None = None, config_file_path: str | None = None, config: paidiverpy.config.configuration.Configuration | None = None, metadata: paidiverpy.metadata_parser.MetadataParser | None = None, images: paidiverpy.images_layer.ImagesLayer | None = None, paidiverpy: paidiverpy.Paidiverpy | None = None, step_name: str | None = None, client: dask.distributed.Client | None = None, config_index: int | None = None, logger: logging.Logger | None = None, raise_error: bool = False, verbose: int = 2)[source]#
Bases:
paidiverpy.PaidiverpyColourLayer class.
This class contains the methods for processing the images in the colour layer.
- Parameters:
parameters (dict) – The parameters for the step.
config_params (dict | ConfigParams, optional) – The configuration parameters. It can contain the following keys / attributes: - input_path (str): The path to the input files. - output_path (str): The path to the output files. - metadata_path (str): The path to the metadata file. - metadata_type (str): The type of the metadata file. - track_changes (bool): Whether to track changes. - n_jobs (int): The number of n_jobs.
config_file_path (str) – The path to the configuration file.
config (Configuration) – The configuration object.
metadata (MetadataParser) – The metadata object.
images (ImagesLayer) – The images object.
paidiverpy (Paidiverpy) – The paidiverpy object.
step_name (str) – The name of the step.
config_index (int) – The index of the configuration.
logger (logging.Logger) – The logger object.
raise_error (bool) – Whether to raise an error.
verbose (int) – verbose level (0 = none, 1 = errors/warnings, 2 = info).
- static grayscale(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.GrayScaleParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Convert the image to grayscale.
Method to convert the image to grayscale.
- Parameters:
image_data (np.ndarray) – The input image.
params (GrayScaleParams, optional) – Parameters for the grayscale conversion. Defaults to GrayScaleParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – If the input image does not have 3 channels or 4 channels with alpha.
- Returns:
The updated image.
- Return type:
np.ndarray
- static gaussian_blur(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.GaussianBlurParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Gaussian blur.
Method to apply Gaussian blur to the image.
- Parameters:
image_data (np.ndarray) – The image to apply Gaussian blur.
params (GaussianBlurParams, optional) – the parameters for the method. Defaults to GaussianBlurParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Error applying Gaussian blur.
- Returns:
The updated image.
- Return type:
np.ndarray
- static sharpen(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.SharpenParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Sharpening.
Method to apply sharpening to the image.
- Parameters:
image_data (np.ndarray) – The image to apply sharpening.
params (SharpenParams, optional) – Params for method. Defaults to SharpenParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Error applying sharpening.
- Returns:
The updated image.
- Return type:
np.ndarray
- static contrast_adjustment(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.ContrastAdjustmentParams | None = None, **_kwargs: dict[str, Any]) numpy.ndarray[Any, Any][source]#
Contrast adjustment.
Method to apply contrast adjustment to the image.
- Parameters:
image_data (np.ndarray) – The image to apply contrast adjustment.
params (ContrastAdjustmentParams, optional) – Params for method. Defaults to ContrastAdjustmentParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Error applying contrast adjustment.
- Returns:
The updated image.
- Return type:
np.ndarray
- static illumination_correction(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.IlluminationCorrectionParams | None = None, **_kwargs: dict[str, Any]) numpy.ndarray[Any, Any][source]#
Illumination correction.
Method to apply illumination correction to the image.
- Parameters:
image_data (np.ndarray) – The image to apply illumination correction.
params (IlluminationCorrectionParams, optional) – Params for method. Defaults to IlluminationCorrectionParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Error applying illumination correction.
- Returns:
The updated image.
- Return type:
np.ndarray
- static deblur(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.DeblurParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Deblurring.
Method to apply deblurring to the image.
- Parameters:
image_data (np.ndarray) – The image to apply deblurring.
params (DeblurParams, optional) – Params for method. Defaults to DeblurParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Unknown PSF type. Please use ‘gaussian’ or ‘motion’.
ValueError – Unknown method type. Please use ‘wiener’.
NotImplementedError – Unknown method type. Please use ‘wiener’.
ValueError – Error applying contrast adjustment.
- Returns:
The updated image.
- Return type:
np.ndarray
- static colour_alteration(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.ColourAlterationParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Apply colour alteration to the image.
- Parameters:
image_data (np.ndarray) – The image to alter colour channel.
params (ColourAlterationParams, optional) – Params for method. Defaults to None.
**_kwargs (dict) – Additional keyword arguments.
- Raises:
ValueError – Unknown method type. Please use ‘white_balance’.
ValueError – Image is gray-scale’.
e – Error applying colour alteration.
- Returns:
The updated image.
- Return type:
np.ndarray
- static edge_detection(image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.EdgeDetectionParams | None = None, **_kwargs: dict[str, object]) numpy.ndarray[Any, Any][source]#
Edge detection.
Method to apply edge detection to the image.
- Parameters:
image_data (np.ndarray) – The image to apply edge detection.
params (EdgeDetectionParams, optional) – Params for method. Defaults to EdgeDetectionParams().
**_kwargs (dict) – Additional keyword arguments.
- Raises:
e – Error applying edge detection.
- Returns:
The updated image.
- Return type:
np.ndarray
- static get_object_features(gray_image_data: numpy.ndarray[Any, Any], label_image_data: numpy.ndarray[Any, Any], params: paidiverpy.models.colour_params.EdgeDetectionParams) tuple[dict[str, object], numpy.ndarray][source]#
Get object features.
Get the features of the object.
- Parameters:
gray_image_data (np.ndarray) – The grayscale image data.
label_image_data (np.ndarray) – The label image data.
params (EdgeDetectionParams) – The parameters for edge detection.
- Returns:
The features of the object and the binary image data.
- Return type:
- static gaussian_psf(size: list[int], sigma: float) numpy.ndarray[Any, Any][source]#
Gaussian point spread function.
Create a Gaussian point spread function (PSF).
- static motion_psf(size: list[int], length: float, angle_xy: float, angle_z: int = 0) numpy.ndarray[Any, Any][source]#
Motion point spread function.
Create a motion point spread function (PSF).
- static deconvolution(img: numpy.ndarray[Any, Any], bw_img: numpy.ndarray[Any, Any], blurd_bw_img: numpy.ndarray[Any, Any], deconv: bool, deconv_method: str, deconv_iter: int, deconv_mask_weight: float, small_float_val: float = 1e-06) numpy.ndarray[Any, Any][source]#
Deconvolution.
Perform deconvolution on the image.
- Parameters:
img (np.ndarray) – The image to deconvolve
bw_img (np.ndarray) – The binary image to use for deconvolution
blurd_bw_img (np.ndarray) – The blurred binary image to use for deconvolution
deconv (bool) – Whether to perform deconvolution
deconv_method (str) – The method to use for deconvolution
deconv_iter (int) – The number of iterations for deconvolution
deconv_mask_weight (float) – The weight for the deconvolution mask
small_float_val (float, optional) – The small float value. Defaults to 1e-6.
- Returns:
The deconvolved image
- Return type:
np.ndarray
- static sharpness_analysis(gray_img: numpy.ndarray[Any, Any], img: numpy.ndarray[Any, Any], features: dict[str, object], estimate_sharpness: bool = True) dict[str, object][source]#
Sharpness analysis.
Estimate the sharpness of the image using FFTs.
- Parameters:
Defaults to True.
- Returns:
The features of the image
- Return type:
- static detect_edges(img: numpy.ndarray[Any, Any], method: str, blur_radius: float, threshold: dict[str, float]) numpy.ndarray[Any, Any][source]#
Detect edges.
Detect edges in the image.
- static process_edges(edges_mag: numpy.ndarray[Any, Any], low_threshold: float, blur_radius: float) numpy.ndarray[Any, Any][source]#
Process the edges.
Process the edges using the low threshold.
- static process_edges_mean(edges_mag: numpy.ndarray[Any, Any], blur_radius: float) numpy.ndarray[Any, Any][source]#
Process the edges.
Process the edges using the mean.
- Parameters:
edges_mag (np.ndarray) – The edges magnitude
blur_radius (float) – The radius for the blur
- Returns:
The filled edges
- Return type:
np.ndarray