Ask Your Question
0

How to keep negative value when i use substract?

asked 2014-03-22 03:38:30 -0600

wuling gravatar image

updated 2014-03-22 03:51:37 -0600

Hi all: In opencv doucument , the result of using substract link text are all positive (if image range is 0~255). How to do that i can get negative value when src1-src2 where src2 larger than src1 ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-03-22 07:02:58 -0600

Guanta gravatar image

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-22 03:38:30 -0600

Seen: 2,449 times

Last updated: Mar 22 '14