Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pixelwise subtract, with negative numbers

I would like to implement the following pixelwise operation between two images:

  • Subtract the pixels (RGB) (important: if the result is negative, keep it)
  • Convert to absolute value (RGB)
  • Somehow merge the three channels (for starter, I use the cv::COLOR_RGB2GRAY which is a weighted add)

But, the problem is, that the cv::substract() and the operator - on cv::Mat fails to calculate negative values, and uses 0 instead.

How can I easily implement the behavior I need?