I don't think the integral image is the most adequate tool for this task. Detection of intensity changes in a ROI can be easily implemented by comparing the intensity values within the ROI through Numpy's any
and slicing as shown below.
To begin with, we import the necessary modules and load some sample images:
import numpy as np
from skimage import io
import matplotlib.pyplot as plt
reference = io.imread('https://i.stack.imgur.com/9fmvl.png')
same = io.imread('https://i.stack.imgur.com/u1wlT.png')
changed = io.imread('https://i.stack.imgur.com/H2dIu.png')
This is how the images look:
fig, [ax0, ax1, ax2] = plt.subplots(1, 3)
ax0.imshow(reference)
ax0.axis('off')
ax0.set_title('Reference')
ax1.imshow(same)
ax1.axis('off')
ax1.set_title('Same')
ax2.imshow(changed)
ax2.axis('off')
ax2.set_title('Changed')
plt.show(fig)

Then we define a function that returns True
whenever there is at least one ROI pixel whose intensity in the test image is different to that of the reference image:
def detect_change(ref, img, roi):
upper, left, lower, right = roi
return np.any(ref[upper:lower, left:right] != img[upper:lower, left:right])
Finally we just need to set up the ROI (the red square) and call detect_change
with proper arguments:
In [73]: roi = [32, 32, 96, 96]
In [74]: detect_change(reference, same, roi)
Out[74]: False
In [75]: detect_change(reference, changed, roi)
Out[75]: True