Efficiently converting color to transparency in python
问题 GIMP has a convenient function that allows you to convert an arbitrary color to an alpha channel. Essentially all pixels become transparent relative to how far away from the chosen color they are. I want to replicate this functionality with opencv. I tried iterating through the image: for x in range(rows): for y in range(cols): mask_img[y, x][3] = cv2.norm(img[y, x] - (255, 255, 255, 255)) But this is prohibitively expensive, it takes about 10 times longer to do that iteration than it takes