Fast Image Differencing

just wondering if anyone has some starter info on image differencing.

i have a frameOne image and a frameTwo image. frameOne is just an image of say a wall, frameTwo is an image of a person standing infront of the wall.

i would like to get the bounds of the area the person is standing by looking at the difference of the 2 images. and then maybe the silhouette ouline of the person.

as fast as posable- near or real-time would be fantastic.

In order to cut down the calculations you should first sort everything you don’t need.

Do you need color?

Do you need the full resolution?

Two downscaled grayscale images can be much easier and faster compared. The downsampling itself takes away one step as a side-fx - averaging of several pixels.

That are all hints I can offer right now, because I don’t really know what you excactly need.

edit: oh… and don’t forget a fuzzy threshold (eg more than+/- 5% differnce in brightness [grayscale])

What you are after is called a “difference key” in video land. It’s a good technique to use to try to avoid the coloured fringes (spill) that you can get with blue or green screen techniques. It requires a stationary camera though (or it gets a whole lot harder)

The simple thing to do is to get the array of raster data for the BufferedImages and then just construct a new array with pixdif[i] = pix1[i]-pix2[i];
(or set the alpha component to 255 or 0 based on the result of the difference * some threshold…)

Apply a threshold to this and scale it so you basically have a binary mask… (pixel is background or not) then you can experiment with more stuff to smooth edges and despeckle, etc. getting rid of “wholes” in the foreground where it just happens to match the same colour as what was behind may be tricky.

You didn’t say the size of the images, but I think you should be able to do 320x240 or similar at 30fps (real-time for television video) without too much effort.

nice one- me trying that at the moment… im using IR-Camera. so maybe a little faster with that… being only RED and BLACK.