Skip to content

Commit

Permalink
Merge branch 'mpd'
Browse files Browse the repository at this point in the history
  • Loading branch information
deseilligny committed Jul 9, 2024
2 parents e97d4ba + bb7383c commit 2ff12cb
Show file tree
Hide file tree
Showing 8 changed files with 1,042 additions and 437 deletions.
65 changes: 63 additions & 2 deletions MMVII/include/MMVII_ExtractLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,15 @@ class cScoreTetaLine : public tFunc1DReal // herit from tFunc1DReal for optimiza
/// Assure that teta1->teta2 is trigo and teta1<Pi
static void NormalizeTeta(t2Teta &);

const tREAL8 & Length() const; ///< Accessor
const tREAL8 & LengthCur() const; ///< Accessor
cDataIm2D<tREAL4> * DIm() const; ///< Accessor

/// Current lenght can vary
void SetLengthCur(tREAL8 aL);

tREAL8 Prolongate(tREAL8 aLMax, std::pair<tREAL8,tREAL8> & aTeta,bool ReestimateTeta);

tREAL8 Score2Teta(const std::pair<tREAL8,tREAL8> & aTeta, tREAL8 aAbscMin) const;
private :

/// fix center of reusing the data (to avoid cost for cTabulatedDiffInterpolator)
Expand All @@ -288,16 +294,71 @@ class cScoreTetaLine : public tFunc1DReal // herit from tFunc1DReal for optimiza
/// Value as tFunc1DReal
cPt1dr Value(const cPt1dr& aPt) const override;

tREAL8 ScoreOfTeta(const tREAL8 & aTeta, tREAL8 aAbscMin,tREAL8 aSign) const;

cDataIm2D<tREAL4> * mDIm;
tREAL8 mLength;

tREAL8 mLengthInit;
tREAL8 mStepAInit;
tREAL8 mLengthCur;
int mNb;
tREAL8 mStepAbsc;
tREAL8 mStepTeta;
cTabulatedDiffInterpolator mTabInt;
cPt2dr mC;
tREAL8 mCurSign; /// used to specify an orientaion of segment
tREAL8 mStepTetaInit;
tREAL8 mStepTetaLim;
};

/** Base class for optimizing of a segment it inherits of tFunc2DReal so that it can be used by " cOptimByStep<2>"
* in OptimizeSeg . The function "CostOfSeg" must be defined.
*/

class cOptimPosSeg : public tFunc2DReal
{
public :
/// constructor takes initial segment
cOptimPosSeg(const tSeg2dr &);


tSeg2dr OptimizeSeg(tREAL8 aStepInit,tREAL8 aStepLim,bool IsMin,tREAL8 aMaxDInfInit) const;
private :
cSegment2DCompiled<tREAL8> ModifiedSeg(const cPt2dr & aPModif) const;
/// Inteface CostOfSeg to make it a function of tFunc2DReal
cPt1dr Value(const cPt2dr &) const override;
/// Method to define for indicating the cost to optimize
virtual tREAL8 CostOfSeg(const cSegment2DCompiled<tREAL8> &) const = 0;

cSegment2DCompiled<tREAL8> mSegInit; ///< initial value of segment
cPt2dr mP0Loc; ///< First point in local coordinates of segment (y=0)
cPt2dr mP1Loc; ///< Second point in local coordinates of segment (y=0)
};

/** Class for refine the position of a segment where the objective is that, on a given image "I" , the points have a given value "V" :
*
* -----
* \
* / | I(m) - V|
* Cost(Seg) = -----
* p in Seg
* */

template <class Type> class cOptimSeg_ValueIm : public cOptimPosSeg
{
public :
cOptimSeg_ValueIm(const tSeg2dr &,tREAL8 aStepOnSeg,const cDataIm2D<Type> & aDIm,tREAL8 aTargetValue);

tREAL8 CostOfSeg(const cSegment2DCompiled<tREAL8> &) const override;
private :
tREAL8 mStepOnSeg; ///< Sampling step on the seg
int mNbOnSeg; ///< Number of points (computed from mStepOnSeg)
const cDataIm2D<Type> & mDataIm; ///< Image on which it is computed
tREAL8 mTargetValue; ///<
};




};
#endif // _MMVII_EXTRACT_LINES_H_
Expand Down
10 changes: 9 additions & 1 deletion MMVII/include/MMVII_Geom2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ template <class T> inline T Teta(const cPtxd<T,2> & aP1) ///< From x,y to To
return std::atan2(aP1.y(),aP1.x());
}

/// return the "line" angle : i.e angle between 2 non oriented direction, it's always in [0,PI/2]
template <class T> T LineAngles(const cPtxd<T,2> & aDir1,const cPtxd<T,2> & aDir2);


template <class T> inline cPtxd<T,2> ToPolar(const cPtxd<T,2> & aP1,T aDefTeta) ///< With Def value 4 teta
{
return IsNotNull(aP1) ? ToPolar(aP1) : cPtxd<T,2>(0,aDefTeta);
Expand Down Expand Up @@ -608,6 +612,7 @@ class cEllipse
cPt2dr PtAndGradOfTeta(tREAL8 aTeta,cPt2dr &,tREAL8 aMulRho=1.0) const; /// return also the gradien of belong function

cPt2dr ToCoordLoc(const cPt2dr &) const; /// in a sys when ellipse is unity circle
cPt2dr VectToCoordLoc(const cPt2dr &) const; /// for vector (dont use center)
cPt2dr FromCoordLoc(const cPt2dr &) const; /// in a sys when ellipse is unity circle
cPt2dr VectFromCoordLoc(const cPt2dr &) const; /// for vector (dont use center)in a sys when ellipse is unity circle
cPt2dr ToRhoTeta(const cPt2dr &) const; /// Invert function of PtOfTeta
Expand All @@ -618,6 +623,8 @@ class cEllipse
cPt2dr Tgt(const cPt2dr &) const;
cPt2dr NormalInt(const cPt2dr &) const;

cPt2dr InterSemiLine(tREAL8 aTeta) const; /// compute the intesection of 1/2 line of direction teta with the ellipse

private :
void OneBenchEllispe();
cDenseVect<tREAL8> mV;
Expand All @@ -644,12 +651,13 @@ class cEllipse_Estimate
cLeasSqtAA<tREAL8> & Sys();

// indicate a rough center, for better numerical accuracy
cEllipse_Estimate(const cPt2dr & aC0);
cEllipse_Estimate(const cPt2dr & aC0,bool isCenterFree=true);
void AddPt(cPt2dr aP) ;

cEllipse Compute() ;
~cEllipse_Estimate();
private :
bool mIsCenterFree;
cLeasSqtAA<tREAL8> *mSys;
cPt2dr mC0;

Expand Down
3 changes: 3 additions & 0 deletions MMVII/include/MMVII_util_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ template <class Type> void ResizeUp(std::vector<Type> & aV1,size_t aSz,const Typ
aV1.resize(aSz,aVal);
}

template <class Type> void ResizeDown(std::vector<Type> & aV1,size_t aSz) { aV1.resize(std::min(aV1.size(),aSz)); }


template <class Type> void SetAndResize(std::vector<Type> & aVec,size_t aSz,const Type &aVal,const Type & aDef)
{
ResizeUp(aVec,aSz,aDef);
Expand Down
Loading

0 comments on commit 2ff12cb

Please sign in to comment.