pyUSID.io.image.ImageTranslator

class pyUSID.io.image.ImageTranslator(*args, **kwargs)[source]

Bases: ArrayTranslator

Translates data from an image file to an HDF5 file

Return type:

Translator object

Methods

is_valid_file

Checks whether the provided file can be read by this translator.

translate

Translates the image in the provided file into a USID HDF5 file

static is_valid_file(file_path, *args, **kwargs)

Checks whether the provided file can be read by this translator.

This basic function compares the file extension against the “extension” keyword argument. If the extension matches, this function returns True

Parameters:

file_path (str) – Path to raw data file

Returns:

file_path – Path to the file that needs to be provided to translate() if the provided file was indeed a valid file Else, None

Return type:

str

translate(image_path, h5_path=None, bin_factor=None, interp_func=Resampling.BICUBIC, normalize=False, **image_args)[source]

Translates the image in the provided file into a USID HDF5 file

Parameters:
  • image_path (str) – Absolute path to folder holding the image files

  • h5_path (str, optional) – Absolute path to where the HDF5 file should be located. Default is None

  • bin_factor (uint or array-like of uint, optional) – Down-sampling factor for each dimension. Default is None. If specifying different binning for each dimension, please specify as (height binning, width binning)

  • interp_func (int, optional.) – Default = PIL.Image.BICUBIC for pillow<9.0.0 or PIL.Image.Resampling.BICUBIC for pillow>9.0.0 How the image will be interpolated to provide the down-sampled or binned image. For more information see instructions for the resample argument for PIL.Image.resize()

  • normalize (boolean, optional. Default = False) – Should the raw image be normalized between the values of 0 and 1

  • image_args (dict) – Arguments to be passed to read_image. Arguments depend on the type of image.

Returns:

h5_main – HDF5 Dataset object that contains the flattened images

Return type:

h5py.Dataset