Text this: A new algorithm for detecting and correcting bad pixels in infrared images