Histogram compensation algorithm for an efficient phase-only hologram calculation