tried to fix histogram method
only draw image if debug is enabled