Python + OpenCV, change brightness/darkness outside a sliding window?
<p>I'm working with Python and OpenCV and I'm a newbie in both.
For my project, I need to move a sliding window over a picture; for each position of the window the area outside the window must be shown darker than the area inside the window.</p>

<p>This is the part of my code that takes care of the picture and window visualization (the valid positions for the sliding window are calculated somewhere else)</p>

<pre><code>for (x, y, window) in valid_positions:        
    if window.shape[0] != winH or window.shape[1] != winW:
       continue

    # Put here stuff to process the window content
    # i.e apply a classifier

    clone = image.copy()
    cv2.rectangle(clone, (x, y), (x + winW, y + winH), (0, 255, 0), 2)

    cv2.imshow("Window", clone)
    cv2.waitKey(1)
    time.sleep(0.025)
</code></pre>

<p>The window is created and it slides on the valid positions, so that part works well. But I have absolutely no idea on how to make the picture outside the window appear darker.</p>

<p>Any suggestions?
Thanks in advance.</p>

<p>EDIT: i forgot to add an important detail: my input images are always in black and white (not even greyscale, just black and white pixels). Maybe this makes it easier to alter the brightness/darkness?</p>