opencv przekonwertuje czarne piksele na białe

import cv2

img = cv2.imread("path/to/image")

th = 20 # defines the value below which a pixel is considered "black"
black_pixels = np.where(
    (img[:, :, 0] < th) & 
    (img[:, :, 1] < th) & 
    (img[:, :, 2]  th)
)

# set those pixels to white
img[black_pixels] = [255, 255, 255]
wolf-like_hunter