This forum has been archived. All content is frozen. Please use KDE Discuss instead.

histogramming in eigen

Tags: None
(comma "," separated)
johnm1019
Registered Member
Posts
46
Karma
0

histogramming in eigen

Mon Jul 23, 2012 9:08 am
Hi, I went to write some code to histogram a vector in Eigen and, knowing that Eigen generally solves my most difficult problems with ease, thought that my implementation seemed un-elegant and there is probably a better way.

thoughts?

Eigen::ArrayXf m_imageData;
image->getImage(m_imageData); // c-style get data by reference
Eigen::Array<unsigned int,1,Eigen::Dynamic> val;
val = (m_imageData / m_imageData.maxCoeff() * m_nbins).cast<unsigned int>();
for(unsigned long i=0;i<val.size();++i)
{
++m_histogram[val(i)]; //std::vector<int> m_histogram;
}


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]