implementing exact histogram matching

at the moment working correctly only for reference image