Can someone help what is wrong in code. I need code compare 2 PCB images and show where is differences. I'm new in code. Result must be to show differences in the image. I have tried everything and did not find solution.
import cv2
import numpy as np
ref = cv2.imread('Reference/Reference.jpg')
ref_gray = cv2.cvtColor(ref, cv2.COLOR_BGR2GRAY)
cv2.imshow('ref1',ref)
img = cv2.imread('WithDefects/WithDefects.jpg')
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('ref2',img)
diff = np.abs(ref_gray-img_gray)
diff_blur= cv2.medianBlur(diff, 3,3)
defects = np.where(diff_blur>50,255,0)
cv2.imshow(np.where(diff_blur>50,255,0))
cv2.imshow(diff_blur)
img_with_defects = np.where(defects == 255, (0,0,255),img)
cv2.imshow(img_with_defects)
cv2.waitKey(0)
cv2.destroyAllWindows()
I get error : line 17, in cv2.imshow(np.where(diff_blur>50,255,0)) cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'imshow'
Overload resolution failed:
- imshow() missing required argument 'mat' (pos 2)
- imshow() missing required argument 'mat' (pos 2)
- imshow() missing required argument 'mat' (pos 2)