Ask Your Question

Is there any openCV functionality that finds differences in images?

asked 2015-01-28 13:42:30 -0500

Potato gravatar image

I want to have a base image, say a picture of an empty theater. Another test image, the same theater with one person sitting on a seat. The output should circle the person showing that, that is the difference in the two images. Is there any functionality that would support this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-28 14:42:36 -0500

Guanta gravatar image

Of course you can subtract two images using OpenCV. Something like this should work:

cv::Mat1f img1 = cv::imread("image1.png", cv::LOAD_IMAGE_GRAYSCALE);
cv::Mat1f img2 = cv::imread("image2.png", cv::LOAD_IMAGE_GRAYSCALE);

cv::Mat1f sub = img1 - img2; // Now all pixels != 0 are different pixels

From here on you can proceed further, some possible involved steps:

edit flag offensive delete link more


Great! Thank you for your help. I was able to achieve what I wanted to do.

Potato gravatar imagePotato ( 2015-01-29 15:35:33 -0500 )edit

Question Tools

1 follower


Asked: 2015-01-28 13:42:30 -0500

Seen: 266 times

Last updated: Jan 28 '15