Someone mention Optos? Great for killing line noise, but in this case my usual mantra of propagation delay through the Opto applies (but only because I've been bitten by Optos in the past). Arguable you should use a reverse-connected diode to avoid reverse-biasing the LED in the opto.

If you have noise on the line you really need to deal with it electrically, rather than through software, particularly with a finely crafted LUT solution as you have (I'm not taking the piss - it's a good solution here, mimicking one solution used by FPGAs for logic representation.... I'll be honest, when you first mentioned this project I was thinking it'd be a brilliant first-project for anyone looking to get into FPGAs, a Cyclone IV board will go cheap at around £20... but that sends the chat into a completely different direction and isn't really for this site) - in that case you could have easily configure for differential inputs. Anyway, as-it-is, I suppose my own view is clear from driving the spindle-encoder on the lathe - I use the MAX487 chips, on tuppeth-ha'peny Arduino RS485 interface boards to provide 120R differential drive/sinks as my weapon of choice.