-
Notifications
You must be signed in to change notification settings - Fork 393
Description
Bug description: If you try to use the save_movie=True parameter in the movie.play() function you get the correct preview, but the saved AVI file looks completely black. This happens with both opencv backends.
Minimal working example:
import numpy as np
import caiman as cm
movie = cm.movie(np.random.rand(150, 300, 300))
movie.play(save_movie=True, plot_text=True)Possible Fix: Before playing the movie, the code seems to normalize the frame range to be between 0 and 1 (for offset=0 and gain=1). And afterwards, at least in the embed_opencv backend, it scales the data back to span the uint8 range.
However, this is not done when saving the file. So changing this line to
frame = np.clip((frame * 255.), 0, 255).astype('u1')seems to fix the problem. This uses the same scaling and clipping as used to display the preview (I was not sure what the expected behavior would be when gain != 1 or offset != 0).
@pgunn is there any chance I could get an early release with this fix? Thanks! (I can submit a pull request.)