Preprocessing the input image