It looks like there are a couple of ways to speed up what you're trying to do. getImageData is pretty slow, and putImageData is frustratingly slow so eliminating those calls will always serve you well. You're right to forget about the red channel. I'd also get rid of this line:
var r = history[0].getContext('2d').getImageData(0, 0, w, h).data;
Also, you should be able to draw the canvas to the appropriate context, so long as you clear the context. I believe your try statement should look like:
try {
ctxCurr.clearRect(0, 0, w, h);
ctxCurr.drawImage(history[i-1], 0, 0);
}
Removing all of those redundant calls to putImageData should help a lot.