Open javak87 opened 1 year ago
you can use opencv to create binary mask
` def create_mask_by_threshold(im=None, s=None, method=cv2.THRESH_BINARY, thres=220, mpath=""):
if im is None:
im = cv2.imread(os.path.join(...))
mask = 'result1.png' if s is None else os.path.join(mpath, s)
img = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) # it will be a RGB mask without cv2.COLOR_BGR2GRAY flag
blurred = cv2.GaussianBlur(img, (7, 7), 0)
_, img_masked = cv2.threshold(blurred, thres, 255, method)
cv2.imwrite(mask, img_masked)`
Great. Thanks
Dear Developer, I want to use grayscale images to train a network, after running I can see the RGB mask on grayscale images which is not my interest. I want to apply a binary mask. Here is the mask and images after masking: Images Masks
Could you please tell me how can I get rid of RGB mask and use the binary mask? Thanks