Changing color from image
Hi all,
I am trying to swap certain colors in an image for another color. I have installed opencv on Open Sesame, but still I can't seem to get the following code running:
import numpy as np
import cv2
im = cv2.imread('your_input_image.png')
im[np.where((im == [0,0,0]).all(axis = 2))] = [0,33,166]
cv2.imwrite('your_output_image.png', im)
Everytime I get the following error: AttributeError: 'bool' object has no attribute 'all'
I have tried several things but I can't find the solution. Any advice how to run this code or another way how to swap colors in images would be greatly appreciated!
I have attached the image I am using to this post.
BJ
Comments
I meant to attach this file:
Hi,
Can you try whether this code does the trick:
im[np.where((np.all(im == [0,0,0],axis = -1)))] = [0,33,166](from here)
Eduard