def saveImg(img,fn,enc="uint16",scale=True,maxVal=None):
"""Saves image as tif file.
``scale`` triggers the image to be scaled to either the maximum
range of encoding or ``maxVal``. See also :py:func:`scaleToEnc`.
Args:
img (numpy.ndarray): Image to save.
fn (str): Filename.
Keyword Args:
enc (str): Encoding of image.
scale (bool): Scale image.
maxVal (int): Maximum value to which image is scaled.
Returns:
str: Filename.
"""
#Fill nan pixels with 0
img=np.nan_to_num(img)
#Scale img
if scale:
img=scaleToEnc(img,enc,maxVal=maxVal)
else:
#Convert to encoding
img=img.astype(enc)
skimage.io.imsave(fn,img)
return fn
评论列表
文章目录