Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

With help from online article Python numpy array with multiple conditions to iterate over image

I was able to extract each BGR value then work on them to accomplish the same task on same image in around 4000 milliseconds

Here's the code

TOL = 90**2

#((c_r - ref_r).^2 + (c_g - ref_g).^2 + (c_b - ref_b).^2)
Res = (img[...,0]-[122])**2+(img[...,1]-[112])**2+(img[...,2]-[96])**2

#<= tolerance^2 then 255
Res1 = cv2.bitwise_not(Res.astype(np.uint8))
Res1 = cv2.merge((Res1,Res1,Res1))
Trest = cv2.bitwise_and(img,Res1)