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

前端 未结 4 2050
清歌不尽
清歌不尽 2021-02-19 18:26

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:07

    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
    

提交回复
热议问题