user3539646
user3539646

Reputation: 5

Finding the median value of an RGB image in OpenCV?

Is there any easy way of finding the median value of a RGB image in OpenCV using C? In MATLAB we can just extract the arrays corresponding to the three channels and compute median values for each of the arrays by median(median(array)). Finally, the median value of these three medians (for three channels) can be calculated for the final median value.

Upvotes: 0

Views: 12321

Answers (1)

cassandracomar
cassandracomar

Reputation: 1519

You can convert the matrix to a histogram via the calcHist function (once for each channel), then calculate the median for a given channel by using the function available here.

Note: I have not tested that linked code, but it should at least give you an idea of how to get started.

Upvotes: 3

Related Questions