I have an image stored in a 2D numpy array. I want to extract all pixel values in a rectangle from that array. The rectangle is defined as ((x1,y1),(x2,y2)) where all x and y s are naturally array indices.
I can extract the pixel values using a nested for loop, but what would be a pythonic way to do this?