Considering me a noob in programming please accept my apology if my query seems to be irrelevant or too basic. Actually, I want to compare these two pictures (embedded in a single file). One has all solid white region and other one has some black patches. What I am targeting is to extract the no. of white color pixels or density of while color so that I can distinguish among these two images by getting values of white color density but I don't know if this approach is right or wrong. Right now I have a code that mask and binary inverse the input image. Here's my code Complete procedure can be seen Here
def label():
image = cv2.imread("2121.bmp")
ROIs = cv2.selectROIs("Select Rois", image)
ROIs = ROIs.tolist()
print(ROIs)
mask = np.zeros(image.shape[:2], dtype="uint8")
i = 0
for rect in ROIs:
(x, y, w, h) = ROIs[i]
i = i + 1
cv2.rectangle(mask, (x, y), (x + w, y + h), 255, -1)
cv2.waitKey(1)
masked = cv2.bitwise_and(image, image, mask=mask)
masked = cv2.threshold(masked, 100, 225, cv2.THRESH_BINARY_INV)[1] # 100, 225
cv2.imshow("Image02", masked)
cv2.waitKey(0)
label()