refactoring ReinhardTMO.m