PIL Cannot Handle This Data Type

前端 未结 1 1994
孤城傲影
孤城傲影 2020-12-17 00:25

I\'m attempting to use the fft module in numpy:

import Image, numpy

i = Image.open(\'img.png\')
a = numpy.asarray(i, numpy.uint8)

b = abs(numpy.fft.rfft2(a         


        
相关标签:
1条回答
  • 2020-12-17 01:20

    I think perhaps the rfft2 is being performed over the wrong axes. By default, it uses the last two axes: axes=(-2,-1). The third axis represents the RGB channels. Instead, it seems more plausible that one would want to perform an FFT over the spatial axes, axes=(0,1):

    import Image
    import numpy as np
    
    i = Image.open('image.png').convert('RGB')
    a = np.asarray(i, np.uint8)
    print(a.shape)
    
    b = abs(np.fft.rfft2(a,axes=(0,1)))
    b = np.uint8(b)
    j = Image.fromarray(b)
    j.save('/tmp/img2.png')
    
    0 讨论(0)
提交回复
热议问题