Monday, December 5, 2011

Fade-in, Fade-out, Dissolve video effects





When working on videos (stacks in ImageJ), it is always interesting to make transitions between video clips to finalize a small movie .... and that's possible with ImageJ.


1- Fade-in / Fade-out

Fade-in and fade-out are two basic video effects consisting of a smooth transition from or to a black image, respectively.
Fade-in: from a black image, the image is progressively appearing.
Fade-out: The image is slowly disappearing leading to a black image. This is often used at the end of a movie.
In terms of image processing, this transition is done by linearly interpolating your image with a black one and that's really easy to do with ImageJ...

Fig.1: RGB image of 320x180 (16/9 ratio)
  1. Download this image and open it in ImageJ
  2. Check that this image is of RGB type.
  3. Add a black slice (Image > Stacks > Add Slice)
  4. Then, the fade-out effect is done by interpolating the title image with the black slice thanks to the function Scale (Image > Scale...). 
  5. Check that the interpolation scheme is Bilinear and enter in Depth (Images) text field, the number of frames you need for the transition. I choose 40 frames.
  6. Et VoilĂ !
This can be summarized in a small script...

+++ IJ snippet +++ +++ End of IJ snippet +++

To get the fade-in effect, reverse the stack with Image > Stacks > Tools > Reverse function.

2- Dissolve (or cross-fade) effect

Using the same principle, the dissolve effect is a transition calculated between two images. Here is an example... 
Fig.2: RGB montage to compute the dissolve effect between these two images. The image #2 is a scaled and cropped version of the Embryos image available in the Samples directory.
First, after downloading the image of Fig.2, let's convert the montage into a stack by using the function Image > Stacks > Tools > Montage to Stack...
Fig.3: function Montage to Stack... to convert the Fig. 2 into a stack.
Then, scale this 2-frames stack to get a 40-frames transition. If you think that's too fast (or too slow), modify the Z-scaling factor. The following movie was carried out with a transition of 80 frames... and saved with 25 fps.




Hope that helps!




No comments:

Post a Comment