# Creating a colour variation effect of the Northern Lights

As is well known (see https://www.youtube.com/watch?v=fVsONlc3OUY ), the Northern Lights or Auroral displays appear as variations of several colours (generally pale green and pink). Is there a possibility that a colour variation effect can be introduced onto an existing image of the Northern Lights using Mathematica. One possibility is to employ an animation where the pale green gradually changes to pink and vice versa. A naïve choice is as follows

   Manipulate[ImageEffect[image, {"Solarization", x}], {{x, 0.5}, 0, 1}]


where image is attached here

However the Solarization technique is not convincing. Would appreciate better techniques of showing a colour changing effect.

• A job for ColorFunction -> "AuroraColors" perhaps? Commented Oct 21, 2015 at 11:52

First, we define a suitable color function that cycles from green to purple:

cf[h_] := If[h < .5, h + .4, (1 - h) + .4]
SetAttributes[cf, Listable]


And then we apply it to the hue channel of our image:

i = Import["https://i.sstatic.net/iMzXN.jpg"];
cSep = ColorSeparate[ColorConvert[i, "HSB"]];
ct = ParallelTable[
ColorCombine[{Image[cf[Mod[ImageData[#[[1]]] + hueShift, 1]]], #[[
2]], #[[3]]} &@cSep, "HSB"], {hueShift, 0, 1 - .05, .05}];


And by exporting it as an animated gif, with Export["aurora.gif", ct] we obtain:

http://i.imgur.com/dem9fog.gifv

Update

As per @Kuba's suggestion, you can achieve a ~100x speedup if you perform the color shifting using ImageApply:

ct = ParallelTable[
ColorCombine[{ImageApply[
cf[Mod[# + hueShift, 1]] &, #1], #2, #3} & @@ cSep,
"HSB"], {hueShift, 0, 1 - .05, .05}];

• Nice +1, ImageApply will be faster, you can even use it interactively: Manipulate[ ColorCombine[{ ImageApply[cf[Mod[# + hueShift, 1]] &, #1], #2, #3 } & @@ cSep, "HSB"] , {hueShift, 0, 1 - .05, .05} ]
– Kuba
Commented Oct 21, 2015 at 12:43
• ImageApply does speed things up noticeably Commented Oct 21, 2015 at 22:59