c++ - cvGetHistValue_1D is deprecated. What is to be used instead? -


according latest opencv (opencv 2.4.5) documentation, cvgethistvalue_1d has been deprecated imgproc module, , part of legacy module.

i know should used instead of cvgethistvalue_1d if not plan use legacy module.

my previous code under, needs rewritten without use of cvgethistvalue_1d

cvhistogram *hist = cvcreatehist(1, &numbins, cv_hist_array, ranges, 1); cvclearhist(hist);  cvcalchist(&odepth,hist); cvnormalizehist(hist, 1.0f); float *cumhist = new float[numbins]; cumhist[0] = *cvgethistvalue_1d(hist, 0); for(int = 1; i<numbins; i++) {     cumhist[i] = cumhist[i-1] + *cvgethistvalue_1d(hist, i);      if (cumhist[i] > 0.95)     {         omaxdisp = i;         break;     } } 

i assuming interested in using c++ api. matrix element access accomplished using cv::mat::at().

your code might this:

cv::mat image;    //already in memory size_t omaxdisp = 0; cv::mat hist;  //setup histogram parameters const int channels = 0; const int numbins = 256; const float rangevals[2] = {0.f, 256.f}; const float* ranges = rangevals;  cv::calchist(&image, 1, &channels, cv::noarray(), hist, 1, &numbins, &ranges); cv::normalize(hist, hist,1,0,cv::norm_l1);  float cumhist[numbins]; float sum = 0.f; (size_t = 0; < numbins; ++i) {     float val = hist.at<float>(i);     sum += val;     cumhist[i] = sum;      if (cumhist[i] > 0.95)     {         omaxdisp = i;         break;     } } 

as side note, it's idea not use new unless necessary.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -