Ask Your Question

most frequently occurring value in 2D matrix

asked 2014-10-11 21:20:39 -0600

Eng Hind gravatar image

Hi , I want to find the most frequently occurring value in a 2D matrix. i was trying to use std::max_element but it didn't work because it is only works with a one dimension vector .. could anybody help me please ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-10-12 05:33:21 -0600

A cv::Mat has a member variable 'data' that contains all values in a 1d-array so you can use it as argument. But how do you use std::max_element to get the most frequently value?

edit flag offensive delete link more


Like FooBar said, the function simply points to the element with the largest value not with the most occuring value. I can confirm that the data variable is a 1D array in memory and can thus be accessed that way.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-12 07:14:07 -0600 )edit

yes i know that max_element points to the largest value not with the most .. i have a vector with counters points to different values .. then i was trying to find the max counter value that will let me know most frequently value .. this the idea that i was trying to apply it .

Eng Hind gravatar imageEng Hind ( 2014-10-14 09:50:35 -0600 )edit

Question Tools

1 follower


Asked: 2014-10-11 21:20:39 -0600

Seen: 749 times

Last updated: Oct 12 '14