Ask Your Question

zero center normalization image

asked 2019-01-03 00:09:34 -0500

XTSR gravatar image

Hello, I need to normalize an image using zero center normalization. How to do it in OpenCV?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-01-03 00:21:14 -0500

berak gravatar image

updated 2019-01-03 00:33:18 -0500

for a float image:

img.convertTo(img, CV_32F);

you get the mean and stdev:

Scalar m,d;
meanStdDev(img, m, d);

then you subtract the mean, and divide by stdev:

img -= m;
img /= d; // but be careful, don't divide by zero here !
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-01-03 00:09:34 -0500

Seen: 42 times

Last updated: Jan 03