Adjusted the parameters to operate on the original image dimensions