3
$\begingroup$

I need some help with a program that will fill in objects that pop out from the background. For example I have this picture enter image description hereand would like to get an output like this. enter image description here I don't know how to do this though (obviously otherwise I wouldn't be asking). And I was wondering if there was some way of filling in objects that don't match the background. The only other thing is that the background isn't always going to be white for example the background could be a blue blanket with a brown dog on it. In that picture it would fill the dog in Black. The last thing about this is that the object that will be filled in will always be centered in the image.

$\endgroup$
2
$\begingroup$

Here is one simple approach:

Step 1. Find the background color. (This is an entire topic in its own right, so if you're not sure how to do this, ask a separate question about it.)

Step 2. Binarize the image so that all pixels whose color is close to the background color are white, and all pixels whose color is not similar to the background color are black. This will get you a rough approximation to what you want, but there might be holes in the middle of the black shape (e.g., if the cat was wearing a white collar).

Step 3. Apply a suitable morphological operator, e.g., the closing operator.

This approach will have some limitations, e.g., if the background is not flat but rather has shading or a gradient, but it is simple to implement and try.

If the simple approach I outlined above is not sufficient, the broad problem area you are looking at is image segmentation; you should check out the techniques that have been developed in the literature. There are many, many methods for image segmentation that you could explore. For instance, you could look at methods based upon graph cuts.

$\endgroup$
  • $\begingroup$ I added some stuff to my question. $\endgroup$ – MrQandA Nov 12 '15 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.