I am taking a jpg image and using numpy's fft2 to create/save a new image. However it throws this error
我正在使用一个jpg图像,并使用numpy的fft2来创建/保存一个新的图像。但是它抛出了这个错误。
"IOError: cannot write mode F as JPEG"
Is there an issue with CMYK and JPEG files in PIL???
在PIL, CMYK和JPEG文件有问题吗?
p = Image.open('kibera.jpg')
bw_p = p.convert('L')
array_p = numpy.asarray(bw_p)
fft_p = abs(numpy.fft.rfft2(array_p))
new_p = Image.fromarray(fft_p)
new_p.save('kibera0.jpg')
new_p.histogram()
1 个解决方案
#1
34
Try convert the image to RGB:
尝试将图像转换为RGB:
...
new_p = Image.fromarray(fft_p)
if new_p.mode != 'RGB':
new_p = new_p.convert('RGB')
...
#1
34
Try convert the image to RGB:
尝试将图像转换为RGB:
...
new_p = Image.fromarray(fft_p)
if new_p.mode != 'RGB':
new_p = new_p.convert('RGB')
...