Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is the type of your image, the standard type is unsigned char. So, you can't have negative values if the matrix type is CV_8U. You need to convert the image to a signed type, e.g. integer (CV_32S). Alternatively, you can use the function 'substract', see http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=subtract#subtract which allows to give a type for the destination matrix.