1 | initial version |
it's probably far easier, if you extract the L channel, and work on that:
Mat bgr = .... ?
Mat hls;
cvtColor(bgr, hls, COLOR_BGR2HLS);
Mat L;
extractChannel(hls, L, 1);
// find min / max:
double m,M;
minMaxLoc(&m,&M, 0,0);
// find mean / stddev:
Scalar mu,dev;
meanStdDev(L,mu,dev);
2 | No.2 Revision |
it's probably far easier, if you extract the L channel, and work on that:
Mat bgr = .... ?
Mat hls;
cvtColor(bgr, hls, COLOR_BGR2HLS);
Mat L;
extractChannel(hls, L, 1);
// find min / max:
double m,M;
minMaxLoc(&m,&M, 0,0);
// find mean / stddev:
Scalar mu,dev;
meanStdDev(L,mu,dev);
meanStdDev(L, mu, dev);
double mean = mu[0];
3 | No.3 Revision |
it's probably far easier, if you extract the L channel, and work on that:
Mat bgr = .... ?
Mat hls;
cvtColor(bgr, hls, COLOR_BGR2HLS);
Mat L;
extractChannel(hls, L, 1);
// find min / max:
double m,M;
minMaxLoc(&m,&M, 0,0);
// find mean / stddev:
Scalar mu,dev;
meanStdDev(L, mu, dev);
double mean = mu[0];
also, the peak of a normalized histogram is NOT the average value of the image.
(and i think, you should not use histograms here at all)