Implementing histogram filter