Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- no_alpha = cv2.cvtColor(island_data, cv2.COLOR_RGBA2RGB)
- img = no_alpha.copy()
- #cv2.imshow("Image", no_alpha)
- #cv2.waitKey()
- for color in range(1, 255):
- seeds = np.argwhere(img[:, :, 2] > 250)
- if seeds.size > 0:
- seed_coord = seeds[0]
- else:
- print("gaben")
- break
- #try:
- # seed_coord = next(i for i, val in np.ndenumerate(img[:, :, 2]) if val > 250)
- #except:
- # break
- print(f"Seed Coord: {seed_coord}")
- floodval = (0, color, 0)
- lower_range = np.array([0, color, 0])
- upper_range = np.array([0, color, 0])
- print(img[seed_coord[0], seed_coord[1]])
- cv2.floodFill(img, None, seedPoint=seed_coord, newVal=floodval)
- print(img[seed_coord[0], seed_coord[1]])
- mask = cv2.inRange(img, lower_range, upper_range)
- print(seed_coord)
- cv2.imshow("image", img)
- cv2.waitKey()
- cv2.imshow("image", mask)
- cv2.waitKey()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement