Differences between two photos

Hey guys! I'm new on matlab and I'm trying to do one thing, but I do not get it. The problem is that, for example, imagine there is a table and we take a photo. After this we put some element above the table ,for example, an apple and we take another photo. So, the question is, How can I determine the ROI (Region Of Interest) from the difference between the two images?
I was reading about roifilt2, roicolor... but I do not know how to apply that to it.
Thank you, kss!! =)

 Accepted Answer

Try simply subtracting the images.
diffImage = double(image1) - double(image2);
imshow(diffImage, []);
Casting to double is important otherwise you will never get negative numbers. Also, the [] in imshow() lets you see both positive and negative numbers. If you want a binary image and have a color image, then you can use the max function, something like
diffImage = max(abs(diffImage), [], 3) % For a color image.
Nothing more to do for a gray scale image. Then
binaryImage = abs(diffImage) > 5; % Or whatever number works.

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!