Made some changes in ImagePreProcessing function