This is the image:
I want to turn all the colours to black except yellow and tried this code but showing an error can anyone please help?
import cv2 as cv
import numpy as np
img = cv.imread('Screenshot 2022-04-10 at 10.02.19 AM.png',1)
if(img.any() == [255, 255, 0]):
cv.imshow('image',img);
else:
ret , thresh1 = cv.threshold(img,500,255,cv.THRESH_BINARY);
cv.imshow("Timg",thresh1);
cv.waitKey(0)
cv.destroyAllWindows()
The error is showing for the if conditional statement. The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Steps: TLDR;
Code
Details
Why did I do this?
The LAB color space contains 3 channels:
Since your image comprised of blue, magenta and yellow, I opted for LAB color space. And specifically the b-component because it highlights yellow color