How to subtract two images using python opencv2 to get the foreground object

前端 未结 4 854
北海茫月
北海茫月 2021-02-19 18:48

Is there any way to subtract two images in python opencv2 ?

  • Image 1 : Any image (eg. a house Image) (static image)
  • Image 2 : The same Image with an Objec
4条回答
  •  甜味超标
    2021-02-19 19:17

    cv2.subtract does not work it just binds the values between 0-255 so if you wanna get negative values just convert the image from unit8 to int32 or int64. Note unint8 could only take on the values of 0-255 thus it could not handle negative values

    image1= np.int32(image1)
    
    image2= np.int32(image2)
    
    image3 = image1 - image2
    

提交回复
热议问题