Ask Your Question
1

inverting the background and object colors

asked 2015-02-27 06:58:50 -0500

begueradj gravatar image

I read in documentation that:

In OpenCV, finding contours is like finding white object from black background. So remember, object to be found should be white and background should be black.

In my case, all the images I am dealing with are colorful but their background is always white. Is there any solution in OpenCV to make the background of these images black and the objects white in order to apply cv2.findCountours() function ?

edit retag flag offensive close merge delete

Comments

1

check this tutorial here

theodore gravatar imagetheodore ( 2015-02-27 07:19:10 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-02-27 20:29:16 -0500

If you provide a sample of the images you have, it'd help me to answer your question.

Do you mean and are you sure that every white pixel represents the background? If the answer is yes, then you can convert every not white pixel to be a white pixel and every white pixel to be a black pixel!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-02-27 06:58:50 -0500

Seen: 189 times

Last updated: Feb 27 '15