Extracting portions of an image