本文整理汇总了C++中vnl_matrix::max_value方法的典型用法代码示例。如果您正苦于以下问题:C++ vnl_matrix::max_value方法的具体用法?C++ vnl_matrix::max_value怎么用?C++ vnl_matrix::max_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnl_matrix
的用法示例。
在下文中一共展示了vnl_matrix::max_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: local_viterbi
bool rgrsn_ldp::local_viterbi(const vnl_matrix<double> & data,
double resolution,
const vnl_vector<double> & transition,
unsigned int window_size,
vnl_vector<double> & optimal_signal)
{
assert(resolution > 0.0);
assert(transition.size()%2 == 1);
const double min_v = data.min_value();
const double max_v = data.max_value();
const int nBin = (max_v - min_v)/resolution;
// raw data to probability map
// quantilization
const int N = data.rows();
vnl_matrix<double> probMap = vnl_matrix<double>(N, nBin);
for (int r = 0; r<N; r++) {
for (int c = 0; c<data.cols(); c++) {
int num = value_to_bin_number(min_v, resolution, data[r][c], nBin);
probMap[r][num] += 1.0;
}
}
probMap /= data.cols(); // normalization
vcl_vector<double> optimalValues(N, 0);
vcl_vector<int> numValues(N, 0); // multiple values from local dynamic programming
for (int i = 0; i <= N - window_size; i++) {
// get a local probMap;
vnl_matrix<double> localProbMap = probMap.extract(window_size, probMap.cols(), i, 0);
vcl_vector<int> localOptimalBins;
rgrsn_ldp::viterbi(localProbMap, transition, localOptimalBins);
assert(localOptimalBins.size() == window_size);
for (int j = 0; j < localOptimalBins.size(); j++) {
double value = bin_number_to_value(min_v, resolution, localOptimalBins[j]);
numValues[j + i] += 1;
optimalValues[j + i] += value;
}
}
// average all optimal path as final result
for (int i = 0; i<optimalValues.size(); i++) {
optimalValues[i] /= numValues[i];
}
optimal_signal = vnl_vector<double>(&optimalValues[0], (int)optimalValues.size());
return true;
}
示例2: WriteMatrixImageScaled
void WriteMatrixImageScaled(const vnl_matrix<double> &M, const std::string &Filename)
{
vil_image_view<vxl_byte> Image(M.rows(), M.columns(), 1, 1); //(ni, nj, n_planes, n_interleaved_planes)
//double Max = Tools::VectorMax(Vectorize(M));
double Max = M.max_value();
for (unsigned j = 0; j < Image.nj(); j++)
{
for (unsigned i = 0; i < Image.ni(); i++)
{
Image(i,j) = static_cast<vxl_byte>(255 * M(i,j)/Max);
//cout << "M: " << M(i,j) << endl;
//cout << "Image: " << Image(i,j) << endl;
}
}
vil_save(Image, Filename.c_str());
}
示例3: local_viterbi
bool rgrns_viterbi::local_viterbi(const vnl_matrix<double> & data,
double resolution,
const vnl_vector<double> & transition,
unsigned int window_size,
int num_path,
vnl_vector<double> & optimal_signal)
{
assert(resolution > 0.0);
assert(transition.size()%2 == 1);
const double min_v = data.min_value();
const double max_v = data.max_value();
const int nBin = (max_v - min_v)/resolution;
const int path_width_ratio = 20;
// raw data to probability map
// quantilization
const int N = data.rows();
vnl_matrix<double> probMap = vnl_matrix<double>(N, nBin);
for (int r = 0; r<N; r++) {
for (int c = 0; c<data.cols(); c++) {
int num = rgrsn_ldp::value_to_bin_number(min_v, resolution, data[r][c], nBin);
probMap[r][num] += 1.0;
}
}
probMap /= data.cols(); // normalization
vcl_vector<double> optimalValues(N, 0);
vcl_vector<int> numValues(N, 0); // multiple values from local dynamic programming
vnl_matrix<int> valid_map(window_size, nBin); //
valid_map.fill(0);
for (int i = 0; i <= N - window_size; i++) {
// get a local probMap;
vnl_matrix<double> localProbMap = probMap.extract(window_size, probMap.cols(), i, 0);
vcl_vector<int> localOptimalBins;
if (i < window_size) {
rgrsn_ldp::viterbi(localProbMap, transition, localOptimalBins);
}
else
{
// only check the path along with the previous optimal path
rgrns_viterbi::viterbi(localProbMap, valid_map, transition, localOptimalBins);
}
assert(localOptimalBins.size() == window_size);
for (int j = 0; j < localOptimalBins.size(); j++) {
double value = rgrsn_ldp::bin_number_to_value(min_v, resolution, localOptimalBins[j]);
numValues[j + i] += 1;
optimalValues[j + i] += value;
}
// set valid_map for next iteration
valid_map.fill(0);
for (int j = 0; j<localOptimalBins.size(); j++) {
int start = localOptimalBins[j] - transition.size() * path_width_ratio;
int end = localOptimalBins[j] + transition.size() * path_width_ratio;
start = (start >= 0) ? start : 0;
end = (end < nBin) ? end : nBin - 1;
for (int k = start; k <= end; k++) {
valid_map[j][k] = 1;
}
}
}
// average all optimal path as final result
for (int i = 0; i<optimalValues.size(); i++) {
optimalValues[i] /= numValues[i];
}
optimal_signal = vnl_vector<double>(&optimalValues[0], (int)optimalValues.size());
return true;
}