56 using namespace DISP3DLIB;
57 using namespace Eigen;
72 const QSharedPointer<MatrixXd> matDistanceTable,
73 double (*interpolationFunction) (
double),
74 const double dCancelDist,
75 const QVector<int> &vecExcludeIndex)
78 if(matDistanceTable->rows() == 0 && matDistanceTable->cols() == 0) {
79 qDebug() <<
"[WARNING] Interpolation::createInterpolationMat - received an empty distance table.";
80 return QSharedPointer<SparseMatrix<float> >::create();
84 QSharedPointer<Eigen::SparseMatrix<float> > matInterpolationMatrix = QSharedPointer<SparseMatrix<float> >::create(matDistanceTable->rows(), vecProjectedSensors.size());
87 QVector<Triplet<float> > vecNonZeroEntries;
88 const qint32 iRows = matInterpolationMatrix->rows();
89 const qint32 iCols = matInterpolationMatrix->cols();
92 QSet<qint32> sensorLookup;
95 for(
const qint32& s : vecProjectedSensors){
96 if(!vecExcludeIndex.contains(idx)){
97 sensorLookup.insert(s);
103 for (qint32 r = 0; r < iRows; ++r) {
104 if (sensorLookup.contains(r) ==
false) {
107 QVector<QPair<qint32, float> > vecBelowThresh;
108 float dWeightsSum = 0.0;
109 const RowVectorXd& rowVec = matDistanceTable->row(r);
111 for (qint32 c = 0; c < iCols; ++c) {
112 const float dDist = rowVec[c];
114 if (dDist < dCancelDist) {
115 const float dValueWeight = std::fabs(1.0 / interpolationFunction(dDist));
116 dWeightsSum += dValueWeight;
117 vecBelowThresh.push_back(qMakePair(c, dValueWeight));
121 for (
const QPair<qint32, float> &qp : vecBelowThresh) {
122 vecNonZeroEntries.push_back(Eigen::Triplet<float> (r, qp.first, qp.second / dWeightsSum));
127 const int iIndexInSubset = vecProjectedSensors.indexOf(r);
129 vecNonZeroEntries.push_back(Eigen::Triplet<float> (r, iIndexInSubset, 1));
133 matInterpolationMatrix->setFromTriplets(vecNonZeroEntries.begin(), vecNonZeroEntries.end());
135 return matInterpolationMatrix;
141 const QSharedPointer<VectorXf> &vecMeasurementData)
143 if (matInterpolationMatrix->cols() != vecMeasurementData->rows()) {
144 qDebug() <<
"[WARNING] Interpolation::interpolateSignal - Dimension mismatch. Return null pointer...";
148 VectorXf pOutVec = *matInterpolationMatrix * (*vecMeasurementData);
156 const VectorXf &vecMeasurementData)
158 if (matInterpolationMatrix.cols() != vecMeasurementData.rows()) {
159 qDebug() <<
"[WARNING] Interpolation::interpolateSignal - Dimension mismatch. Return null pointer...";
163 VectorXf pOutVec = matInterpolationMatrix * vecMeasurementData;
179 return exp(-((dIn * dIn) / 2.0));
186 return std::max((-(1.0f / 9.0f) * (dIn * dIn) + 1), 0.0);
193 return dIn * dIn * dIn;