grayscaling and filtering input image