Probá así (no está muy optimizado, pero ahora no tengo mucho tiempo):
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rollover</title>
<script>
function toGrayScale(im){
im.style.cursor='pointer';
if(document.createElement("canvas").getContext){
if(im.gs){
im.src=im.gs;
return;
}
var ref = document.createElement("canvas");
ref.width = im.width || im.offsetWidth;
ref.height =im.height || im.offsetHeight;
var context = ref.getContext("2d");
context.drawImage(im,0,0);
var iData=context.getImageData(0,0, ref.width, ref.height);
var data = iData.data;
var length = data.length;
for (var i = 0;i<length;i+=4) {
var average = (data[i]+data[i+1]+data[i+2])/3;
data[i] = average;
data[i+1] = average;
data[i+2] = average;
}
context.putImageData(iData, 0, 0);
im.src=im.gs=ref.toDataURL();
}
}
onload=function(){
toGrayScale(document.getElementById('im'));
document.getElementById('im').style.filter='progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)'
if(document.getElementById('im').gs)
document.getElementById('im').src=document.getElementById('im').gs;
}
</script>
</head>
<body>
<img id="im" onmouseover="this.src='arwen.jpg';this.style.filter=''" onmouseout="this.src=this.gs || 'arwen.jpg';this.style.filter='progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)'" src="arwen.jpg" />
</body>
</html>