this is now correctly extracting the image regions