Ask Your Question
0

Getting the (HSL conversion) Lightness average Value from an image

asked 2018-09-05 06:26:52 -0600

zms gravatar image

Hi, I have hundreds of images that need to analyze to get the max and min value. What is the best way to get the max and min value for lightness value? I had tried the example for the histogram as for this link

link for histogram

I only select channel 2 as the conversion is at HLS, channel 2 is the L.

The question, am i correct by doing like this to get the Ligtness value? If i do the histogram for RGB without conversion, it also have the same answer for Green Channel (2). I think I'm not correct.

Any input?

Thanks

image description

edit retag flag offensive close merge delete

Comments

sorry your question is not clear! Do you want to find the min & max value of a HSL image? or a BGR Image? Are you computing Histogram to find the Min max? Then you are wrong? Have you looked at this cv::min & cv::max?

Balaji R gravatar imageBalaji R ( 2018-09-05 08:03:45 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-05 08:24:51 -0600

berak gravatar image

updated 2018-09-05 10:15:56 -0600

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)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-09-05 06:26:52 -0600

Seen: 1,101 times

Last updated: Sep 05 '18