Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Background subtraction showing background

Solved!
Go to solution

Hi there,

 

I'm currently attempted to do background subtraction. Unfortunately instead of showing the image of the object, the program I've created is showing the background image after subtraction. I've included the jpeg images as well as my vi for this problem. Please help me! =(

Thanks

Download All
0 Kudos
Message 1 of 2
(4,607 Views)
Solution
Accepted by topic author theriver

The program is working just like you designed it.  You are subtracting the background image from the chair image.  Where the background is showing, they cancel out and you get a difference of zero.  Where the chair is, it subtracts the background from the chair (actually chair from background, I think).  Since the chair is a solid color, it is essentially subtracting a constant value from the background.  In the chair area, all that is left is a darker version of the background.

 

What you probably want is to only have the image of the chair, which is a little more complicated.  I would first use absolute difference on the two images.  The resulting image will be zero (or very close) wherever the background matches.  You should get a fairly solid image where the chair is.  Threshold this, and use binary fill holes to fill in any holes in the chair.  Then apply this image as a mask to the original chair image.  It will keep the masked area (chair) and the rest will be black.

 

Bruce

 

 

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 2
(4,604 Views)