created threshold with mean filter added functionality