#include "ConfidenceMaps2D.h" ConfidenceMaps2D::ConfidenceMaps2D() { } ConfidenceMaps2D::~ConfidenceMaps2D() { } void ConfidenceMaps2D::setMatrix2D(const std::vector * matrix, int rows, int cols, bool normalizeValues) { this->matrix = matrix; this->rows = rows; this->cols = cols; this->numel = rows*cols; std::vector * matrix_ptr = const_cast* >(matrix); if(normalizeValues) { double min_mat; double max_mat; min_mat = (*matrix).front(); max_mat = (*matrix).front(); //Find min-max for(size_t i=0; isize();i++) { double val = (*matrix)[i]; if( val< min_mat ) min_mat = val; if(val > max_mat) max_mat = val; } // Normalization values double diff = (max_mat - min_mat); // Prevent division by zero const double epsilon_diff = 1.0e-17; if(diffsize();i++) (*matrix_ptr)[i] = ((*matrix_ptr)[i] - min_mat) /diff; } std::vector dist_penalty; dist_penalty.reserve(rows); for(int i=0; i::epsilon(); // Numerical limit to avoid division by zero and add to the weights to avoid zero weights in Laplacian // Numerical limit to avoid division by zero and add to the weights to avoid zero weights in Laplacian const double epsilon = 1.0e-5; this->L.resize(numel,numel); // Find min and max weights double min_weight; double max_weight; min_weight = (*matrix).front(); max_weight = (*matrix).front(); // Horizontal edges for(int i=0; i<= numel-rows-1; i++) { double weight = abs((*matrix)[i] - (*matrix)[i+rows]); weight += gamma; if(weight < min_weight ) min_weight = weight; if(weight > max_weight) max_weight = weight; } // Vertical edges for(int i=0; i<= numel-rows; i+=rows) { for(int j=0; j<=rows-2; j++) { double weight = abs((*matrix)[i+j] - (*matrix)[i+j+1]) ; if(weight < min_weight ) min_weight = weight; if(weight > max_weight) max_weight = weight; } } // ---Find min and max weights // Normalization values double diff = (max_weight - min_weight); // Prevent division by zero const double epsilon_diff = 1.0e-17; if(diff