def np_to_pil(x): """Converts from np image in skimage float format to PIL.Image""" x = np.squeeze(np.uint8(img_as_ubyte(x))) return Image.fromarray(np.uint8(img_as_ubyte(x)))