1 | initial version |
the most common way to get a binary image is thresholding :
#help(cv2.threshold)
# assume, "gray" is your "mask" image above
thr, bin = cv2.threshold(gray, 0.1, 255.0, cv2.THRESH_BINARY);
print("threshold: ",thr)
(to use OTSU, you need to convert / scale to uint8 first !)
then you can mask out the unwanted parts:
#help(cv2.bitwise_or)
# assume, "img" is the bgr cloud img
mask = cv2.resize(mask, (img.shape[1], img.shape[0]))
result = cv2.bitwise_or(img, img, mask=mask);
2 | No.2 Revision |
the most common way to get a binary image is thresholding :
#help(cv2.threshold)
# assume, "gray" is your "mask" image above
thr, bin = cv2.threshold(gray, 0.1, 255.0, cv2.THRESH_BINARY);
print("threshold: ",thr)
(to use OTSU, you need to convert / scale to uint8 first !)
then you can mask out the unwanted parts:
#help(cv2.bitwise_or)
# assume, "img" is the bgr cloud img
# images did not have same size, thus:
mask = cv2.resize(mask, (img.shape[1], img.shape[0]))
result = cv2.bitwise_or(img, img, mask=mask);