load_tiff#
- deepinv.utils.load_tiff(fname, dtype=None)[source]#
Load image or volume from a TIFF file as a torch tensor.
Integer images are normalized to the range
[0, 1]by dividing by the maximum value representable by their dtype; floating point images are cast as-is (values are preserved, but the dtype is recast to float64). 2D images of shape(H, W)are loaded with a single channel, and 3D arrays of shape(H, W, C)are converted to channel-first(C, H, W). In both cases a leading batch dimension is added.Warning
Requires
tifffileto be installed. Install it withpip install tifffile.- Parameters:
fname (str, pathlib.Path) – path to TIFF file or buffer.
dtype (torch.dtype) – if not
None, cast the output tensor to this dtype. IfNone(default), the tensor is returned astorch.float64regardless of the TIFF’s original dtype (e.g. afloat32TIFF is upcast); passdtype=torch.float32to match the dtype commonly used in the library and PyTorch.
- Returns:
torch.Tensorof shape(1, C, H, W)and dtypetorch.float64unlessdtypeis specified.- Return type:
Examples using load_tiff:#
Low-intensity STED fluorescence microscopy denoising