First time here? Check out the FAQ!

Ask Your Question
2

Background subtraction using single image

asked Jun 13 '13

arablau gravatar image

Hi Everyone,

I'm working on a project where I am photographing products like this purse below. image description

I want to remove the background and have been trying a few methods but wanted to know what the community thinks is best practice.

I've been playing with different amounts of blurring, thresholding, dilating and eroding but I am not sure what combination of these measures will yield the best results.

The best I can do so far is this: image description

What are your thoughts?

Thank you all!

Preview: (hide)

Comments

remove background? there's no background, just a white background?

Shaban gravatar imageShaban (Jun 13 '13)edit

Yes, I want to remove the peach background and make all of those pixels true white. I am playing around with eroding and dilating and filtering but don't know if there is a better way to get just the object.

arablau gravatar imagearablau (Jun 13 '13)edit

Could you please share your code? I'm looking for something similar and it would be great to get a good starting point

sockeqwe gravatar imagesockeqwe (Sep 20 '14)edit

i am also interested in the code

zombodotcom gravatar imagezombodotcom (Nov 6 '18)edit

1 answer

Sort by » oldest newest most voted
2

answered Jul 31 '13

I will apply a threshold on your image, with threshold function with THRESH_TOZERO parameter. All pixel with a value greter than your threshold will be set to 0. Therefore, you will have a mask to copy only the non-zero pixel. If you want to "protect" white zone in your object, try to use findContours) and drawContours) to draw a mask of your object. The difficult part will be the threshold setting...

Preview: (hide)

Question Tools

Stats

Asked: Jun 13 '13

Seen: 2,196 times

Last updated: Jul 31 '13