开发者

Get a Image Mask of the Differences Between Two Images Emgu CV

I was wondering how to take two different gray images an开发者_StackOverflow社区d create a mask of the differences between the two. Any help would be much appreciated.


Assuming the camera is stationary and the images are very well, you can find the differences between the two images using element-wise subtraction. Using OpenCV's C++ API, it would look something like this (note: this code is untested):

void FindDifference(cv::Mat src1, cv::Mat src2, cv::Mat &dst, int threshold) {
    dst = cv::abs(src2 - src1);
    cv::threshold(dst, dst, threshold, 255, cv::THRESH_BINARY);
}

You can tweak the value of threshold to reduce false positives caused by noise. If you are still getting too many false positives, you should use look into motion estimation and image registration to align the two images.

I am not familiar with EmuCV's API, but it should be fairly straightforward to translate the above code into its API calls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜