I shot a timelapse out my living room window today. I set up my camera and put on a rubber band to keep the shutter button depressed. The camera ran until the battery ran out, and produced this result:
Immediately you'll notice one thing - the movie "pops" every now and then. This is caused by the automatic exposure in the camera switching to another exposure value, or switching to another white balance setting.
To correct for this, I did the following:
Let Cavg be the a color vector with the average red, green and blue intensities over the past 50 frames, including the current frame.
Compute Ccurrent, the average color vector for the current frame.
Now, multiply the current frame (channel-wise) with Cavg / Ccurrent. This forces the average channel values of the current frame to equal the average channel values over the past 50 frames.
The result looks like this in diagram form. r, g, and b are the average red, green and blue values in the input frame, while r', g' and b' are the corrected values:
The corrected movie looks like this:
If you want to compare the two movies, here they are - side by side - with the uncorrected to the left and the corrected to the right: