Skip to content

Commit 07d57c5

Browse files
committed
Check for RMSE when inlier count is same
1 parent 58aebfd commit 07d57c5

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

include/itkLandmarkRegistrationEstimator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LandmarkRegistrationEstimator : public itk::ParametersEstimator<Point<doub
6969
virtual bool
7070
Agree(std::vector<double> & parameters, Point<double, Dimension> & data) override;
7171

72-
virtual std::vector<bool>
72+
virtual std::vector<double>
7373
AgreeMultiple(std::vector<double> & parameters, std::vector<Point<double, Dimension>> & data, unsigned int currentBest) override;
7474

7575
virtual bool

include/itkLandmarkRegistrationEstimator.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ LandmarkRegistrationEstimator<Dimension, TTransform>::CheckCorresspondenceDistan
371371
}
372372

373373
template <unsigned int Dimension, typename TTransform>
374-
std::vector<bool>
374+
std::vector<double>
375375
LandmarkRegistrationEstimator<Dimension, TTransform>::AgreeMultiple(std::vector<double> & parameters,
376376
std::vector<Point<double, Dimension>> & data, unsigned int currentBest)
377377
{
@@ -398,7 +398,7 @@ LandmarkRegistrationEstimator<Dimension, TTransform>::AgreeMultiple(std::vector<
398398
transform->SetParameters(optParameters);
399399

400400
std::vector<double> query_pt(3);
401-
std::vector<bool> output(data.size(), false);
401+
std::vector<double> output(data.size(), -1.0);
402402
//output.reserve(data.size());
403403

404404
const size_t num_results = 1;
@@ -434,8 +434,8 @@ LandmarkRegistrationEstimator<Dimension, TTransform>::AgreeMultiple(std::vector<
434434
if (flag)
435435
{
436436
localBest++;
437+
output[i] = out_dists_sqr[0];
437438
}
438-
output[i] = flag;
439439
}
440440

441441
return output;

include/itkParametersEstimator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ITK_TEMPLATE_EXPORT ParametersEstimator : public Object
8686
virtual bool
8787
Agree(std::vector<SType> & parameters, T & data) = 0;
8888

89-
virtual std::vector<bool>
89+
virtual std::vector<double>
9090
AgreeMultiple(std::vector<SType> & parameters, std::vector<T> & data, unsigned int currentBest) = 0;
9191

9292
virtual bool

include/itkRANSAC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class ITK_TEMPLATE_EXPORT RANSAC : public Object
203203
// agrees with the best model, otherwise false
204204
bool * bestVotes;
205205
unsigned int numVotesForBest;
206+
double bestRMSE;
206207

207208
std::vector<T> data;
208209
std::vector<T> agreeData;

include/itkRANSAC.hxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,24 @@ RANSAC<T, SType, TTransform>::RANSACThreadCallback(void * arg)
345345

346346
// Expensive Inlier Test
347347
auto result = caller->paramEstimator->AgreeMultiple(exactEstimateParameters, caller->agreeData, caller->numVotesForBest);
348+
double rmse_value = 0.0;
349+
348350
for (m = 0; m < numAgreeObjects; m++)
349351
{
350-
if (result[m])
352+
if (result[m] > 0)
351353
{
352354
curVotes[m] = true;
353355
numVotesForCur++;
356+
rmse_value = rmse_value + result[m];
354357
}
355358
} // found a larger consensus set?
356359

357360
caller->resultsMutex.lock();
358-
if (numVotesForCur > caller->numVotesForBest)
361+
if (numVotesForCur > caller->numVotesForBest || (numVotesForCur == caller->numVotesForBest && rmse_value < caller->bestRMSE))
359362
{
360363
caller->numVotesForBest = numVotesForCur;
364+
caller->bestRMSE = rmse_value;
365+
361366
std::copy(curVotes, curVotes + numAgreeObjects, caller->bestVotes);
362367

363368
caller->parametersRansac.clear();

0 commit comments

Comments
 (0)