I'm doing skin detection in which I took the image and detected the face then on that image I used canny edge detection to detect all the edges and now I want to subtract ie image -canny so that I only get the skin part
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.01,
minNeighbors=3,
minSize=(60, 60)
)
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
roi_color = image[y:y + h, x:x + w]
cv2.imwrite(str(w) + str(h) + '_faces.jpg', roi_color)
status = cv2.imwrite('faces_detected.jpg', image)
cv2_imshow(image)
--- then performing canny edge detection
img = cv2.imread("132132_faces.jpg")
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
canny = cv2.Canny(img, 100, 200)
now im trying to do
np.subtract(canny,image)
to get the non skin part but since they have different shape
canny (132,132)
image (193, 261, 3)
i tried to add a new axis to canny so that they both becomes 3d but still getting the error
operands could not be broadcast together with shapes (193,261,3) (132,132,1)