def imwrite(image, path, quality=95, **plugin_args): """Save a [-1.0, 1.0] image. Parameters ---------- quality: Quality for JEPG format. plugin_args: To be passed to skimage.io.imsave. """ iio.imsave(path, dtype.im2uint(image), quality=quality, **plugin_args)
def imencode(image, format='PNG', quality=95): """Encode an [-1.0, 1.0] image into byte string. Args: format : 'PNG' or 'JPEG'. quality : Only for 'JPEG'. Returns: Byte string. """ byte_io = io.BytesIO() image = Image.fromarray(im2uint(image)) image.save(byte_io, format=format, quality=quality) bytes = byte_io.getvalue() return bytes
def imshow(image): """Show a [-1.0, 1.0] image.""" iio.imshow(dtype.im2uint(image))
def imwrite(image, path, quality=95, **plugin_args): """Save a [-1.0, 1.0] image.""" if path[-4:] == ".png": iio.imsave(path, dtype.im2uint(image), **plugin_args) else: iio.imsave(path, dtype.im2uint(image), quality=quality, **plugin_args)
def imwrite(image, path, quality=95, **plugin_args): """Save a [-1.0, 1.0] image.""" iio.imsave(path, dtype.im2uint(image), quality=quality, **plugin_args)
def imwrite(image, path, quality=95, **plugin_args): """Save a [-1.0, 1.0] image Why ??""" #Rather safe a 0,1 grayscale img as png #Normalizing between 0 and 1 img_min, img_max = np.amin(image), np.amax(image) img = image * (1 / np.sqrt(np.square(img_max - img_min))) iio.imsave(path, dtype.im2uint(img), **plugin_args)