This is probably something very simple, but I have wasted a day and more working on it, and am no closer to a solution. I have a snippet of Python that:
- opens an image file
- calculates the FFT and shifts the origin
- displays the FFT
- allows user to mark points
- operates on those points
- draws results of the operations back to the FFT window
The details of steps 5 and 6 are irrelevant. The FFT display opens in a small window that I can manually maximize in order to make the point marking more precise.
I am trying to automatically maximize the FFT display before I start marking points, but none of the approaches I have tried work.
Here is the code I have used:
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
image = Image.open('file.tif') # step 1
dft = np.fft.fft2(image)
dft = np.fft.fftshift(dft, axes=(-2,-1)) # step 2
fig, ax = plt.subplots()
ax.imshow(np.log(np.abs(dft) ** 2)) # step 3
pts = plt.ginput(n = -1, timeout = -1,
show_clicks = True, mouse_add = 1,
mouse_pop = 2, mouse_stop = 3 ) # step 4
"""
[ manipulate pts data ] # step 5
[ draw things in FFT display with plt.plot() ] # step 6
"""
plt.show()
I can maximize the window at the very end by inserting:
manager = plt.get_current_fig_manager()
manager.full_screen_toggle()
just above plt.show(), but I want to maximize it before the plt.ginput() step. Nothing I have tried impacts the size of the FFT display and allows everything else to proceed. For example, I can insert the widow maximizing and plt.show() commands before the plt.ginput() call, but that seems to block the point marking completely.
David is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.