io.images¶
-
pywi.io.images.
fill_nan_pixels
(image, noise_distribution=None)[source]¶ Replace in-place NaN values in image by zeros or by random noise.
Images containing NaN values generate undesired harmonics with wavelet image cleaning. This function should be used to “fix” images before each wavelet image cleaning.
Replace NaN (“Not a Number”) values in image by zeros if noise_distribution is None. Otherwise, NaN values are replaced by random noise drawn by the noise_distribution random generator.
Parameters: - image (array_like) – The image to process. NaN values are replaced in-place thus this function changes the provided object.
- noise_distribution (pywi.denoising.inverse_transform_sampling.EmpiricalDistribution) – The random generator to use to replace NaN pixels by random noise.
Returns: Returns a boolean mask array indicating whether pixels in images initially contained NaN values (True) of not (False). This array is defined by the instruction np.isnan(image).
Return type: array_like
Notes
NaN values are replaced in-place in the provided image parameter.
Examples
>>> import numpy as np >>> img = np.array([[1, 2, np.nan],[4, np.nan, 6],[np.nan, 8, np.nan]]) >>> fill_nan_pixels(img) ... array([[False, False, True], [False, True, False], [ True, False, True]], dtype=bool) >>> img ... array([[ 1., 2., 0.], [ 4., 0., 6.], [ 0., 8., 0.]])
-
pywi.io.images.
image_files_in_dir
(directory_path, max_num_files=None, file_ext=('.fits', '.fit'))[source]¶ Return the path of FITS and Simtel files in directory_path.
Return the path of all (or max_num_files) files having the extension “.simtel”, “.simtel.gz”, “.fits” or “.fit” in directory_path.
Parameters: Yields: str – The path of the next FITS or Simtel files in directory_path.
-
pywi.io.images.
image_files_in_paths
(path_list, max_num_files=None)[source]¶ Return the path of FITS and Simtel files in path_list.
Return the path of all (or max_num_files) files having the extension “.simtel”, “.simtel.gz”, “.fits” or “.fit” in path_list.
Parameters: Yields: str – The path of the next FITS or Simtel files in path_list.
-
pywi.io.images.
load_image
(input_file_path, **kwargs)[source]¶ Return the image array contained in the given image file.
So far, this function convert all multi-channel input images as mono-channel grayscale.
The list of supported formats is available in the following page: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html
Fits format is also supported thanks to astropy.
Parameters: input_file_path (str) – The path of the image file to load Returns: The loaded image Return type: ndarray
-
pywi.io.images.
save_image
(image_array, output_file_path, **kwargs)[source]¶ Save the image array image in the given file output_file_path.
The list of supported formats is available in the following page: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html
Fits format is also supported thanks to astropy.
Parameters: - image (array_like) – The image to save
- output_file_path (str) – The destination path of the image