Here's how to "redact" portions of the image given a top-left and bottom-right corner.
import cv2
import numpy as np
# load image
img = cv2.imread("page.jpg");
# target boxes
boxes = [];
# first box
tl = [678, 325];
br = [925, 373];
boxes.append([tl, br]);
# second box
tl = [130, 403];
br = [1534, 1508];
boxes.append([tl, br]);
# redact with numpy slicing
for box in boxes:
tl, br = box;
img[tl[1]:br[1], tl[0]:br[0]] = [255, 255, 255]; # replace with white
# show image
cv2.imshow("Redacted", img);
cv2.waitKey(0);
cv2.imwrite("redacted.png", img); # save
I don't think the boxes you gave are correct. The second one is huge and the first is tiny. Here's a picture using those boxes:
This code should work for any boxes though, so just adjust the corner coordinates to the right spot and it'll work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…