views:

692

answers:

2

How can I subtract one image from another using openCV?

Ps.: I coudn't use the python implementation because I'll have to do it in C++

+2  A: 

Use LoadImage to load your images into memory, then use the Sub method.

This link contains some example code, if that will help: http://permalink.gmane.org/gmane.comp.lib.opencv/36167

Justin Ethier
I'll try, my friend. Thanks
marionmaiden
+1  A: 
#include <cv.h>
#include <highgui.h>

using namespace cv;

Mat im = imread("cameraman.tif");
Mat im2 = imread("lena.tif");

Mat diff_im = im - im2;

Change the image names. Also make sure they have the same size.

Dat Chu