From: lgrezesb Date: Wed, 10 Feb 2010 14:55:00 +0000 (+0000) Subject: Good version of clitkSignalMeanPosition, from clitk2 X-Git-Tag: v1.2.0~813 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=253e4eea321f0a154e1c57834f36d4e4c4b34ef1;p=clitk.git Good version of clitkSignalMeanPosition, from clitk2 --- diff --git a/tools/clitkSignalMeanPositionFilter.cxx b/tools/clitkSignalMeanPositionFilter.cxx index 912d9ee..905af5e 100644 --- a/tools/clitkSignalMeanPositionFilter.cxx +++ b/tools/clitkSignalMeanPositionFilter.cxx @@ -1,7 +1,10 @@ /*========================================================================= Program: clitk + Module: $RCSfile: clitkSignalMeanPositionFilter.cxx,v $ Language: C++ + Date: $Date: 2010/02/10 14:55:00 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,6 +28,8 @@ void clitk::SignalMeanPositionFilter::SetParameters(args_info_clitkSignalMeanPos mAugmentationDelay = args_info.delay_arg; mIsAdaptiveMethod = false; mWindowLength = -1; + mValidationWithRealPhase = false; + mUseLearnedDeltaPhase = false; if (args_info.eta_given) { mEta = args_info.eta_arg; mEtaIsSet = true; @@ -48,6 +53,28 @@ void clitk::SignalMeanPositionFilter::SetParameters(args_info_clitkSignalMeanPos mIsAdaptiveMethod = true; mWindowLength = args_info.L_arg; } + if (args_info.phase_given) { + mValidationWithRealPhase = true; + mInputPhaseFilename = args_info.phase_arg; + mInputPhase.Read(mInputPhaseFilename); + } + mNumberOfIsoPhase = args_info.nbiso_arg; + if (args_info.delta_given) { + mUseLearnedDeltaPhase = true; + mLearnIsoPhaseDelta.Read(args_info.delta_arg); + mNumberOfIsoPhase = mLearnIsoPhaseDelta.size(); + } + + // DEBUG + if (args_info.phase_given) { + std::cout << "PLEASE DO NO USE THIS OPTION --phase YET ..." << std::endl; + exit(0); + } + if (args_info.delta_given) { + std::cout << "PLEASE DO NO USE THIS OPTION --delta YET ..." << std::endl; + exit(0); + } + } //--------------------------------------------------------------------- @@ -55,45 +82,19 @@ void clitk::SignalMeanPositionFilter::SetParameters(args_info_clitkSignalMeanPos //--------------------------------------------------------------------- void clitk::SignalMeanPositionFilter::Update() { - // DEBUG -// int e = 5; -// clitk::Signal temp; -// temp.resize(mInput.size()*e); -// for(unsigned int i=0; i phase; + ComputeIsoPhase(mListOfEllipses, phase, mCycles); + + //int currentCycle = 0; + for (unsigned int i=0; i & l, + std::vector & phase, + std::vector & cycles) { + double refphaseangle=0; + double previousangle=0; + phase.resize(mListOfEllipses.size()); + + // DD(mListOfEllipses.size()); + mIsoPhaseIndex.resize(mListOfEllipses.size()); + // mIsoPhaseDelta.resize(mNumberOfIsoPhase); + // mIsoPhaseDeltaNb.resize(mNumberOfIsoPhase); + mIsoPhaseRefAngle.resize(mNumberOfIsoPhase); + + for (unsigned int i=0; iComputeSemiAxeLengths()[0]; + double theta = mListOfEllipses[0]->ComputeAngleInRad(); + Vector2d x2; x2[0] = x1[0]+a * cos(theta); x2[1] = x1[1]+a * sin(theta); + Vector2d x3(x1); + Vector2d x4; x4[0] = mAugmentedInputX[i+mWindowLength]; x4[1] = mAugmentedInputY[i+mWindowLength]; + Vector2d A(x2-x1); + Vector2d B(x4-x3); + double signed_angle = atan2(B[1], B[0]) - atan2(A[1], A[0]); + // double signed_angle = atan2(B[1], B[0]) - atan2(0, 1); + if (signed_angle<0) signed_angle = 2*M_PI+signed_angle; + // http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm + + // First time : set the angle + if (i==0) { + refphaseangle = signed_angle; + for(int a=0; a 2*M_PI) mIsoPhaseRefAngle[a] -= 2*M_PI; + if (mIsoPhaseRefAngle[a] < 0) mIsoPhaseRefAngle[a] = 2*M_PI-mIsoPhaseRefAngle[a]; + // DD(rad2deg(mIsoPhaseRefAngle[a])); + // mIsoPhaseDelta[a] = 0.0; + // mIsoPhaseDeltaNb[a] = 0; + } + int a=0; + // DD(rad2deg(signed_angle)); + while ((a=mIsoPhaseRefAngle[a])) { a++; } + // DD(a); + mIsoPhaseIndex[i] = a-1; + // DD(mIsoPhaseIndex[0]); + cycles.push_back(0); + } + else { + mIsoPhaseIndex[i] = mIsoPhaseIndex[i-1]; + + // Check if angle cross a ref angle + for(int a=0; a1.0) phase[j] = 1.0-phase[j]; + DD(phase[j]); + j++; + } + } + else j+=cycles[0]; + } + */ + for (unsigned int i=0; i namespace clitk { @@ -51,15 +55,28 @@ namespace clitk { bool mIsAdaptiveMethod; std::vector mCurrentResidual; int mWindowLength; - std::vector mCenters; + std::vector mListOfEllipses; + + bool mValidationWithRealPhase; + std::string mInputPhaseFilename; + clitk::Signal mInputPhase; + std::vector mCycles; + + std::vector mIsoPhaseIndex; + std::vector mIsoPhaseDelta; + std::vector mIsoPhaseDeltaNb; + std::vector mIsoPhaseRefAngle; + + bool mUseLearnedDeltaPhase; + clitk::Signal mLearnIsoPhaseDelta; + int mNumberOfIsoPhase; void FitEllipse(clitk::Ellipse & An); void AdaptiveFitEllipse(clitk::Ellipse & An); - void ComputeAugmentedSpace(const clitk::Signal & input, - clitk::Signal & outputX, - clitk::Signal & outputY, - unsigned int delay); + void ComputeIsoPhase(std::vector & l, + std::vector & phase, + std::vector & cycles); }; //--------------------------------------------------------------------- diff --git a/tools/clitkSignalMeanPositionTracking.cxx b/tools/clitkSignalMeanPositionTracking.cxx index e63e929..939d7b9 100644 --- a/tools/clitkSignalMeanPositionTracking.cxx +++ b/tools/clitkSignalMeanPositionTracking.cxx @@ -1,7 +1,10 @@ /*========================================================================= Program: clitk + Module: $RCSfile: clitkSignalMeanPositionTracking.cxx,v $ Language: C++ + Date: $Date: 2010/02/10 14:55:00 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or diff --git a/tools/clitkSignalMeanPositionTracking.ggo b/tools/clitkSignalMeanPositionTracking.ggo index 46baa88..a1a7939 100644 --- a/tools/clitkSignalMeanPositionTracking.ggo +++ b/tools/clitkSignalMeanPositionTracking.ggo @@ -9,7 +9,12 @@ option "delay" d "Delay for augmented space" int no default="10" option "eta" e "Convergence param (auto if not given)" double no option "iter" - "Max # of iterations" int no default="100" option "L" L "Sliding window length" int no -option "t" t "DEBUG" int no +option "t" t "DEBUG" int no default="1000" + +option "phase" p "Input phase file for validation" string no +option "delta" - "Input learn delta phase file" string no +option "nbiso" n "Number of iso phase" int no default="1" + section "Output" option "output" o "Output ellipse param filename (2 lines=initial/final ; 6 quadratic param + 5 parametric param=center/axis/theta)" string no