Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- image_test = params.small_images[0]
- mask = np.zeros(image_test.shape, dtype=np.uint8)
- roi_corners = np.array([[0, 14], [13.33, 28], [26.66, 28], [39, 14], [26.66, 0], [13.33, 0]], dtype=np.int32)
- # fill the ROI so it doesn't get wiped out when the mask is applied
- channel_count = image_test.shape[2] # i.e. 3 or 4 depending on your image
- ignore_mask_color = (255,)*channel_count
- cv.fillConvexPoly(mask, roi_corners, ignore_mask_color)
- # apply the mask
- masked_image = cv.bitwise_and(image_test, mask)
- # save the result
- cv.imwrite('image_masked.png', masked_image)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement