I am using cv2::absdiff()
for subtracting a scalar from an image Matrix. The code I am using is:
double min;
double max;
Scalar mean;
Scalar std_dev;
minMaxLoc(img_a_color_planes[1], &min, &max);
meanStdDev(img_a_color_planes[1], mean, std_dev);
Mat img_a_color_planes[3];
split(img_a, img_a_color_planes);
Mat oper = img_a_color_planes[1];
absdiff(oper, mean, oper);
divide(oper, std_dev, oper);
multiply(oper, 10, oper);
add(oper, mean, oper);
In here, I specifically copied the green channel of img_a
into the Mat oper
, inspite of output matrix oper
being specified in absdiff
. Even then, the green color channel img_a_color_planes[1]
is being affected. I don't understand the reason for this. How can I avoid this?
Here is how my img_a
is getting affected after the absdiff
operation:
Initial img_a
: