I am taking a jpg image and using numpy\'s fft2 to create/save a new image. However it throws this error
\"IOError: cannot write mode F as JPEG\"
>
I think it may be that your fft_p
array is in float type and the image should have every pixel in the format 0-255 (which is uint8), so maybe you can try doing this before creating the image from array:
fft_p = fft_p.astype(np.uint8)
new_p = Image.fromarray(fft_p)
But be aware that every element in the fft_p
array should be in the 0-255 range, so maybe you would need to do some processing to that before to get the desired results, for example if you every element is a float between 0 and 1 you can multiply them by 255.