mymesh.image.read#
- mymesh.image.read(img, scalefactor=1, scaleorder=1)[source]#
Read image data into a numpy array format. Data can be input as an existing image array (in which case the only operation will be scaling), a file path to either a single image file or a directory of images, or a list of file paths to image files.
- Parameters:
img (str, list, or np.ndarray) – If given as a string, file path to image directory or file. If given as a list, treated as a list of file paths. If given a numpy array, assumed to be an image data matrix and only scaling will be performed (if scalefactor != 1).
scalefactor (float, optional) – Scale factor for resampling the image. If greater than 1, there will be more than 1 elements per voxel. If less than 1, will coarsen the image, by default 1.
scaleorder (int, optional) – Interpolation order for scaling the image (see scipy.ndimage.zoom), by default 1. Must be 0-5.
- Returns:
I – Image data array. For images with multichannel (e.g. RGB) data, this will be a tuple of arrays. For 3D image data separate files are assumed to be “z-slices”, and are stored along the first axis of the image matrix (i.e. slice0 = I[0,:,:]), so the 0, 1, 2 axes correspond with z, y, x.
- Return type:
np.ndarray or tuple of np.ndarray