image_fft.py 556 B

123456789101112131415161718
  1. # 2D Fast Fourier Transform of a image
  2. from vedo import Image, show
  3. url = 'https://vedo.embl.es/examples/data/images/dog.jpg'
  4. img = Image(url).resize([200,None]) # resize so that x has 200 pixels, but keep y aspect-ratio
  5. img_fft = img.fft(logscale=12)
  6. img_fft = img_fft.tomesh().cmap('Set1',"RGBA").add_scalarbar("12 log(fft)") # optional step
  7. show([
  8. [img, f"Original image\n{url[-40:]}"],
  9. [img_fft, "2D Fast Fourier Transform"],
  10. [img.fft(mode='complex').rfft(), "Reversed FFT"],
  11. ],
  12. N=3, bg='gray7', axes=1,
  13. ).close()