img boundary detection for cropping