Function to return a sub-image