Contours & Masks using Python & OpenCV - How to separate object from image background?

preview_player
Показать описание
Control mouse with fly swatter!

How to separate object from background using Python and OpenCV:

Here I've used an images with already defined edges for
simplicity, clarity and with didactic purposes in mind, however
this exact technique can be used to separate objects from RGB images
and place them on whatever backgrounds - it's just a matter of a few
additional steps of creating edge map from the image. It may be applied
to either photos or videos. Next tutorials would cover this topic in greater
details while in this video I wanted to emphasize the contours and masks.

00:00 Intro
00:56 Coding starts here...
01:10 Loading original image
04:18 Converting image to gray scale
05:06 Converting image to black and white
09:40 Extracting all contours
11:43 Extracting most significant contours
14:13 Traversing contours in various ways
18:29 Masking background
25:09 Placing object onto a new background
25:35 END RESULT & SUMMARY

Source code:

OpenCV Tutorials playlist:

Support the channel:
Рекомендации по теме
Комментарии
Автор

Control mouse with fly swatter!

00:00 Intro
00:56 Coding starts here...
01:10 Loading original image
04:18 Converting image to gray scale
05:06 Converting image to black and white
09:40 Extracting all contours
11:43 Extracting most significant contours
14:13 Traversing contours in various ways
18:29 Masking background
25:09 Placing object onto a new background
25:35 END RESULT & SUMMARY

monkey_see_monkey_do
Автор

Great video, chapter titles and intro all spot on man!!

python
Автор

Trully excellent...the only working solution
One big question ...suppose the image had a little more info.... like 2 little birds flying near the face (NOT on the face) ...how could I have them removed ?

johntsioumpris
Автор

How about getting binary image by canny instead of threshold and using a complicated picture! you may find it will be difficult to deal with.

jacksonwang-iris
Автор

Great tutorial! I have a question though.. how would I be able to segment an image from the background? Like if there was an object and behind it a blue background. How would I be able to just get the object without the blue background?

mikekrestas
Автор

Identify the eyes nose mouth hair in a black & white image and give it a color

naveenvarmaa
Автор

Hi great tutorial.
I have one query, in my image what I have, I'm not getting the mask at the background. It is happening on the object. So could u plz provide me ur email id or Linkdin so that I can able to tackle this issue...?

shivanshjayara
welcome to shbcf.ru