Applying Spatial Pyramid Pooling on a region of feature map

How to implement the region Spatial Pyramid Pooling as shown in the figure? How existed implementation are all suitable for the entire feature map.