# Subtracting one image from another?



## magicdrshoon (Aug 3, 2011)

Hello one and all!

I am trying to automatically measure the size of an object using imaging.

I was hoping there would be a fairly straight forward way of taking a picture without the object in view (to create a 'control' image), take another picture with the object in view, and then subtract one image from another leaving only the object.

Or maybe some way of saying "if pixel x1/y1 of image 1 equals (with tolerance) pixel x1/y1 of image 2 then do not show pixel in new image, if not then show in new image"

The camera would be in a fixed position to maintain position.

I'm willing to buy software if there is something that does the job. We have several of the usual packages already (Photoshop, PSP etc.).

Thanks for your help!


----------



## Laxer (Dec 28, 2010)

Photoshop has a "difference" blending option.

So if you created two layers (control + test) and put the blending option to difference you might be able to achieve what you are looking for.

(The above would have problems with change in lighting)

Not sure how you would measure the size.....

If you provide us 2 images(control+test) we may be able to assist your more.


----------



## magicdrshoon (Aug 3, 2011)

I had a quick play with what you sugested, but I couldn't get any results. I am however a novice user!

I've attached a couple of images I've been playing with.

The idea being that a third image would be created showing only the difference, i.e. the package.

The sizing aspect we can deal with, it's just this first step I'm having trouble with.


----------



## Laxer (Dec 28, 2010)

Hello magicdrshoon,

Here is the results of a quick attempt at what you are going for:










Here is how I did it->

‪TSF - Subtracting one image from another?‬‏ - YouTubeTo view detail on the video turn up the quality(1080P) and watch it full screen​*1.* Open up the two images in Photoshop
*2.* Take the image with the object in it and copy it.
*3.* paste it twice into the control image
*4. *make one of the test layers invisible
*5.* on the top most layer set the blending options to "difference"
*6.* merge the control and test image.
*7.* use the magic wand to select the outside of the object(tolerance may need to be adjusted)
*8.* inverse the section
*9.* make the invisible test layer visible and copy the image
*10.* paste it into a new sheet and save it.

Maybe one of my team members will have an easier solution :4-dontkno


----------



## magicdrshoon (Aug 3, 2011)

Hi. thanks for your help.

A friend has pointed me towards something called OpenVC which I am looking into.

Essentially I need to be able to do this from within another piece of software which with be custom built.

I'll keep this thread posted with any developments in case anyone else is interested.


----------



## Laxer (Dec 28, 2010)

Good luck with your development!

Let me know how progress comes along!


----------

