【发布时间】:2015-03-09 16:38:21
【问题描述】:
这是我的matlab代码:
imageData = imageData ./ toolbox.c3d.p.tprctile(imageData(xy),99.2);
imageData(imageData>1) = 1;
这是我的 openCV/c++ 代码,矩阵 dst 是一个 openCV 矩阵
cv::Mat dst
std::vector<float> result;
for (std::vector<int>::iterator it = index.begin() ; it != index.end(); ++it)
{
int ind = *it;
float temp = dst.at<float>(ind - 1);
result.push_back(temp);
}
float divider = tprctile(result,99.2);
dst = dst/ divider;
百分位数的效用函数
float Utils::tprctile(std::vector<float> channel, double pt)
{
std::sort(channel.begin(),channel.end());
int ptInd = Utilities::MatlabRound (pt/100 * channel.size() );
return channel[ptInd];
// Matlab code
// function val = tprctile(data, pt)
// data = sort(data);
// ptInd = round( pt/100 * length(data) );
// val = data(ptInd);
}
我的问题是关于imageData(imageData>1) = 1
实现此功能的最有效方法是什么 - 我当然可以像我一样遍历 dst 。有没有更好的办法?
【问题讨论】:
标签: c++ matlab opencv optimization