From aa1e28543bab30f578d123bbf3bb0bc12645eed3 Mon Sep 17 00:00:00 2001 From: Bertrand Kerautret Date: Sat, 21 Oct 2023 11:33:27 +0200 Subject: [PATCH] add extraction of confidence votes --- Changelog.md | 16 ++++++++++------ bin/extractAccOrigins.cpp | 12 ++++++++---- src/NormalAccumulator.cpp | 16 ++++++++++++---- src/NormalAccumulator.h | 5 ++++- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Changelog.md b/Changelog.md index 92f4e99..87f00d6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,19 +1,23 @@ -# Version 1.2 +# Version 1.2 + - Add confidence score extraction from origins. + (Bertrand Kerautret [#31](https://github.com/kerautret/CDCVAM/pull/31)) + - New tools ExtractAccoOrigins and fix duplicated accumulations values + (Bertrand Kerautret [#30](https://github.com/kerautret/CDCVAM/pull/30)) - Fix comilation issue of displayAccuMesh. - (Bertrand Kerautret [#28](Kerautret https://github.com/kerautret/CDCVAM/pull/28)) + (Bertrand Kerautret [#28](https://github.com/kerautret/CDCVAM/pull/28)) - Remove travis and add github actions. - (Bertrand Kerautret [#29](Kerautret https://github.com/kerautret/CDCVAM/pull/29)) + (Bertrand Kerautret [#29](https://github.com/kerautret/CDCVAM/pull/29)) # Version 1.1 - Fix cmake issue with boost - (Bertrand [#25](Kerautret https://github.com/kerautret/CDCVAM/pull/25)) + (Bertrand [#25](https://github.com/kerautret/CDCVAM/pull/25)) - Replace boost prog option with Cli11 - (Bertrand [#24](Kerautret https://github.com/kerautret/CDCVAM/pull/24)) + (Bertrand [#24](https://github.com/kerautret/CDCVAM/pull/24)) - Fix compilation issues (missing std::) - (Bertrand [#23](Kerautret https://github.com/kerautret/CDCVAM/pull/23)) + (Bertrand [#23](https://github.com/kerautret/CDCVAM/pull/23)) # Version 1.0 diff --git a/bin/extractAccOrigins.cpp b/bin/extractAccOrigins.cpp index fbb7dfc..c6490a4 100644 --- a/bin/extractAccOrigins.cpp +++ b/bin/extractAccOrigins.cpp @@ -42,7 +42,6 @@ int main(int argc, char *const *argv) string inputFile; string outputAccOrigins {"exportedAcc.dat"}; unsigned int thAcc {50}; - double thConf {0.75}; double radius {5.0}; bool invertNormal {false}; @@ -59,7 +58,6 @@ int main(int argc, char *const *argv) app.add_option("--radius,-r", radius, "radius of accumulation analysis.", true); app.add_flag("--invertNormal", invertNormal, "export the accumulation vectors."); app.add_option("--maxThAccVectors", thAcc, "threshold the value of accumulations used to decide to export the accumulations vectors (used with outputAccVectors) .", true); - app.add_option("--maxThConfVectors",thConf, "threshold the value of confidence to export the accumulations vectors (used with outputConfVectors) .", true); app.get_formatter()->column_width(40); CLI11_PARSE(app, argc, argv); @@ -77,17 +75,23 @@ int main(int argc, char *const *argv) // 3) Generate accumulation image normAcc.computeAccumulation(); NormalAccumulator::Image3D &imageAccumulation = normAcc.getAccumulationImage(); + normAcc.computeConfidence(true, thAcc ); + + NormalAccumulator::Image3D &imageConfVote = normAcc.getConfidentVoteImage(); if(outputAccOrigins != "") { ofstream fout; fout.open(outputAccOrigins.c_str(), ofstream::binary|ofstream::out); - for(const auto &p: imageAccumulation.domain()) + fout << "# Accumulation extracted from the extractAccOrigins tools of CDVAM." << std::endl; + fout << "# Format X Y Z AccVal ConfScore FaceId1 FaceId2 ...." << std::endl; + + for(const auto &p: imageAccumulation.domain()) { if(imageAccumulation(p)>thAcc) { NormalAccumulator::PointIndexContainer setIndexPt = normAcc.getAssociatedIndexPoints(p); if(setIndexPt.size()!=0){ - fout << p[0] << " " << p[1] << " " << p[2] << " " << imageAccumulation(p) << " " ; + fout << p[0] << " " << p[1] << " " << p[2] << " " << imageAccumulation(p) << " " << imageConfVote(p) << " "; for(const auto &i: setIndexPt) { fout << i << " "; diff --git a/src/NormalAccumulator.cpp b/src/NormalAccumulator.cpp index 03f2d21..686ef11 100644 --- a/src/NormalAccumulator.cpp +++ b/src/NormalAccumulator.cpp @@ -55,6 +55,7 @@ NormalAccumulator::initFromMesh(const DGtal::Mesh &aMesh, bool invertNorm bb.second + DGtal::Z3i::RealPoint::diagonal(3*myRadius)); myAccumulationImage = NormalAccumulator::Image3D(myDomain); myConfidenceImage = NormalAccumulator::Image3DDouble(myDomain); + myConfidentVoteImage = NormalAccumulator::Image3D(myDomain); myRadiusImage = NormalAccumulator::Image3DDouble(myDomain); myAssociationImage = NormalAccumulator::ImagePointAssociation(myDomain); if (myIsVerbose) @@ -434,10 +435,12 @@ NormalAccumulator::computeConfidence(bool updateVertexAsso, unsigned int minAcc } // Step 3: Compute confidance image indicating the rate between accIsMax/acc - for(auto &v: myDomain){ - if ( myAccumulationImage(v) > minAcc ) - myConfidenceImage.setValue(v, scoreConfidance(v)/(double)myAccumulationImage(v)); - } + for(auto &v: myDomain){ + if ( myAccumulationImage(v) > minAcc ) + myConfidenceImage.setValue(v, scoreConfidance(v)/(double)myAccumulationImage(v)); + myConfidentVoteImage.setValue(v, scoreConfidance(v)); + + } myIsAssociationCompFromConfidence = updateVertexAsso; myIsConfidenceComputed = true; } @@ -473,6 +476,11 @@ NormalAccumulator::getAccumulationImage() { } +NormalAccumulator::Image3D & +NormalAccumulator::getConfidentVoteImage() { + return myConfidentVoteImage; +} + NormalAccumulator::Image3DDouble & NormalAccumulator::getConfidenceImage(){ return myConfidenceImage; diff --git a/src/NormalAccumulator.h b/src/NormalAccumulator.h index 99ba878..b2f25ed 100644 --- a/src/NormalAccumulator.h +++ b/src/NormalAccumulator.h @@ -66,7 +66,8 @@ class NormalAccumulator{ myAccumulationImage(DGtal::Z3i::Domain()), myConfidenceImage(DGtal::Z3i::Domain()), myRadiusImage(DGtal::Z3i::Domain()), - myAssociationImage(DGtal::Z3i::Domain()) + myAssociationImage(DGtal::Z3i::Domain()), + myConfidentVoteImage(DGtal::Z3i::Domain()) { @@ -241,6 +242,7 @@ class NormalAccumulator{ Image3D & getAccumulationImage() ; + Image3D & getConfidentVoteImage() ; Image3DDouble & getConfidenceImage() ; @@ -269,6 +271,7 @@ class NormalAccumulator{ Image3D myAccumulationImage; + Image3D myConfidentVoteImage; // represent the number of ray for which the voxel is maximal Image3DDouble myConfidenceImage; Image3DDouble myRadiusImage; ImagePointAssociation myAssociationImage; // to recover all normal origins contributing to an accumulation point.