Back to ObjectJ Examples

Stabilize Movie in Chunks

Download Stabilize in Chunks

Norbert Vischer
University of Amsterdam

version 7.2
25-june-2021

If a movie is "shaky", this macro possibly can stabilize it. You need a thresholdable particle in the image of which you asssume that it was stable during a certain time window (chunk) of the movie.

The time window is defined by two rectangular rois, a green one at the beginning and a red one at the end of the desired time frames. These two rois have same postition and size, and limit space and time within which the particle serves as fiducial point. Within the chosen roi and time window, the particle analyser detects the current x-y position of the largest particle found and identifies it as fiducial object. It records its x-y position that is later used for compensating any undesired movement. Once a chunk is stabilized, you can continue to to stabilize a different chunk using a different fiducial particle. Replace "interpolation=Bilinear" by "interpolation=None" (~line 157) if you need to avoid interpolation.

Hyperstacks:
If used for hyperstacks, fiducial objects must be in channel 1, and all other channels will undergo the same translation. Note that the hyperstack must not be 5D (i.e. either nChannels or nFrames must be 1).
Use Image>Color>Arrange Channels if necessary.

Installation:
Open StabilizeChunks-7.2.txt in ImageJ and choose menu Macros>Install Macros.

Usage:

Fig 1: Unstable movie: slice 37 was used as start point and slice 85 as endpoint.
Red (thresholded) particle inside the roi has travveled from left to right in slice 85.

Fig 2: Before translating slices 38 .. 250, the particle’s trajectory during slice 37 .. 85 is shown as segmented line, asking for confirmation (OK or Esc).