Freezing motion of a video sequence based on the first frame

Hello to everybody, newbie here.
I’m stuck in a problem that I think I’ve followed the wrong direction until now.
I have video sequences of ultrasound.
Each sequence is about 1000 frames.
The size of each image in the frameset is 360x520
The problem I try to solve, is that I want to take the
first frame of the grayscale sequence and register it with the rest of the frames. What I want to achieve is each pixel on the sequence of images to represent a constant spatial point . During the evolution of the image sequence, I want to compensate the movement and match each image with the first frame, discarding any points that disappear.
I started working with optical flow and video stabilization using opencv 4.2 in Python, but then I understood that stabilizing the frames and removing the jitter, is not useful in this case, because I want to fully eliminate the motion.
The processing of the videos will be offline, so I’m not too much concerned about the speed.
I attach a frame sample.
Thank you for your help.


the problem here is that those are 2d slices of a 3d scene, so any out of plane movement of the ultrasound head will change the view radically, making it impossible to register.

you would have to make sure the scanner head stays in a single plane.

stabilization is basically the right idea, whether using optical flow or feature matching or other methods. most stabilization calculates view poses relative to a reference, which form a trajectory, and then that trajectory is smoothed, so the recalculated view through time approximately follow the original camera view at that time (keeping most data in view). what you want is no smoothing at all, i.e. make the recalculated view stick to the first view.

you would want to identify (specify a mask) and possibly remove the drawn overlays because those can and will interfere with image analysis.