Ask Your Question

Revision history [back]

click to hide/show revision 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);

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];

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)