Image Loading and Saving
- hugheslab.im_file_tools.load_image(filename)
Loads an image or stack of images from a file.
- Arguments:
- filenamestr or Path
path to file
- Returns:
ndarray : 2D, 3D or 4D numpy array representing image or stack
- hugheslab.im_file_tools.save_image16_scaled(img, filename)
Saves image as 16 bit tif with scaling to use full dynamic range.
- Arguments:
- imgndarray,
input image as 2D numpy array
- filenamestr
path to save to, folder must exist
- hugheslab.im_file_tools.save_tif_stack(stack, filename, bit_depth=16, auto_contrast=None, fixed_min=None)
Writes stack of images from 3D numpy array to file. The array must be ordered (frame, y, x).
- Arguments:
- stackndarray
3D numpy array (frame, y, x)
- filenamestr or Path
path to file name. Folder must exist.
- Keyword Arguments:
- bit_depthint
8 or 16 (default)
- auto_contraststr or None
Whether or not to scale images to use full bit depth ‘image’ to autoscale each image individually ‘stack’ to autoscale entire stack None or ‘none’ for no autoscaling
- fixed_minint or None
if auto_contrast is ‘image’ or ‘stack’, setting this value fixed the lower range of the saved image pixel values rather than taking the minimum from the images.
- hugheslab.im_file_tools.load_folder_images(folder, numeric_sort=True)
Loads all images in a folder and stores them as a 3D or 4D numpy array, depending on whether they are monochrome or colour images. All images must be the same size.
- Arguments:
- folderstr
path to folder
- hugheslab.im_file_tools.folder_to_tif_stack(folder, tif_file)
Loads all images in a folder and saves them as a 16 bit tif stack.
- Arguments:
- folderstr
path to folder
- tif_filestr
path to tif file to save to
- hugheslab.im_file_tools.tif_stack_to_folder(tif_file, folder)
Loads a 16 bit tif stack and saves the images to a folder as 16 bit tifs.
- hugheslab.im_file_tools.save_video(stack, filename, fps=30, auto_contrast=None, fixed_min=None)
Saves a stack of images as a video file.
- Arguments:
- stackndarray
3D numpy array (frame, y, x)
- filenamestr
path to save to, folder must exist
- Keyword Arguments:
- fpsint
frames per second, default is 30
- auto_contraststr or None
Whether or not to scale images to use full bit depth ‘image’ to autoscale each image individually ‘stack’ to autoscale entire stack None or ‘none’ for no autoscaling
- fixed_minint or None
if auto_contrast is ‘image’ or ‘stack’, setting this value fixes the lower range of the saved image pixel values rather than taking the minimum from the images. Default is None.