From e89af1213ae2e187e7a5361169701affdaa24e80 Mon Sep 17 00:00:00 2001 From: deseilligny Date: Tue, 13 Mar 2018 16:33:21 +0100 Subject: [PATCH 1/2] Filter Masq, option dist hom --- src/uti_image/ImVis/Vino_Geom.cpp | 2 +- src/uti_image/NewRechPH/NH_InvarRad.cpp | 4 ++-- src/uti_image/NewRechPH/ParamNewRechPH.xml | 11 +++++++++- src/uti_image/NewRechPH/StatPHom.cpp | 11 ++++++---- src/uti_image/NewRechPH/cParamNewRechPH.cpp | 24 ++++++++++----------- src/uti_image/NewRechPH/cParamNewRechPH.h | 6 +++--- src/uti_phgrm/CPP_HomFilterMasq.cpp | 17 ++++++++++++++- 7 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/uti_image/ImVis/Vino_Geom.cpp b/src/uti_image/ImVis/Vino_Geom.cpp index 640fe324d4..186f5fa525 100644 --- a/src/uti_image/ImVis/Vino_Geom.cpp +++ b/src/uti_image/ImVis/Vino_Geom.cpp @@ -330,7 +330,7 @@ void cAppli_Vino::ShowSPC(const Pt2dr & aPClW) std::cout << "\n"; { - Im2D_INT1 aImLogT = aNearest->ImRad(); + Im2D_INT1 aImLogT = aNearest->ImLogPol(); int aZoom=10; Pt2di aSz = aImLogT.sz(); diff --git a/src/uti_image/NewRechPH/NH_InvarRad.cpp b/src/uti_image/NewRechPH/NH_InvarRad.cpp index 840756a2d3..460aaa2af7 100644 --- a/src/uti_image/NewRechPH/NH_InvarRad.cpp +++ b/src/uti_image/NewRechPH/NH_InvarRad.cpp @@ -369,8 +369,8 @@ bool cAppli_NewRechPH::CalvInvariantRot(cOnePCarac & aPt) aS2 -= ElSquare(aS1); aS2 = sqrt(ElMax(1e-10,aS2)); ELISE_COPY(aImBuf.all_pts(),(aImBuf.in()-aS1)/aS2, aImBuf.out()); - aPt.ImRad() = Im2D_INT1(aImBuf.sz().x,aImBuf.sz().y); - ELISE_COPY(aImBuf.all_pts(),Max(-128,Min(127,round_ni(aImBuf.in()*32))),aPt.ImRad().out()); + aPt.ImLogPol() = Im2D_INT1(aImBuf.sz().x,aImBuf.sz().y); + ELISE_COPY(aImBuf.all_pts(),Max(-128,Min(127,round_ni(aImBuf.in()*32))),aPt.ImLogPol().out()); aPt.VectRho() = aVRho; if (BUG) diff --git a/src/uti_image/NewRechPH/ParamNewRechPH.xml b/src/uti_image/NewRechPH/ParamNewRechPH.xml index f8032a287b..c5dbcfa93e 100644 --- a/src/uti_image/NewRechPH/ParamNewRechPH.xml +++ b/src/uti_image/NewRechPH/ParamNewRechPH.xml @@ -88,6 +88,14 @@ + + + + + + + + @@ -105,8 +113,9 @@ - + + diff --git a/src/uti_image/NewRechPH/StatPHom.cpp b/src/uti_image/NewRechPH/StatPHom.cpp index 0e5a863f15..1abd45df99 100644 --- a/src/uti_image/NewRechPH/StatPHom.cpp +++ b/src/uti_image/NewRechPH/StatPHom.cpp @@ -179,7 +179,9 @@ void cOneImSPH::TestMatch(cOneImSPH & aI2) if ((!aV1.empty()) && (!aV2.empty())) { aI2.mVNearest.clear(); - std::cout << "===========================================================\n"; + std::cout << "*************===========================================================*************\n"; + std::cout << "*************===========================================================*************\n"; + std::cout << "*************===========================================================*************\n"; std::cout << "For " << eToString(aLab) << " sz=" << aV1.size() << " " << aV2.size() << "\n"; std::vector aVD22; @@ -190,7 +192,7 @@ void cOneImSPH::TestMatch(cOneImSPH & aI2) aI2.mVNearest.push_back(aP); aVD22.push_back(aDist); } - mAppli.ShowStat("Nearest D for ",20,aVD22); + mAppli.ShowStat("Distribution du point le plus proche avec meme carac",20,aVD22); std::vector aVD12; @@ -336,8 +338,9 @@ void cAppliStatPHom::TestHom() } } } - ShowStat("ECAR EPIP",20,aVREpi); - ShowStat("ECAR COMPL",20,aVRComp); + // La, on test la qualite des references , epipolaire et nuages + ShowStat("ECAR EPIP pour les points SIFT",20,aVREpi); + ShowStat("ECAR COMPLET pour les points SIFT",20,aVRComp); /* int aNB= 20; std::cout << "========= ECAR EPIP ==========\n"; diff --git a/src/uti_image/NewRechPH/cParamNewRechPH.cpp b/src/uti_image/NewRechPH/cParamNewRechPH.cpp index 3488fdd91f..41512381e1 100644 --- a/src/uti_image/NewRechPH/cParamNewRechPH.cpp +++ b/src/uti_image/NewRechPH/cParamNewRechPH.cpp @@ -508,14 +508,14 @@ const cOneInvRad & cOnePCarac::InvR()const } -Im2D_INT1 & cOnePCarac::ImRad() +Im2D_INT1 & cOnePCarac::ImLogPol() { - return mImRad; + return mImLogPol; } -const Im2D_INT1 & cOnePCarac::ImRad()const +const Im2D_INT1 & cOnePCarac::ImLogPol()const { - return mImRad; + return mImLogPol; } @@ -545,7 +545,7 @@ void BinaryUnDumpFromFile(cOnePCarac & anObj,ELISE_fp & aFp) BinaryUnDumpFromFile(anObj.AutoCorrel(),aFp); BinaryUnDumpFromFile(anObj.OK(),aFp); BinaryUnDumpFromFile(anObj.InvR(),aFp); - BinaryUnDumpFromFile(anObj.ImRad(),aFp); + BinaryUnDumpFromFile(anObj.ImLogPol(),aFp); BinaryUnDumpFromFile(anObj.VectRho(),aFp); } @@ -565,7 +565,7 @@ void BinaryDumpInFile(ELISE_fp & aFp,const cOnePCarac & anObj) BinaryDumpInFile(aFp,anObj.AutoCorrel()); BinaryDumpInFile(aFp,anObj.OK()); BinaryDumpInFile(aFp,anObj.InvR()); - BinaryDumpInFile(aFp,anObj.ImRad()); + BinaryDumpInFile(aFp,anObj.ImLogPol()); BinaryDumpInFile(aFp,anObj.VectRho()); } @@ -587,7 +587,7 @@ cElXMLTree * ToXMLTree(const cOnePCarac & anObj) aRes->AddFils(::ToXMLTree(std::string("AutoCorrel"),anObj.AutoCorrel())->ReTagThis("AutoCorrel")); aRes->AddFils(::ToXMLTree(std::string("OK"),anObj.OK())->ReTagThis("OK")); aRes->AddFils(ToXMLTree(anObj.InvR())->ReTagThis("InvR")); - aRes->AddFils(::ToXMLTree(std::string("ImRad"),anObj.ImRad())->ReTagThis("ImRad")); + aRes->AddFils(::ToXMLTree(std::string("ImLogPol"),anObj.ImLogPol())->ReTagThis("ImLogPol")); aRes->AddFils(::ToXMLTree(std::string("VectRho"),anObj.VectRho())->ReTagThis("VectRho")); aRes->mGXml = anObj.mGXml; XMLPopContext(anObj.mGXml); @@ -627,12 +627,12 @@ void xml_init(cOnePCarac & anObj,cElXMLTree * aTree) xml_init(anObj.InvR(),aTree->Get("InvR",1)); //tototo - xml_init(anObj.ImRad(),aTree->Get("ImRad",1)); //tototo + xml_init(anObj.ImLogPol(),aTree->Get("ImLogPol",1)); //tototo xml_init(anObj.VectRho(),aTree->Get("VectRho",1)); //tototo } -std::string Mangling( cOnePCarac *) {return "A1E622235CA23AC9FD3F";}; +std::string Mangling( cOnePCarac *) {return "E0CF3BC532583685FE3F";}; std::vector< cOnePCarac > & cSetPCarac::OnePCarac() @@ -691,7 +691,7 @@ void xml_init(cSetPCarac & anObj,cElXMLTree * aTree) xml_init(anObj.OnePCarac(),aTree->GetAll("OnePCarac",false,1)); } -std::string Mangling( cSetPCarac *) {return "00FB91C136438280FE3F";}; +std::string Mangling( cSetPCarac *) {return "55544900B54811F1FE3F";}; cOnePCarac & cSRPC_Truth::P1() @@ -748,7 +748,7 @@ void xml_init(cSRPC_Truth & anObj,cElXMLTree * aTree) xml_init(anObj.P2(),aTree->Get("P2",1)); //tototo } -std::string Mangling( cSRPC_Truth *) {return "208C32A1E44ECED3FBBF";}; +std::string Mangling( cSRPC_Truth *) {return "605FA27E9728E3ABFBBF";}; std::vector< cSRPC_Truth > & cSetRefPCarac::SRPC_Truth() @@ -841,7 +841,7 @@ void xml_init(cSetRefPCarac & anObj,cElXMLTree * aTree) xml_init(anObj.SRPC_Rand(),aTree->GetAll("SRPC_Rand",false,1)); } -std::string Mangling( cSetRefPCarac *) {return "86C0DAE397FC78B5FD3F";}; +std::string Mangling( cSetRefPCarac *) {return "D1AF655A5B3CE59CFE3F";}; std::vector & cCBOneBit::Coeff() diff --git a/src/uti_image/NewRechPH/cParamNewRechPH.h b/src/uti_image/NewRechPH/cParamNewRechPH.h index 451a43f30a..89eec818a1 100644 --- a/src/uti_image/NewRechPH/cParamNewRechPH.h +++ b/src/uti_image/NewRechPH/cParamNewRechPH.h @@ -179,8 +179,8 @@ class cOnePCarac cOneInvRad & InvR(); const cOneInvRad & InvR()const ; - Im2D_INT1 & ImRad(); - const Im2D_INT1 & ImRad()const ; + Im2D_INT1 & ImLogPol(); + const Im2D_INT1 & ImLogPol()const ; std::vector & VectRho(); const std::vector & VectRho()const ; @@ -199,7 +199,7 @@ class cOnePCarac double mAutoCorrel; bool mOK; cOneInvRad mInvR; - Im2D_INT1 mImRad; + Im2D_INT1 mImLogPol; std::vector mVectRho; }; cElXMLTree * ToXMLTree(const cOnePCarac &); diff --git a/src/uti_phgrm/CPP_HomFilterMasq.cpp b/src/uti_phgrm/CPP_HomFilterMasq.cpp index bb93c9fbdc..7be4deb26a 100644 --- a/src/uti_phgrm/CPP_HomFilterMasq.cpp +++ b/src/uti_phgrm/CPP_HomFilterMasq.cpp @@ -89,6 +89,7 @@ int HomFilterMasq_main(int argc,char ** argv) std::string aOriMasq3D,aNameMasq3D; cMasqBin3D * aMasq3D = 0; double aDistId=-1; + double aDistHom=-1; Pt2dr aSelecTer; @@ -111,6 +112,7 @@ int HomFilterMasq_main(int argc,char ** argv) << EAM(aNameMasq3D,"Masq3D",true,"File of Masq3D, Def=AperiCloud_${OriMasq3D}.ply") << EAM(aSelecTer,"SelecTer",true,"[Per,Prop] Period of tiling on ground selection, Prop=proporion of selected") << EAM(aDistId,"DistId",true,"Supress pair such that d(P1,P2) < DistId, def unused") + << EAM(aDistHom,"DistH",true,"Distance for filtering homologous point") ); bool aHasOri3D = EAMIsInit(&aOriMasq3D); bool HasTerSelec = EAMIsInit(&aSelecTer); @@ -145,7 +147,7 @@ int HomFilterMasq_main(int argc,char ** argv) } else { - ELISE_ASSERT(EAMIsInit(&aSelecTer),"Unused OriMasq3D"); + ELISE_ASSERT(EAMIsInit(&aSelecTer) || (aDistHom>=0),"Unused OriMasq3D"); } aKeyOri = "NKS-Assoc-Im2Orient@" + aOriMasq3D; } @@ -289,6 +291,19 @@ std::cout << aNameIm1 << " # " << aNameIm2 << "\n"; aNbTestTer ++; aNbInTer += OkTer; } + + if (aDistHom >0 ) + { + Pt2dr aRP1 = aVCam[aKN1]->Ter2Capteur(aPTer); + Pt2dr aRP2 = aVCam[aKN2]->Ter2Capteur(aPTer); + double aD1 = euclid(aP1,aRP1); + double aD2 = euclid(aP2,aRP2); + if ((aD1+aD2) > aDistHom) + { + Ok = false; + std::cout << "DIST " << aD1 << " " << aD2 << "\n"; + } + } } if (Ok && (aDistId>=0)) From 5938966c037de1185d36c5e3c4e712943a7f2601 Mon Sep 17 00:00:00 2001 From: deseilligny Date: Wed, 14 Mar 2018 21:00:07 +0100 Subject: [PATCH 2/2] Hom filter + Rolling sur FITS --- src/uti_image/NewRechPH/NH_InvarRad.cpp | 75 +++++++++++++++++++++---- src/uti_image/NewRechPH/NewRechPH.cpp | 8 ++- src/uti_image/NewRechPH/NewRechPH.h | 7 ++- src/uti_phgrm/CPP_HomFilterMasq.cpp | 2 +- 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/src/uti_image/NewRechPH/NH_InvarRad.cpp b/src/uti_image/NewRechPH/NH_InvarRad.cpp index 460aaa2af7..68a11f5de9 100644 --- a/src/uti_image/NewRechPH/NH_InvarRad.cpp +++ b/src/uti_image/NewRechPH/NH_InvarRad.cpp @@ -40,9 +40,14 @@ Header-MicMac-eLiSe-25/06/2007*/ #include "NewRechPH.h" -Pt2di cAppli_NewRechPH::SzInvRad() +Pt2di cAppli_NewRechPH::SzInvRadUse() { - return Pt2di(mNbSR, mNbTetaInv); + return Pt2di(mNbSR2Use, mNbTetaInv); +} + +Pt2di cAppli_NewRechPH::SzInvRadCalc() +{ + return Pt2di(mNbSR2Calc, mNbTetaInv); } /* @@ -169,6 +174,23 @@ class cRadInvStat double mS3; }; + // return Pt2di(mNbSR2Use, mNbTetaInv); +void Normalise(tImNRPH aImBuf,tImNRPH aImOut,int aX0In,int aX1In,int aSzXOut) +{ + int aSzY = aImBuf.sz().y; + double aS0,aS1,aS2; + ELISE_COPY + ( + rectangle(Pt2di(aX0In,0),Pt2di(aX1In,aSzY)), + Virgule(1,aImBuf.in(),Square(aImBuf.in())), + Virgule(sigma(aS0),sigma(aS1),sigma(aS2)) + ); + aS1 /= aS0; + aS2 /= aS0; + aS2 -= ElSquare(aS1); + aS2 = sqrt(ElMax(1e-10,aS2)); + ELISE_COPY(rectangle(Pt2di(aX0In,0),Pt2di(aX0In+aSzXOut,aSzY)),(aImBuf.in()-aS1)/aS2, aImBuf.out()); +} bool cAppli_NewRechPH::CalvInvariantRot(cOnePCarac & aPt) @@ -182,7 +204,7 @@ bool cAppli_NewRechPH::CalvInvariantRot(cOnePCarac & aPt) } // Buf[KTeta][KRho] pour KRho=0, duplication de la valeur centrale - tImNRPH aImBuf(SzInvRad().x,SzInvRad().y); + tImNRPH aImBuf(SzInvRadCalc().x,SzInvRadCalc().y); tTImNRPH aTBuf(aImBuf); std::vector aVIm; @@ -194,7 +216,7 @@ bool cAppli_NewRechPH::CalvInvariantRot(cOnePCarac & aPt) int aN0 = aPt.NivScale(); // aVIm.push_back(mVI1.at(aN0)); - for (int aKRho=0 ; aKRho 0 ) + if (Ok && (aDistHom >0 )) { Pt2dr aRP1 = aVCam[aKN1]->Ter2Capteur(aPTer); Pt2dr aRP2 = aVCam[aKN2]->Ter2Capteur(aPTer);