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

前端 未结 4 847
北海茫月
北海茫月 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:10

    If the background in the two images are exactly the same, you can subtract them as you mention in your post.

    image1 = imread("/path/to/image1")
    image2 = imread("/path/to/image2")
    image3 = image1 - image2
    

提交回复
热议问题