Q:

Add blur/gradient to image outside of mask in python

I have a bounding box whose coordinates are given by (x, y, w, h) where x and y are top-left coordinates of the box.  I'd like to apply a blur or gradient outside the box.  How would I create a mask using the coordinates above and apply this effect outside the mask with either PIL or cv2 similar to the image below? 

A:

Here is an example, I think that should be helpful to adapt it to your program. 
import cv2
original = cv2.imread("spidy.png", 3)
blurred = cv2.GaussianBlur(original, (25,25), 0)

original[0:500, 0:500] = blurred[0:500, 0:500]
cv2.imwrite('cvBlurredOutput.jpg', original)

1) First read Image
2) Blur it, the parameter (25,25) is the blur kernel, basically the width/height of your "blur Brush"
3) finally copy the region of interest from the blurred to the original

