7

I'm not sure how to get a "fade in" effect.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
M.R.
  • 31,425
  • 8
  • 90
  • 281

2 Answers2

12

Start from understanding and setting up an transition functions sequence:

Plot[Evaluate@Table[(1 + Tanh[tr (x - dt n)])/2, {n, 1, Length[imgs], 1}], {x, 0, 
  dt (Length[imgs] + 1)}, PlotStyle -> Thick]

enter image description here

Set your images as a list:

enter image description here

Set 2 main parameters of your animation:

tr = 1;(* transition speed *)
dt = 4;(* display time *)

Finally use interactive interface

Animate[Overlay[Table[SetAlphaChannel[imgs[[n]], (1 + Tanh[tr (x - dt n)])/2], {n, 1, 
    Length[imgs], 1}]], {x, 0, dt (Length[imgs] + 1), 
  ImageSize -> Small}, AnimationRate -> 2]

enter image description here

Or make a table and export as an .GIF image

gift = Table[Overlay[Table[SetAlphaChannel[imgs[[n]], (1 + Tanh[tr (x - dt n)])/2], {n,
       1, Length[imgs], 1}]], {x, 0, dt (Length[imgs] + 1), 
    dt (Length[imgs] + 1)/50}];

Export["MyVacationSlideShow.gif", gift]
Vitaliy Kaurov
  • 73,078
  • 9
  • 204
  • 355
4

Vitaliy has a great answer, however I wanted to try my hand at this to get something a bit smoother in action by using Dynamics...

images = ImageResize[#, 500] & /@ ExampleData /@ ExampleData["TestImage"][[1 ;; 7]];
i = 1;
Dynamic[
    Which[Or @@ Thread[i == Range[Length[images]]], Pause[2]; i += .01, 
      i < Length[images] - 1, i += .01, 
      True, i = 1]; fade = Mod[i, 1];
 ImageCompose[images[[IntegerPart[i]]], {images[[IntegerPart[i] + 1]], fade}]
]

This works, but can someone please tell me why I can't substitute IntegerQ[i] for Or @@ Thread[i == Range[Length[images]]]?

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
M.R.
  • 31,425
  • 8
  • 90
  • 281