Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python中保存HSV转换后的图像?_Python_Python 3.x_Image Processing_Python Imaging Library - Fatal编程技术网

如何在Python中保存HSV转换后的图像?

如何在Python中保存HSV转换后的图像?,python,python-3.x,image-processing,python-imaging-library,Python,Python 3.x,Image Processing,Python Imaging Library,我正在读取RGB图像,并使用PIL将其转换为HSV模式。现在我正试图保存这个HSV图像,但我得到一个错误 filename = r'\trial_images\cat.jpg' img = Image.open(filename) img = img.convert('HSV') destination = r'\demo\temp.jpg' img.save(destination) 我得到以下错误: OSError: cannot write mode HSV as JPEG 如何保存已

我正在读取RGB图像,并使用PIL将其转换为HSV模式。现在我正试图保存这个HSV图像,但我得到一个错误

filename = r'\trial_images\cat.jpg'
img = Image.open(filename)
img = img.convert('HSV')
destination = r'\demo\temp.jpg'
img.save(destination)
我得到以下错误:

OSError: cannot write mode HSV as JPEG

如何保存已转换的图像?请帮助

简单一个…另存为numpy数组。这很好,但文件可能相当大(对我来说,它大约比jpeg图像大7倍)。你可以去numpy's
函数将其对半剪切为原始图像大小的3-4倍。不是很好,但是当你进行图像处理时,你可能会很好。

胡乱猜测-尝试保存为TIFF格式。绝大多数图像格式只处理灰色、RGB、sRGB或CMYK颜色空间。HSV是文件扩展名吗?如果你可以修改图像的
模式
属性,将其设置为
'RGB'
,你就可以保存了。无论如何,不建议将HSV图像保存为JPEG格式,压缩可能会严重损坏它。@YvesDaoust:原始图像为“RGB”。我想将图像转换为HSV,并将其保存在本地,以便在我的Web服务中进一步显示。